|
|
@@ -1,94 +1,71 @@
|
|
|
<template>
|
|
|
- <div class="mobile-brand-center mobile-content">
|
|
|
- <div class="mobile-brand-wrap">
|
|
|
- <div class="mobile-brand-header">
|
|
|
- <img src="/images/mobile/@2x/brand/brandWall.png" alt="">
|
|
|
- <div class="mobile-brand-index" :class="{'scrolled': isScrolled, 'is-more': isScrolled && !isMore}">
|
|
|
- <p style="float: left">索引:</p>
|
|
|
- <div style="float: left;width: 5.5rem">
|
|
|
- <nuxt-link :to="'/mobile/brand/brandCenter/' + item"
|
|
|
- :class="{'active': item == activeIndex}"
|
|
|
- :key="key" v-for="(item, key) in initArr">{{item}}</nuxt-link>
|
|
|
+ <div>
|
|
|
+ <search-header @searchAction="onSearch" :placeholder="'请输入品牌名称'" :showSimilar="false"></search-header>
|
|
|
+ <div class="mobile-brand-center mobile-content">
|
|
|
+ <div class="mobile-brand-wrap">
|
|
|
+ <div class="mobile-brand-header">
|
|
|
+ <img src="/images/mobile/@2x/brand/brandWall.png" alt="">
|
|
|
+ <div class="mobile-brand-index" :class="{'scrolled': isScrolled, 'is-more': isScrolled && !isMore}">
|
|
|
+ <p style="float: left">索引:</p>
|
|
|
+ <div style="float: left;width: 5.5rem">
|
|
|
+ <nuxt-link :to="'/mobile/brand/brandCenter/' + item"
|
|
|
+ :class="{'active': item == activeIndex}"
|
|
|
+ :key="key" v-for="(item, key) in initArr">{{item}}</nuxt-link>
|
|
|
+ </div>
|
|
|
+ <div v-if="isScrolled" class="more-index" @click="isMore = !isMore">
|
|
|
+ {{!isMore ? '更多' : '收起'}}
|
|
|
+ <img v-if="!isMore" src="/images/mobile/@2x/applyPurchase/currency-arrow-down.png" alt="">
|
|
|
+ <img src="/images/mobile/@2x/applyPurchase/currency-arrow-up.png" v-else alt="">
|
|
|
+ </div>
|
|
|
+ <div class="clear-float"></div>
|
|
|
</div>
|
|
|
- <div v-if="isScrolled" class="more-index" @click="isMore = !isMore">
|
|
|
- {{!isMore ? '更多' : '收起'}}
|
|
|
- <img v-if="!isMore" src="/images/mobile/@2x/applyPurchase/currency-arrow-down.png" alt="">
|
|
|
- <img src="/images/mobile/@2x/applyPurchase/currency-arrow-up.png" v-else alt="">
|
|
|
- </div>
|
|
|
- <div class="clear-float"></div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <div class="mobile-brand-list">
|
|
|
- <div v-for="(brands, initial) in brandList">
|
|
|
- <div class="brand-initial">
|
|
|
- <p v-text="initial" :style="initial === '0~9' ? 'font-size: .28rem': 'font-size: .32rem'"></p>
|
|
|
- <span>
|
|
|
- {{initial}}开头共<span>{{brands.length || 0}}</span>个品牌
|
|
|
+ <div class="mobile-brand-list">
|
|
|
+ <div>
|
|
|
+ <div class="brand-initial">
|
|
|
+ <p v-text="activeIndex" :style="activeIndex === '0~9' ? 'font-size: .28rem': 'font-size: .32rem'"></p>
|
|
|
+ <span>
|
|
|
+ {{activeIndex}}开头共<span>{{brandList.totalElements || 0}}</span>个品牌
|
|
|
</span>
|
|
|
- </div>
|
|
|
- <div class="brand-items">
|
|
|
- <nuxt-link :to="`/mobile/brand/${brand.uuid}/`" :key="key" v-for="(brand, key) in brands">
|
|
|
- <div>{{brand.nameEn}}</div>
|
|
|
- <div v-if="brand.nameCn != brand.nameEn">{{brand.nameCn}}</div>
|
|
|
- </nuxt-link>
|
|
|
+ </div>
|
|
|
+ <div class="brand-items">
|
|
|
+ <nuxt-link :to="`/mobile/brand/${brand.uuid}/`" :key="brand.uuid" v-for="brand in brandListTemplate">
|
|
|
+ <div>{{brand.nameEn}}</div>
|
|
|
+ <div v-if="brand.nameCn != brand.nameEn">{{brand.nameCn}}</div>
|
|
|
+ </nuxt-link>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <pull-up :searchMore="fetching" :allPage="allPage" :page="pageParams.page" @pullUpAction="onPullUpAction"></pull-up>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
- function sortList (letter) {
|
|
|
- return function (a, b) {
|
|
|
- var value1 = a[letter]
|
|
|
- var value2 = b[letter]
|
|
|
- if (value1 > value2) {
|
|
|
- return 1
|
|
|
- } else if (value1 < value2) {
|
|
|
- return -1
|
|
|
- } else {
|
|
|
- return 0
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ import {SearchHeader} from '~components/mobile/base'
|
|
|
+ import { PullUp } from '~components/mobile/common'
|
|
|
+ import { startWith } from '~utils/baseUtils'
|
|
|
export default {
|
|
|
name: 'brandList',
|
|
|
data () {
|
|
|
return {
|
|
|
- initArr: [
|
|
|
- 'A',
|
|
|
- 'B',
|
|
|
- 'C',
|
|
|
- 'D',
|
|
|
- 'E',
|
|
|
- 'F',
|
|
|
- 'G',
|
|
|
- 'H',
|
|
|
- 'I',
|
|
|
- 'J',
|
|
|
- 'K',
|
|
|
- 'L',
|
|
|
- 'M',
|
|
|
- 'N',
|
|
|
- 'O',
|
|
|
- 'P',
|
|
|
- 'Q',
|
|
|
- 'R',
|
|
|
- 'S',
|
|
|
- 'T',
|
|
|
- 'U',
|
|
|
- 'V',
|
|
|
- 'W',
|
|
|
- 'X',
|
|
|
- 'Y',
|
|
|
- 'Z',
|
|
|
- '0~9'
|
|
|
- ],
|
|
|
+ initArr: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0~9'],
|
|
|
activeIndex: this.$route.params.initial,
|
|
|
isScrolled: false,
|
|
|
- isMore: false
|
|
|
+ isMore: false,
|
|
|
+ pageParams: {
|
|
|
+ page: 1,
|
|
|
+ count: 60,
|
|
|
+ keyword: ''
|
|
|
+ },
|
|
|
+ isChange: false,
|
|
|
+ brandListTemplate: []
|
|
|
}
|
|
|
},
|
|
|
+ components: {
|
|
|
+ SearchHeader,
|
|
|
+ PullUp
|
|
|
+ },
|
|
|
mounted: function () {
|
|
|
let _this = this
|
|
|
_this.$nextTick(function () {
|
|
|
@@ -98,40 +75,52 @@
|
|
|
})
|
|
|
},
|
|
|
watch: {
|
|
|
- $route: function (val, oldVal) {
|
|
|
- this.activeIndex = val.params.initial
|
|
|
+ 'brandData.data': {
|
|
|
+ handler: function (val) {
|
|
|
+ let list = [...val.content]
|
|
|
+ if (this.isChange) {
|
|
|
+ this.brandListTemplate = list
|
|
|
+ this.isChange = false
|
|
|
+ } else {
|
|
|
+ this.brandListTemplate = [...this.brandListTemplate, ...list]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
+ brandData () {
|
|
|
+ return this.$store.state.product.brand.brandPagerList
|
|
|
+ },
|
|
|
brandList () {
|
|
|
- let brandsList = JSON.parse(JSON.stringify(this.$store.state.product.brand.brandList.data))
|
|
|
- if (brandsList) {
|
|
|
- for (let i in brandsList) {
|
|
|
- brandsList[i] = brandsList[i].sort(sortList('nameEn'))
|
|
|
- }
|
|
|
- }
|
|
|
- let temp = {}
|
|
|
- let keys = []
|
|
|
- for (let key in brandsList) {
|
|
|
- keys.push(key)
|
|
|
- }
|
|
|
- keys = keys.sort()
|
|
|
- for (let i = 0; i < keys.length; i++) {
|
|
|
- temp[keys[i]] = brandsList[keys[i]]
|
|
|
- }
|
|
|
- return temp
|
|
|
+ return this.brandData.data
|
|
|
+ },
|
|
|
+ allPage () {
|
|
|
+ return this.brandList.totalPages
|
|
|
+ },
|
|
|
+ fetching () {
|
|
|
+ return this.brandData.fetching
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
onScroll () {
|
|
|
- if (this.startWith(this.$route.path, '/mobile/brand/brandCenter')) {
|
|
|
+ if (startWith(this.$route.path, '/mobile/brand/brandCenter')) {
|
|
|
let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
|
|
|
this.isScrolled = scrolled > 0
|
|
|
}
|
|
|
},
|
|
|
- startWith: function (str, s) {
|
|
|
- let reg = new RegExp('^' + s)
|
|
|
- return reg.test(str)
|
|
|
+ reloadData: function () {
|
|
|
+ this.$store.dispatch('product/loadBrandsPager', {'initial': this.activeIndex, page: this.pageParams.page, count: this.pageParams.count, keyword: this.pageParams.keyword})
|
|
|
+ },
|
|
|
+ onSearch: function (keyObj) {
|
|
|
+ this.pageParams.keyword = keyObj.keyword
|
|
|
+ this.pageParams.page = 1
|
|
|
+ this.isChange = true
|
|
|
+ this.reloadData()
|
|
|
+ },
|
|
|
+ onPullUpAction: function () {
|
|
|
+ this.pageParams.page++
|
|
|
+ this.reloadData()
|
|
|
}
|
|
|
}
|
|
|
}
|