|
|
@@ -6,8 +6,8 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="brand-switch-item">
|
|
|
- <span :class="activeType=='detail'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='detail'">品牌</span>
|
|
|
- <span :class="activeType=='product'?'mobile-switch-btn active':'mobile-switch-btn'" @click="activeType='product'">产品</span>
|
|
|
+ <span :class="activeType=='detail'?'mobile-switch-btn active':'mobile-switch-btn'" @click="setActiveType('detail')">品牌</span>
|
|
|
+ <span :class="activeType=='product'?'mobile-switch-btn active':'mobile-switch-btn'" @click="setActiveType('product')">产品</span>
|
|
|
</div>
|
|
|
<div class="brand-param-list" v-if="activeType=='detail'">
|
|
|
<div class="brand-param-item" v-if="brandDetail.series">
|
|
|
@@ -34,7 +34,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="brand-product-list" v-if="activeType=='product'">
|
|
|
- <div class="search-box" v-if="productList.content && productList.content.length > 0 || isSearch">
|
|
|
+ <div class="search-box" v-if="searchLists && searchLists.length > 0 || isSearch">
|
|
|
<div class="kind-selecter">
|
|
|
<div @mouseenter="isInList = true" @mouseleave="isInList = false">
|
|
|
<span @click="showKindList = !showKindList" v-text="selectedKind.substring(0, 4)"></span>
|
|
|
@@ -50,12 +50,12 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<ul class="product-list">
|
|
|
- <li v-for="product in productList.content">
|
|
|
+ <li v-for="product in searchLists">
|
|
|
<nuxt-link class="text-left" :to="'/mobile/brand/componentDetail/' + product.uuid">{{product.code}}</nuxt-link>
|
|
|
<a class="text-right" @click="toShowPdf(product.attach)">规格书 <i class="icon-chakan iconfont"></i></a>
|
|
|
</li>
|
|
|
</ul>
|
|
|
- <div class="no-product" v-if="!productList.content || productList.content.length == 0">
|
|
|
+ <div class="no-product" v-if="!productList.totalPages || productList.totalPages == 0">
|
|
|
<img :src="!isSearch?'/images/mobile/@2x/car@2x.png':'/images/mobile/@2x/search-empty.png'" alt="">
|
|
|
<div>抱歉,暂无产品信息</div>
|
|
|
</div>
|
|
|
@@ -80,7 +80,9 @@
|
|
|
},
|
|
|
selectedKind: '全部分类',
|
|
|
isInList: false,
|
|
|
- isSearch: false
|
|
|
+ isSearch: false,
|
|
|
+ isSearchingMore: false,
|
|
|
+ searchLists: []
|
|
|
}
|
|
|
},
|
|
|
filters: {
|
|
|
@@ -89,24 +91,17 @@
|
|
|
}
|
|
|
},
|
|
|
mounted: function () {
|
|
|
- this.$nextTick(function () {
|
|
|
- document.addEventListener('click', this.checkShowFilter)
|
|
|
+ let _this = this
|
|
|
+ _this.$nextTick(function () {
|
|
|
+ window.addEventListener('scroll', function () {
|
|
|
+ _this.scroll()
|
|
|
+ }, false)
|
|
|
+ document.addEventListener('click', _this.checkShowFilter)
|
|
|
})
|
|
|
},
|
|
|
watch: {
|
|
|
keyword: function (val, oldVal) {
|
|
|
this.isSearch = true
|
|
|
- },
|
|
|
- activeType: function (val, oldVal) {
|
|
|
- if (val === 'product') {
|
|
|
- this.pageParams = {
|
|
|
- page: 1,
|
|
|
- count: 10,
|
|
|
- filter: {}
|
|
|
- }
|
|
|
- this.keyword = ''
|
|
|
- this.pageCommodity(this.pageParams)
|
|
|
- }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -115,10 +110,18 @@
|
|
|
if (list.application && list.application !== '') {
|
|
|
this.applications = list.application.split(',')
|
|
|
}
|
|
|
+ this.pageParams.filter.brandid = list.id
|
|
|
return list
|
|
|
},
|
|
|
productList () {
|
|
|
- return this.$store.state.brandComponent.component.data || []
|
|
|
+ console.log(this.pageParams)
|
|
|
+ let list = this.$store.state.brandComponent.component.data
|
|
|
+ this.searchLists = this.searchLists.concat(list.content)
|
|
|
+ this.isSearchingMore = false
|
|
|
+ return list
|
|
|
+ },
|
|
|
+ allPage () {
|
|
|
+ return this.productList.totalPages || 0
|
|
|
},
|
|
|
kindList () {
|
|
|
let brands = this.$store.state.brandCategories.categories.data
|
|
|
@@ -186,6 +189,19 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ scroll: function () {
|
|
|
+ let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
|
|
|
+ if (Math.ceil(scrolled + window.screen.availHeight) >= document.body.scrollHeight && !this.isSearchingMore && this.pageParams.page < this.allPage && this.activeType === 'product') {
|
|
|
+ this.getMoreProduct()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getMoreProduct: function () {
|
|
|
+ if (!this.isSearchingMore) {
|
|
|
+ this.pageParams.page++
|
|
|
+ this.isSearchingMore = true
|
|
|
+ this.pageCommodity(this.pageParams, this.ids)
|
|
|
+ }
|
|
|
+ },
|
|
|
getKinds: function (list, kindList) {
|
|
|
if (list.children && list.children.length > 0) {
|
|
|
for (let i = 0; i < list.children.length; i++) {
|
|
|
@@ -221,13 +237,14 @@
|
|
|
this.pageParams.filter.code = this.keyword
|
|
|
this.pageCommodity(this.pageParams)
|
|
|
},
|
|
|
- async pageCommodity (params) {
|
|
|
- try {
|
|
|
- let { data } = await this.$http.get('/api/product/component/list', { params })
|
|
|
- this.$store.commit('brandComponent/GET_COMPONENT_SUCCESS', data)
|
|
|
- } catch (err) {
|
|
|
- this.$store.commit('brandComponent/GET_COMPONENT_FAILURE', err)
|
|
|
- }
|
|
|
+ pageCommodity (params) {
|
|
|
+// try {
|
|
|
+// let { data } = await this.$http.get('/api/product/component/list', { params })
|
|
|
+// this.$store.commit('brandComponent/GET_COMPONENT_SUCCESS', data)
|
|
|
+// } catch (err) {
|
|
|
+// this.$store.commit('brandComponent/GET_COMPONENT_FAILURE', err)
|
|
|
+// }
|
|
|
+ this.$store.dispatch('loadBrandComponent', this.pageParams)
|
|
|
},
|
|
|
checkShowFilter: function () {
|
|
|
if (!this.isInList) {
|
|
|
@@ -238,6 +255,17 @@
|
|
|
if (url && url !== '1') {
|
|
|
window.location.href = url
|
|
|
}
|
|
|
+ },
|
|
|
+ setActiveType: function (type) {
|
|
|
+ if (type === 'product' && (this.pageParams.page !== 1 || this.keyword !== '')) {
|
|
|
+ this.pageParams.page = 1
|
|
|
+// this.keyword = ''
|
|
|
+ this.searchLists = []
|
|
|
+ console.log(this.pageParams)
|
|
|
+ this.$store.dispatch('loadBrandComponent', this.pageParams)
|
|
|
+// this.pageCommodity(this.pageParams)
|
|
|
+ }
|
|
|
+ this.activeType = type
|
|
|
}
|
|
|
}
|
|
|
}
|