BrandIndex.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  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.params.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.params.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('/product/brand/brandList/A')
  242. }
  243. },
  244. goBrandIndex: function (index) {
  245. if (index === this.$route.params.initial) {
  246. this.initParams()
  247. this.reloadData()
  248. } else {
  249. this.$router.push('/product/brand/brandList/' + 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. margin-top: 20px;
  275. width: 1190px;
  276. overflow: hidden;
  277. .brand-recommend {
  278. float: left;
  279. margin-right: 15px;
  280. .recommend-area {
  281. width: 220px;
  282. height: 862px;
  283. background-color: #ffffff;
  284. border-radius: 5px;
  285. /*border: solid 1px #d2d2d2;*/
  286. }
  287. .recommend-head {
  288. padding-left: 10px;
  289. width: 220px;
  290. height: 34px;
  291. line-height: 34px;
  292. background-color: #2496f1;
  293. font-size: 14px;
  294. font-weight: bold;
  295. border-top-left-radius: 5px;
  296. border-top-right-radius: 5px;
  297. color: #fff;
  298. img{
  299. margin-right: 6px;
  300. margin-top: -2px;
  301. }
  302. }
  303. .recommend-items{
  304. li {
  305. padding: 0px 0 11px 13px;
  306. overflow: hidden;
  307. height: 82px;
  308. border-bottom: solid 1px #e5e5e5;
  309. img{
  310. float: left;
  311. margin: 10px 10px 0 0;
  312. width: 60px;
  313. height: 60px;
  314. background-color: #ffffff;
  315. border-radius: 4px;
  316. border: solid 1px #e5e5e5;
  317. }
  318. div.brand-item{
  319. float: left;
  320. margin-top: 6px;
  321. width: 128px;
  322. p{
  323. margin-bottom: 6px;
  324. font-size: 12px;
  325. color: #666666;
  326. width: 128px;
  327. overflow: hidden;
  328. white-space: nowrap;
  329. text-overflow: ellipsis;
  330. }
  331. span {
  332. display: inline-block;
  333. width: 128px;
  334. font-size: 12px;
  335. color: #666;
  336. overflow: hidden;
  337. }
  338. span.brand-application{
  339. white-space: nowrap;
  340. text-overflow: ellipsis;
  341. }
  342. span.brand-introduce {
  343. display: -webkit-box;
  344. -webkit-line-clamp: 2;
  345. -webkit-box-orient: vertical;
  346. }
  347. &:hover p{
  348. color: #2496f1;
  349. }
  350. &:hover span{
  351. color: #2496f1;
  352. }
  353. }
  354. &:last-child {
  355. padding-top: 5px;
  356. border-bottom: none;
  357. }
  358. }
  359. }
  360. .recommend-prod {
  361. padding: 20px 0 0px 10px;
  362. margin-top: 20px;
  363. width: 220px;
  364. height: 229px;
  365. border-radius: 5px;
  366. background: #fff;
  367. margin-bottom: 120px;
  368. /*border: solid 1px rgba(210, 210, 210, 0.8);*/
  369. .item {
  370. overflow: hidden;
  371. margin-bottom: 22px;
  372. img{
  373. margin-right: 10px;
  374. float: left;
  375. width: 39px;
  376. height: 39px;
  377. }
  378. span {
  379. float: left;
  380. display: inline-block;
  381. width: 155px;
  382. word-break: break-all;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. .brand-center-index {
  389. float: left;
  390. width: 955px;
  391. margin: 0 auto;
  392. >img {
  393. /*height: 50px;*/
  394. &:last-child{
  395. height: 70px;
  396. margin-bottom: 40px;
  397. }
  398. }
  399. .brand-index-tab {
  400. margin-top: 7px;
  401. position: relative;
  402. width: 955px;
  403. height: 34px;
  404. border-radius: 5px;
  405. background: #fff;
  406. border: solid 1px #e5e5e5;
  407. .brand-index-group {
  408. float: left;
  409. height: 34px;
  410. text-align: center;
  411. a {
  412. width: 32px;
  413. height: 32px;
  414. text-align: center;
  415. display: inline-block;
  416. color: #666;
  417. line-height: 32px;
  418. font-size: 14px;
  419. vertical-align: middle;
  420. &:hover{
  421. background-color: #2496f1;
  422. border-radius: 5px;
  423. color: #fff;
  424. }
  425. }
  426. a.active{
  427. background-color: #2496f1;
  428. border-radius: 5px;
  429. color: #fff;
  430. }
  431. &:last-child{
  432. margin-left: 55px;
  433. }
  434. &:last-child a{
  435. letter-spacing: 12px;
  436. }
  437. &:last-child a:hover{
  438. width: 56px;
  439. padding-left: 3px;
  440. }
  441. &:last-child a.active{
  442. width: 56px;
  443. padding-left: 3px;
  444. }
  445. }
  446. }
  447. .brand-center-index-list {
  448. .brand-list-nav {
  449. width: 955px;
  450. height: 34px;
  451. line-height: 34px;
  452. position: relative;
  453. /*overflow: hidden;*/
  454. background: #fff;
  455. border-bottom: solid 1px #e5e5e5;
  456. span.search-index-show {
  457. float: left;
  458. display: inline-block;
  459. width: 98px;
  460. height: 34px;
  461. line-height: 34px;
  462. text-align: center;
  463. background-color: #2496f1;
  464. font-size: 14px;
  465. color: #fdfbfb;
  466. border-radius: 3px 3px 0px 0px;
  467. }
  468. span {
  469. font-size: 14px;
  470. color: #333;
  471. /*margin-bottom: 20px;*/
  472. .active-index {
  473. font-size: 16px;
  474. color: #3c7cf5;
  475. display: inline-block;
  476. max-width: 100px;
  477. overflow: hidden;
  478. text-overflow: ellipsis;
  479. white-space: nowrap;
  480. vertical-align: middle;
  481. }
  482. .active-number {
  483. font-weight: bold;
  484. font-size: 16px;
  485. color: #fc524a;
  486. }
  487. }
  488. div.search{
  489. float: left;
  490. margin-left: 10px;
  491. }
  492. .filter-area {
  493. float: right;
  494. /*height: 50px;*/
  495. /*line-height: 50px;*/
  496. margin-right: 9px;
  497. position: relative;
  498. input {
  499. height: 32px;
  500. width: 258px;
  501. line-height: 32px;
  502. padding-left: 11px;
  503. background-color: #ffffff;
  504. border-radius: 3px;
  505. border: solid 1px #2496f1;
  506. padding-right: 32px;
  507. position: absolute;
  508. right: 150px;
  509. top: 0px;
  510. }
  511. b.search-btn {
  512. position: absolute;
  513. top: 0px;
  514. right: 150px;
  515. width: 69px;
  516. height: 32px;
  517. line-height: 32px;
  518. text-align: center;
  519. font-size: 14px;
  520. color: #fff;
  521. background-color: #2496f1;
  522. border-top-right-radius: 5px;
  523. border-bottom-right-radius: 5px;
  524. }
  525. span {
  526. height: 28px;
  527. line-height: 28px;
  528. float:left;
  529. margin-left: 47px;
  530. color: #666;
  531. margin-top: 5px;
  532. a {
  533. width: 30px;
  534. height: 22px;
  535. display: inline-block;
  536. line-height: 22px;
  537. text-align: center;
  538. border: 1px solid #d2d2d2;
  539. color: #3c7cf5;
  540. margin-left: 9px;
  541. cursor: pointer;
  542. background: #fff;
  543. &.is-border {
  544. color: #999;
  545. cursor: not-allowed;
  546. }
  547. }
  548. }
  549. .similar-list {
  550. position: absolute;
  551. z-index: 1;
  552. right: 150px;
  553. top: 29px;
  554. border: 1px solid #c9c9c9;
  555. text-align: left;
  556. width: 258px;
  557. background: #fff;
  558. li {
  559. padding: 0 11px;
  560. height: 30px;
  561. line-height: 30px;
  562. cursor: pointer;
  563. &:hover {
  564. background: #f7f7f7;
  565. }
  566. }
  567. }
  568. }
  569. }
  570. .brand-list-items {
  571. padding-top: 20px;
  572. padding-left: 20px;
  573. background-size: cover;
  574. padding-bottom: 20px;
  575. position: relative;
  576. height: 1037px;
  577. background: #fff;
  578. /*border-bottom: 1px solid #dcdcdc;*/
  579. border-bottom-left-radius: 5px;
  580. border-bottom-right-radius: 5px;
  581. .search-modal-wrap {
  582. background: rgba(255, 255, 255, 0.3);
  583. position: absolute;
  584. width: 100%;
  585. height: 100%;
  586. z-index: 2;
  587. left: 0;
  588. top: 0;
  589. }
  590. >span {
  591. font-size: 14px;
  592. color: #333;
  593. display: block;
  594. margin-bottom: 20px;
  595. .active-index {
  596. font-size: 16px;
  597. color: #3c7cf5;
  598. }
  599. .active-number {
  600. font-weight: bold;
  601. font-size: 16px;
  602. color: #fc524a;
  603. }
  604. }
  605. .brand-list-item-wrap {
  606. display: inline-block;
  607. width: 25%;
  608. margin-bottom: 29px;
  609. position: relative;
  610. height: 30px;
  611. vertical-align: middle;
  612. >a {
  613. display: inline-block;
  614. width: 90px;
  615. >span {
  616. max-width: 270px;
  617. white-space: nowrap;
  618. display: block;
  619. line-height: 20px;
  620. color: #323232;
  621. font-size: 14px;
  622. overflow: hidden;
  623. text-overflow: ellipsis;
  624. &:nth-child(2) {
  625. font-size: 12px;
  626. }
  627. }
  628. .brand-intro {
  629. display: none;
  630. z-index: 3;
  631. position: absolute;
  632. width: 177px;
  633. height: 96px;
  634. overflow: hidden;
  635. right: 31px;
  636. top:0;
  637. border-radius: 4px;
  638. color: #fff;
  639. font-size: 11px;
  640. padding: 13px 15px;
  641. line-height: 18px;
  642. text-align: left;
  643. word-break: break-all;
  644. background-color: #ffffff;
  645. box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.19);
  646. span {
  647. display: block;
  648. font-size: 12px;
  649. color: #333;
  650. &.brand-application {
  651. overflow: hidden;
  652. text-overflow: ellipsis;
  653. white-space: nowrap;
  654. }
  655. }
  656. &:hover {
  657. span {
  658. text-decoration: underline;
  659. }
  660. }
  661. }
  662. &:hover {
  663. >span {
  664. color: #54c1fa;
  665. font-weight: bold;
  666. }
  667. .brand-intro {
  668. display: block;
  669. }
  670. }
  671. >div {
  672. text-align: center;
  673. }
  674. }
  675. }
  676. >div.empty-remind{
  677. text-align: center;
  678. margin: 20px 0;
  679. margin-top: 495px;
  680. font-size: 20px;
  681. }
  682. }
  683. .page-wrap {
  684. text-align: right;
  685. margin: 30px 0 115px 0;
  686. float: none;
  687. .el-pagination .el-pager li.active{
  688. border-color: #20a0ff;
  689. background-color: #20a0ff;
  690. color: #fff;
  691. cursor: default;
  692. }
  693. .page-a{
  694. background-color: #2496f1!important ;
  695. }
  696. }
  697. }
  698. }
  699. </style>