BrandIndex.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. }
  256. }
  257. }
  258. &:nth-child(2) {
  259. left: 322px;
  260. bottom: 22px;
  261. a {
  262. background: #fdad33;
  263. &.active {
  264. font-weight: bold;
  265. background-color: #ea8f02;
  266. position: relative;
  267. bottom: 2px;
  268. }
  269. &:hover {
  270. font-weight: bold;
  271. position: relative;
  272. bottom: 2px;
  273. }
  274. }
  275. }
  276. &:nth-child(3) {
  277. left: 472px;
  278. top: 32px;
  279. a {
  280. background: #12c8b1;
  281. &.active {
  282. font-weight: bold;
  283. background-color: #009b87;
  284. position: relative;
  285. bottom: 2px;
  286. }
  287. &:hover {
  288. font-weight: bold;
  289. position: relative;
  290. bottom: 2px;
  291. }
  292. }
  293. }
  294. &:nth-child(4) {
  295. left: 612px;
  296. bottom: 22px;
  297. a {
  298. background: #24b8fe;
  299. &.active {
  300. font-weight: bold;
  301. background-color: #0095db;
  302. position: relative;
  303. bottom: 2px;
  304. }
  305. &:hover {
  306. font-weight: bold;
  307. position: relative;
  308. bottom: 2px;
  309. }
  310. }
  311. }
  312. &:nth-child(5) {
  313. left: 745px;
  314. top: 32px;
  315. a {
  316. background: #008cff;
  317. &.active {
  318. font-weight: bold;
  319. background-color: #026dc5;
  320. position: relative;
  321. bottom: 2px;
  322. }
  323. &:hover {
  324. font-weight: bold;
  325. position: relative;
  326. bottom: 2px;
  327. }
  328. }
  329. }
  330. &:nth-child(6) {
  331. left: 958px;
  332. bottom: 22px;
  333. a {
  334. background: #898ef3;
  335. &.active {
  336. font-weight: bold;
  337. background-color: #7479eb;
  338. position: relative;
  339. bottom: 2px;
  340. }
  341. &:hover {
  342. font-weight: bold;
  343. position: relative;
  344. bottom: 2px;
  345. }
  346. }
  347. }
  348. }
  349. }
  350. .brand-center-index-list {
  351. .brand-list-nav {
  352. height: 56px;
  353. padding-top: 15px;
  354. .filter-area {
  355. float: right;
  356. height: 50px;
  357. line-height: 50px;
  358. margin-right: 9px;
  359. position: relative;
  360. input {
  361. height: 32px;
  362. width: 318px;
  363. line-height: 32px;
  364. padding-left: 11px;
  365. border: 1px solid #c6c6c6;
  366. background-color: #fff;
  367. padding-right: 32px;
  368. position: absolute;
  369. right: 150px;
  370. top: 9px;
  371. }
  372. img {
  373. position: absolute;
  374. top: 15px;
  375. right: 154px;
  376. }
  377. span {
  378. margin-left: 47px;
  379. color: #666;
  380. a {
  381. width: 30px;
  382. height: 22px;
  383. display: inline-block;
  384. line-height: 22px;
  385. text-align: center;
  386. border: 1px solid #d2d2d2;
  387. color: #3c7cf5;
  388. margin-left: 9px;
  389. cursor: pointer;
  390. background: #fff;
  391. &.is-border {
  392. color: #999;
  393. cursor: not-allowed;
  394. }
  395. }
  396. }
  397. }
  398. }
  399. .brand-list-items {
  400. padding-top: 20px;
  401. background: url('/images/brandCenter/brand-index-bg.png')no-repeat;
  402. background-size: cover;
  403. padding-bottom: 20px;
  404. position: relative;
  405. .search-modal-wrap {
  406. background: rgba(255, 255, 255, 0.3);
  407. position: absolute;
  408. width: 100%;
  409. height: 100%;
  410. z-index: 2;
  411. left: 0;
  412. top: 0;
  413. }
  414. >span {
  415. font-size: 14px;
  416. color: #333;
  417. display: block;
  418. margin-bottom: 20px;
  419. .active-index {
  420. font-size: 16px;
  421. color: #3c7cf5;
  422. }
  423. .active-number {
  424. font-weight: bold;
  425. font-size: 16px;
  426. color: #fc524a;
  427. }
  428. }
  429. .brand-list-item-wrap {
  430. display: inline-block;
  431. width: 297.5px;
  432. margin-bottom: 29px;
  433. position: relative;
  434. height: 30px;
  435. vertical-align: middle;
  436. >a {
  437. display: inline-block;
  438. width: 90px;
  439. >span {
  440. max-width: 270px;
  441. white-space: nowrap;
  442. display: block;
  443. line-height: 20px;
  444. color: #323232;
  445. font-size: 14px;
  446. &:nth-child(2) {
  447. font-size: 12px;
  448. }
  449. }
  450. .brand-intro {
  451. display: none;
  452. z-index: 3;
  453. position: absolute;
  454. width: 177px;
  455. height: 96px;
  456. overflow: hidden;
  457. right: 31px;
  458. top:0;
  459. border-radius: 4px;
  460. background-color: rgb( 102, 102, 102 );
  461. box-shadow: 1.5px 2.598px 7px 0px rgba(0, 0, 0,0.58);
  462. color: #fff;
  463. font-size: 11px;
  464. padding: 13px 15px;
  465. line-height: 18px;
  466. text-align: left;
  467. word-break: break-all;
  468. span {
  469. display: block;
  470. &.brand-application {
  471. overflow: hidden;
  472. text-overflow: ellipsis;
  473. white-space: nowrap;
  474. }
  475. }
  476. &:hover {
  477. span {
  478. text-decoration: underline;
  479. }
  480. }
  481. }
  482. &:hover {
  483. >span {
  484. color: #54c1fa;
  485. font-weight: bold;
  486. }
  487. .brand-intro {
  488. display: block;
  489. }
  490. }
  491. >div {
  492. text-align: center;
  493. }
  494. }
  495. }
  496. >div.empty-remind{
  497. text-align: center;
  498. margin: 20px 0;
  499. }
  500. }
  501. .page-wrap {
  502. text-align: right;
  503. margin: 0 0 20px 0;
  504. float: none;
  505. }
  506. }
  507. }
  508. </style>