brand-product-list.vue
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<template>
<layout-app title="商品列表" class="brand-product-list">
<div class="scroll-view" ref="scroll">
<div class="list-wrapper" v-if="brandProductList != null">
<product-list :list="brandProductList" priceKey="price"/>
</div>
</div>
</layout-app>
</template>
<script>
import { createNamespacedHelpers } from 'vuex';
import ScrollView from 'components/layout/scroll-view';
import ProductList from '../list/components/productList';
const STORE_PATH = 'product';
const { mapActions, mapState } = createNamespacedHelpers(STORE_PATH);
export default {
name: 'BrandProductList',
props: ['productId'],
components: {
ProductList,
ScrollView,
},
data() {
return {
inLoading: false,
scrollOption: {
pullDownRefresh: {
threshold: 70,
stop: 90,
txt: '更新成功'
},
observeDOM: false,
pullUpLoad: false,
},
};
},
computed: {
...mapState(['topLists']),
brandProductList() {
return this.topLists[this.$route.params.productId];
},
},
asyncData({store, router}) {
return store.dispatch(`${STORE_PATH}/fetchBrandTop`, {productId: router.params.productId});
},
activated() {
if (this.$refs.scroll) {
this.$refs.scroll.scrollTop = 0;
}
},
methods: {
...mapActions(['fetchBrandTop']),
onPullingDown() {
this.fetchBrandTop({productId: this.productId});
},
},
};
</script>
<style lang="scss" scoped>
.brand-product-list .scroll-view {
background: #f5f5f5;
height: 100%;
overflow: auto;
-webkit-overflow-scrolling: touch;
}
</style>