BrandIndex.vue 15 KB

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