BrandIndex.vue 23 KB

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