BrandIndex.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <div class="brand-center-index" id="index" @click="showSimilarWord = false">
  3. <img src="/images/brandCenter/brand-index-title1.png" alt="">
  4. <div class="brand-index-tab">
  5. <div class="brand-index-group" v-for="(indexGroup, index) in indexGroups">
  6. <span v-if="index == 5"></span>
  7. <a @click="goBrandIndex(group_index)" v-for="group_index in indexGroup" :class="{'active': activeIndex==group_index}">{{group_index}}</a>
  8. <span v-if="index == 5"></span>
  9. </div>
  10. </div>
  11. <div class="brand-center-index-list">
  12. <div class="brand-list-nav">
  13. <div class="filter-area">
  14. <input type="text" placeholder="请输入您要搜索的品牌" @input="onKeywordInput()" v-model="keyword" @keyup.13="searchBrands()">
  15. <img src="/images/brandCenter/search-btn.png" alt="" @click="searchBrands()">
  16. <span v-if="brandList.totalElements > 0">{{nowPage}}/{{brandList.totalPages}}
  17. <a href="javascript:void(0)" class="icon-xiangzuo iconfont" @click="changePage('pre')" :class="{'is-border': nowPage==1}"></a>
  18. <a href="javascript:void(0)" @click="changePage('next')" class="icon-xiangyou iconfont" :class="{'is-border': nowPage>=brandList.totalPages}"></a>
  19. </span>
  20. <ul class="similar-list" v-show="showSimilarWord && keyword && keyword.length">
  21. <li class="text-ellipse" v-for="similar in similarList" @click.stop="setSimilar(similar.nameCn)">{{similar.nameCn}}</li>
  22. </ul>
  23. </div>
  24. </div>
  25. <div class="brand-list-items">
  26. <span v-show="!isSearch">
  27. 以{{activeIndex&&activeIndex.length==1?'字母':''}}
  28. <span class="active-index">{{activeIndex}}&nbsp;</span>开头共有
  29. <span class="active-number">{{brandList.totalElements || 0}}&nbsp;</span>个品牌
  30. <span v-if="brandList.totalElements > 0">,当前是第
  31. <span class="active-number">{{nowPage}}&nbsp;</span>页
  32. </span>
  33. </span>
  34. <span v-show="isSearch">
  35. 搜索
  36. <span class="active-index">"{{showKeyword}}"&nbsp;</span>,为您找到
  37. <span class="active-number">{{brandList.totalElements || 0}}&nbsp;</span>个相关品牌:
  38. </span>
  39. <div class="brand-list-item-wrap" v-for="brand in brandList.content">
  40. <a :href="'/product/brand/'+brand.uuid" target="_blank">
  41. <span v-if="brand.nameEn">{{brand.nameEn}}</span>
  42. <span v-if="brand.nameCn != brand.nameEn">{{brand.nameCn}}</span>
  43. <div class="brand-intro">
  44. <span class="brand-application">应用领域:{{brand.application | applicationFilter}}</span>
  45. <span >品牌介绍:{{brand.brief | introduceFilter}}</span>
  46. </div>
  47. </a>
  48. </div>
  49. <div v-if="brandList.totalElements <= 0" class="empty-remind">
  50. 商城暂未收录您想要查找的品牌,可前往<a @click="goBrandApply">“品牌申请”</a>提醒我们完善该品牌信息
  51. </div>
  52. <div class="search-modal-wrap" v-if="showSearchModal"></div>
  53. </div>
  54. <page :total="brandList.totalElements" :page-size="pageSize"
  55. :current="nowPage" v-on:childEvent="listenPage"></page>
  56. </div>
  57. <img src="/images/brandCenter/features.png" alt="">
  58. </div>
  59. </template>
  60. <script>
  61. import Page from '~components/common/page/pageComponent.vue'
  62. import PcSearchHeader from '~components/common/PcSearchHeader.vue'
  63. export default {
  64. data () {
  65. return {
  66. indexGroups: [
  67. ['A', 'B', 'C', 'D', 'E'],
  68. ['F', 'G', 'H', 'I', 'J'],
  69. ['K', 'L', 'M', 'N', 'O'],
  70. ['P', 'Q', 'R', 'S', 'T'],
  71. ['U', 'V', 'W', 'X', 'Y', 'Z'],
  72. ['0~9']
  73. ],
  74. nowPage: 1,
  75. pageSize: 60,
  76. keyword: '',
  77. isSearch: false,
  78. brands: {},
  79. showKeyword: '',
  80. showSearchModal: false,
  81. clickCount: 0,
  82. showSimilarWord: false,
  83. similarList: []
  84. }
  85. },
  86. filters: {
  87. applicationFilter: function (str) {
  88. return str ? str.split(',').join('|') : '-'
  89. },
  90. introduceFilter: function (str) {
  91. if (!str || str === '') {
  92. return '-'
  93. }
  94. let len = 0
  95. let index = 0
  96. for (let i = 0; i < str.length; i++) {
  97. if (index === 0 && str.charAt(i).charCodeAt(0) > 255) {
  98. len = len + 2
  99. } else {
  100. len++
  101. }
  102. if (len > 50) {
  103. index = i
  104. break
  105. }
  106. }
  107. if (index > 0) {
  108. return str.substring(0, index) + '...'
  109. } else {
  110. return str
  111. }
  112. }
  113. },
  114. components: {
  115. Page,
  116. PcSearchHeader
  117. },
  118. mounted () {
  119. if (this.$route.path !== '/product/brand/brandList/A') {
  120. this.$router.push('/product/brand/brandList/A')
  121. }
  122. },
  123. computed: {
  124. brandList () {
  125. let brandsList = !this.isSearch ? this.$store.state.product.brand.brandPagerList.data : this.brands
  126. brandsList.content = brandsList.content || []
  127. return brandsList
  128. },
  129. activeIndex () {
  130. return !this.isSearch ? this.$route.params.initial : ''
  131. },
  132. user () {
  133. return this.$store.state.option.user
  134. }
  135. },
  136. watch: {
  137. $route: function (val, oldVal) {
  138. this.initParams()
  139. }
  140. },
  141. methods: {
  142. onKeywordInput: function () {
  143. this.clickCount ++
  144. let count = this.clickCount
  145. let timer = setTimeout(() => {
  146. this.getSimilarList(count, timer)
  147. }, 300)
  148. },
  149. getSimilarList: function (clickCount, timer) {
  150. clearTimeout(timer)
  151. if (this.keyword && this.keyword !== '' && clickCount === this.clickCount) {
  152. this.$http.get('/search/similarKeywords', {params: {keyword: this.keyword}}).then(
  153. res => {
  154. this.similarList = res.data.brand
  155. this.showSimilarWord = true
  156. }
  157. )
  158. }
  159. },
  160. setSimilar: function (key) {
  161. this.showSimilarWord = false
  162. this.keyword = key
  163. this.searchBrands()
  164. },
  165. initParams: function () {
  166. this.nowPage = 1
  167. this.isSearch = false
  168. this.keyword = ''
  169. this.reloadData()
  170. },
  171. reloadData: function () {
  172. !this.isSearch ? this.$store.dispatch('product/loadBrandsPager', {'initial': this.$route.params.initial, 'page': this.nowPage, 'count': this.pageSize, 'keyword': this.keyword}) : this.searchData()
  173. },
  174. searchData: function () {
  175. this.showSearchModal = true
  176. this.$http.get('/api/product/brand/Brand/ByPage', {params: {'page': this.nowPage, 'count': this.pageSize, 'keyword': this.keyword}})
  177. .then(response => {
  178. this.brands = response.data
  179. this.isSearch = true
  180. this.showKeyword = this.keyword
  181. this.showSearchModal = false
  182. })
  183. },
  184. listenPage: function (page) {
  185. this.nowPage = page
  186. this.reloadData()
  187. },
  188. changePage: function (type) {
  189. if (type === 'next' && this.nowPage < this.brandList.totalPages) {
  190. this.nowPage ++
  191. } else if (type === 'pre' && this.nowPage > 1) {
  192. this.nowPage --
  193. }
  194. this.reloadData()
  195. },
  196. searchBrands: function () {
  197. if (this.keyword && this.keyword !== '') {
  198. this.nowPage = 1
  199. this.searchData()
  200. } else {
  201. this.initParams()
  202. this.reloadData()
  203. this.$router.push('/product/brand/brandList/A')
  204. }
  205. },
  206. goBrandIndex: function (index) {
  207. if (index === this.$route.params.initial) {
  208. this.initParams()
  209. this.reloadData()
  210. } else {
  211. this.$router.push('/product/brand/brandList/' + index)
  212. // window.location.href = '/product/brand/brandList/' + index + '#index'
  213. // window.open('/product/brand/brandList/' + index + '#index', '_self')
  214. }
  215. },
  216. goBrandApply: function () {
  217. if (!this.user.logged) {
  218. this.login()
  219. } else {
  220. window.open('/vendor#/brand/apply/')
  221. }
  222. },
  223. login: function () {
  224. this.$http.get('/login/page', {params: {returnUrl: window.location.href}}).then(response => {
  225. if (response.data) {
  226. this.$router.push('/auth/login')
  227. }
  228. })
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. .brand-center-index {
  235. width: 1190px;
  236. margin: 0 auto;
  237. >img {
  238. width: 1190px;
  239. height: 50px;
  240. margin-top: 20px;
  241. &:last-child{
  242. height: 70px;
  243. margin-bottom: 40px;
  244. }
  245. }
  246. .brand-index-tab {
  247. height: 206px;
  248. position: relative;
  249. background: url(/images/brandCenter/brand-index-tree.png) no-repeat;
  250. background-position: 60px 71.7px;
  251. background-color: #eef1fd;
  252. .brand-index-group {
  253. height: 40px;
  254. text-align: center;
  255. position: absolute;
  256. a {
  257. width: 40px;
  258. height: 40px;
  259. text-align: center;
  260. display: inline-block;
  261. color: #fff;
  262. line-height: 40px;
  263. font-size: 16px;
  264. vertical-align: middle;
  265. }
  266. span {
  267. width: 10px;
  268. height: 40px;
  269. display: inline-block;
  270. background: #898ef3;
  271. vertical-align: middle;
  272. }
  273. &:nth-child(1) {
  274. left: 184px;
  275. top: 32px;
  276. a {
  277. background: #fc524a;
  278. &.active {
  279. font-weight: bold;
  280. background-color: #ec190f;
  281. position: relative;
  282. bottom: 2px;
  283. }
  284. &:hover {
  285. font-weight: bold;
  286. position: relative;
  287. bottom: 2px;
  288. background-color: #ec190f;
  289. }
  290. }
  291. }
  292. &:nth-child(2) {
  293. left: 322px;
  294. bottom: 22px;
  295. a {
  296. background: #fdad33;
  297. &.active {
  298. font-weight: bold;
  299. background-color: #ea8f02;
  300. position: relative;
  301. bottom: 2px;
  302. }
  303. &:hover {
  304. font-weight: bold;
  305. position: relative;
  306. bottom: 2px;
  307. background-color: #ea8f02;
  308. }
  309. }
  310. }
  311. &:nth-child(3) {
  312. left: 472px;
  313. top: 32px;
  314. a {
  315. background: #12c8b1;
  316. &.active {
  317. font-weight: bold;
  318. background-color: #009b87;
  319. position: relative;
  320. bottom: 2px;
  321. }
  322. &:hover {
  323. font-weight: bold;
  324. position: relative;
  325. bottom: 2px;
  326. background-color: #009b87;
  327. }
  328. }
  329. }
  330. &:nth-child(4) {
  331. left: 612px;
  332. bottom: 22px;
  333. a {
  334. background: #24b8fe;
  335. &.active {
  336. font-weight: bold;
  337. background-color: #0095db;
  338. position: relative;
  339. bottom: 2px;
  340. }
  341. &:hover {
  342. font-weight: bold;
  343. position: relative;
  344. bottom: 2px;
  345. background-color: #0095db;
  346. }
  347. }
  348. }
  349. &:nth-child(5) {
  350. left: 745px;
  351. top: 32px;
  352. a {
  353. background: #008cff;
  354. &.active {
  355. font-weight: bold;
  356. background-color: #026dc5;
  357. position: relative;
  358. bottom: 2px;
  359. }
  360. &:hover {
  361. font-weight: bold;
  362. position: relative;
  363. bottom: 2px;
  364. background-color: #026dc5;
  365. }
  366. }
  367. }
  368. &:nth-child(6) {
  369. left: 958px;
  370. bottom: 22px;
  371. a {
  372. background: #898ef3;
  373. &.active {
  374. font-weight: bold;
  375. background-color: #7479eb;
  376. position: relative;
  377. bottom: 2px;
  378. }
  379. &:hover {
  380. font-weight: bold;
  381. position: relative;
  382. bottom: 2px;
  383. background-color: #7479eb;
  384. }
  385. }
  386. }
  387. }
  388. }
  389. .brand-center-index-list {
  390. .brand-list-nav {
  391. height: 56px;
  392. padding-top: 8px;
  393. position: relative;
  394. &::after{
  395. content: '';
  396. height: 25px;
  397. width: 1px;
  398. position: absolute;
  399. display: block;
  400. border-left: 1px solid #c6c6c6;
  401. top: 21px;
  402. right: 192px;
  403. z-index: 1000;
  404. }
  405. .filter-area {
  406. float: right;
  407. height: 50px;
  408. line-height: 50px;
  409. margin-right: 9px;
  410. position: relative;
  411. input {
  412. height: 32px;
  413. width: 318px;
  414. line-height: 32px;
  415. padding-left: 11px;
  416. border: 1px solid #c6c6c6;
  417. background-color: #fff;
  418. padding-right: 32px;
  419. position: absolute;
  420. right: 150px;
  421. top: 9px;
  422. }
  423. img {
  424. position: absolute;
  425. top: 15px;
  426. right: 154px;
  427. }
  428. span {
  429. margin-left: 47px;
  430. color: #666;
  431. a {
  432. width: 30px;
  433. height: 22px;
  434. display: inline-block;
  435. line-height: 22px;
  436. text-align: center;
  437. border: 1px solid #d2d2d2;
  438. color: #3c7cf5;
  439. margin-left: 9px;
  440. cursor: pointer;
  441. background: #fff;
  442. &.is-border {
  443. color: #999;
  444. cursor: not-allowed;
  445. }
  446. }
  447. }
  448. .similar-list {
  449. position: absolute;
  450. z-index: 1;
  451. right: 150px;
  452. top: 41px;
  453. border: 1px solid #c9c9c9;
  454. text-align: left;
  455. width: 318px;
  456. background: #fff;
  457. /*max-height: 150px;*/
  458. /*overflow-y: auto;*/
  459. li {
  460. padding: 0 11px;
  461. height: 30px;
  462. line-height: 30px;
  463. cursor: pointer;
  464. &:hover {
  465. background: #f7f7f7;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. .brand-list-items {
  472. padding-top: 20px;
  473. background: url('/images/brandCenter/brand-index-bg.png')no-repeat;
  474. background-size: cover;
  475. padding-bottom: 20px;
  476. position: relative;
  477. .search-modal-wrap {
  478. background: rgba(255, 255, 255, 0.3);
  479. position: absolute;
  480. width: 100%;
  481. height: 100%;
  482. z-index: 2;
  483. left: 0;
  484. top: 0;
  485. }
  486. >span {
  487. font-size: 14px;
  488. color: #333;
  489. display: block;
  490. margin-bottom: 20px;
  491. .active-index {
  492. font-size: 16px;
  493. color: #3c7cf5;
  494. }
  495. .active-number {
  496. font-weight: bold;
  497. font-size: 16px;
  498. color: #fc524a;
  499. }
  500. }
  501. .brand-list-item-wrap {
  502. display: inline-block;
  503. width: 297.5px;
  504. margin-bottom: 29px;
  505. position: relative;
  506. height: 30px;
  507. vertical-align: middle;
  508. >a {
  509. display: inline-block;
  510. width: 90px;
  511. >span {
  512. max-width: 270px;
  513. white-space: nowrap;
  514. display: block;
  515. line-height: 20px;
  516. color: #323232;
  517. font-size: 14px;
  518. &:nth-child(2) {
  519. font-size: 12px;
  520. }
  521. }
  522. .brand-intro {
  523. display: none;
  524. z-index: 3;
  525. position: absolute;
  526. width: 177px;
  527. height: 96px;
  528. overflow: hidden;
  529. right: 31px;
  530. top:0;
  531. border-radius: 4px;
  532. background-color: rgb( 102, 102, 102 );
  533. box-shadow: 1.5px 2.598px 7px 0px rgba(0, 0, 0,0.58);
  534. color: #fff;
  535. font-size: 11px;
  536. padding: 13px 15px;
  537. line-height: 18px;
  538. text-align: left;
  539. word-break: break-all;
  540. span {
  541. display: block;
  542. &.brand-application {
  543. overflow: hidden;
  544. text-overflow: ellipsis;
  545. white-space: nowrap;
  546. }
  547. }
  548. &:hover {
  549. span {
  550. text-decoration: underline;
  551. }
  552. }
  553. }
  554. &:hover {
  555. >span {
  556. color: #54c1fa;
  557. font-weight: bold;
  558. }
  559. .brand-intro {
  560. display: block;
  561. }
  562. }
  563. >div {
  564. text-align: center;
  565. }
  566. }
  567. }
  568. >div.empty-remind{
  569. text-align: center;
  570. margin: 20px 0;
  571. }
  572. }
  573. .page-wrap {
  574. text-align: right;
  575. margin: 0 0 20px 0;
  576. float: none;
  577. }
  578. }
  579. }
  580. </style>