BrandIndex.vue 21 KB

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