BrandIndex.vue 15 KB

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