Showing
8 changed files
with
88 additions
and
25 deletions
apps/pages/product/brand-product-list.vue
0 → 100644
1 | +<template> | ||
2 | + <layout-app title="商品列表" class="brand-product-list"> | ||
3 | + <scroll-view | ||
4 | + ref="scroll" | ||
5 | + :data="brandProductList" | ||
6 | + :options="scrollOption" | ||
7 | + @pulling-down="onPullingDown"> | ||
8 | + <div class="list-wrapper" v-if="brandProductList != null"> | ||
9 | + <product-list :list="brandProductList" /> | ||
10 | + </div> | ||
11 | + </scroll-view> | ||
12 | + </layout-app> | ||
13 | +</template> | ||
14 | + | ||
15 | +<script> | ||
16 | +import { createNamespacedHelpers } from 'vuex'; | ||
17 | +import ScrollView from 'components/layout/scroll-view'; | ||
18 | +import ProductList from '../list/components/productList'; | ||
19 | + | ||
20 | +const STORE_PATH = 'product'; | ||
21 | +const { mapActions, mapState } = createNamespacedHelpers(STORE_PATH); | ||
22 | + | ||
23 | +export default { | ||
24 | + name: 'BrandProductList', | ||
25 | + props: ['productId'], | ||
26 | + components: { | ||
27 | + ProductList, | ||
28 | + ScrollView, | ||
29 | + }, | ||
30 | + data() { | ||
31 | + return { | ||
32 | + inLoading: false, | ||
33 | + scrollOption: { | ||
34 | + pullDownRefresh: { | ||
35 | + threshold: 70, | ||
36 | + stop: 90 | ||
37 | + }, | ||
38 | + observeDOM: false, | ||
39 | + pullUpLoad: false, | ||
40 | + }, | ||
41 | + }; | ||
42 | + }, | ||
43 | + computed: { | ||
44 | + ...mapState(['topLists']), | ||
45 | + brandProductList() { | ||
46 | + return this.topLists[this.$route.params.productId]; | ||
47 | + }, | ||
48 | + }, | ||
49 | + asyncData({store, router}) { | ||
50 | + return store.dispatch(`${STORE_PATH}/fetchBrandTop`, {productId: router.params.productId}); | ||
51 | + }, | ||
52 | + methods: { | ||
53 | + ...mapActions(['fetchBrandTop']), | ||
54 | + onPullingDown() { | ||
55 | + this.fetchBrandTop({productId: this.productId}); | ||
56 | + }, | ||
57 | + }, | ||
58 | +}; | ||
59 | +</script> | ||
60 | + | ||
61 | +<style lang="scss" scoped> | ||
62 | + .brand-product-list /deep/ .scroll-view { | ||
63 | + background: #f5f5f5; | ||
64 | + } | ||
65 | +</style> |
@@ -67,11 +67,11 @@ export default { | @@ -67,11 +67,11 @@ export default { | ||
67 | 67 | ||
68 | span { | 68 | span { |
69 | font-size: 0.7em; | 69 | font-size: 0.7em; |
70 | - line-height: 1.4; | 70 | + line-height: 1.8; |
71 | border: 1px solid #feabac; | 71 | border: 1px solid #feabac; |
72 | color: #feabac; | 72 | color: #feabac; |
73 | text-align: center; | 73 | text-align: center; |
74 | - padding: 0 0.9em; | 74 | + padding: 0 1.2em; |
75 | margin-right: 0.8em; | 75 | margin-right: 0.8em; |
76 | display: inline-block; | 76 | display: inline-block; |
77 | position: relative; | 77 | position: relative; |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <div @click="onAllClick">全部 <i class="cubeic-arrow"></i></div> | 5 | <div @click="onAllClick">全部 <i class="cubeic-arrow"></i></div> |
6 | </div> | 6 | </div> |
7 | <div class="row"> | 7 | <div class="row"> |
8 | - <div class="col" v-for="(product, idx) in list" :key="idx" @click="onItemClick(product)"> | 8 | + <div class="col" v-for="(product, idx) in viewList" :key="idx" @click="onItemClick(product)"> |
9 | <div class="product-item"> | 9 | <div class="product-item"> |
10 | <square-img :src="product.default_images" :width="300" :height="300" /> | 10 | <square-img :src="product.default_images" :width="300" :height="300" /> |
11 | </div> | 11 | </div> |
@@ -30,6 +30,11 @@ export default { | @@ -30,6 +30,11 @@ export default { | ||
30 | default: [], | 30 | default: [], |
31 | }, | 31 | }, |
32 | }, | 32 | }, |
33 | + computed: { | ||
34 | + viewList() { | ||
35 | + return this.list && this.list.slice(0, 3) || []; | ||
36 | + }, | ||
37 | + }, | ||
33 | methods: { | 38 | methods: { |
34 | onItemClick(item) { | 39 | onItemClick(item) { |
35 | this.$emit('itemClick', item); | 40 | this.$emit('itemClick', item); |
@@ -7,4 +7,9 @@ export default [{ | @@ -7,4 +7,9 @@ export default [{ | ||
7 | productId: parseInt(params.productId, 10), | 7 | productId: parseInt(params.productId, 10), |
8 | }; | 8 | }; |
9 | }, | 9 | }, |
10 | +}, { | ||
11 | + name: 'BrandProductList', | ||
12 | + path: '/xianyu/brand-product/:productId.html', | ||
13 | + component: () => import(/* webpackChunkName: "product" */ './brand-product-list'), | ||
14 | + props: true, | ||
10 | }]; | 15 | }]; |
@@ -201,7 +201,7 @@ export default { | @@ -201,7 +201,7 @@ export default { | ||
201 | next(); | 201 | next(); |
202 | }, | 202 | }, |
203 | methods: { | 203 | methods: { |
204 | - ...mapActions(['fetchProductInfo', 'fetchTop3', 'fetchFav', 'toggleFav', 'updateTradeInfo', 'getSelectedTradeProduct', 'payment', 'resetSelectedSize']), | 204 | + ...mapActions(['fetchProductInfo', 'fetchBrandTop', 'fetchFav', 'toggleFav', 'updateTradeInfo', 'getSelectedTradeProduct', 'payment', 'resetSelectedSize']), |
205 | refresh() { | 205 | refresh() { |
206 | this.$refs.slide.refresh(); | 206 | this.$refs.slide.refresh(); |
207 | }, | 207 | }, |
@@ -218,7 +218,7 @@ export default { | @@ -218,7 +218,7 @@ export default { | ||
218 | loadData(productId = this.productId, loading) { | 218 | loadData(productId = this.productId, loading) { |
219 | loading && loading.show(); | 219 | loading && loading.show(); |
220 | 220 | ||
221 | - this.fetchTop3({productId}); | 221 | + this.fetchBrandTop({productId}); |
222 | this.fetchFav({productId}); | 222 | this.fetchFav({productId}); |
223 | 223 | ||
224 | return this.fetchProductInfo({productId}).then(() => { | 224 | return this.fetchProductInfo({productId}).then(() => { |
@@ -273,23 +273,11 @@ export default { | @@ -273,23 +273,11 @@ export default { | ||
273 | }); | 273 | }); |
274 | }, | 274 | }, |
275 | gotoBrand() { | 275 | gotoBrand() { |
276 | - // type: 4,品牌;5,系列 | ||
277 | - const query = { | ||
278 | - type: 5, | ||
279 | - }; | ||
280 | - | ||
281 | - if (this.productDetail.seriesId && this.productDetail.series_name) { | ||
282 | - query.series = this.productDetail.seriesId; | ||
283 | - query.title = this.productDetail.series_name; | ||
284 | - } else { | ||
285 | - query.type = 4; | ||
286 | - query.brand = this.productDetail.brandId; | ||
287 | - query.title = this.productDetail.brand_name; | ||
288 | - } | ||
289 | - | ||
290 | this.$router.push({ | 276 | this.$router.push({ |
291 | - name: 'List', | ||
292 | - query, | 277 | + name: 'BrandProductList', |
278 | + params: { | ||
279 | + productId: this.productId, | ||
280 | + }, | ||
293 | }); | 281 | }); |
294 | }, | 282 | }, |
295 | showActivity() { | 283 | showActivity() { |
@@ -62,13 +62,13 @@ export default { | @@ -62,13 +62,13 @@ export default { | ||
62 | 62 | ||
63 | commit(Types.UPDATE_PRODUCT_FAV, { productId, isFav }); | 63 | commit(Types.UPDATE_PRODUCT_FAV, { productId, isFav }); |
64 | }, | 64 | }, |
65 | - async fetchTop3({ commit }, { productId }) { | 65 | + async fetchBrandTop({ commit }, { productId }) { |
66 | const result = await this.$api.post('/api/ufo/product/top', { product_id: productId }); | 66 | const result = await this.$api.post('/api/ufo/product/top', { product_id: productId }); |
67 | 67 | ||
68 | if (result.code === 200) { | 68 | if (result.code === 200) { |
69 | const productList = result.data.product_list || []; | 69 | const productList = result.data.product_list || []; |
70 | 70 | ||
71 | - commit(Types.UPDATE_PRODUCT_TOP3, { productId, topList: productList.slice(0, 3) }); | 71 | + commit(Types.UPDATE_BRAND_PRODUCT_TOP_LIST, { productId, topList: productList}); |
72 | } | 72 | } |
73 | }, | 73 | }, |
74 | async toggleFav({ commit }, { productId, isFav }) { | 74 | async toggleFav({ commit }, { productId, isFav }) { |
@@ -30,7 +30,7 @@ export default { | @@ -30,7 +30,7 @@ export default { | ||
30 | state.products = {...state.products, [payload.product_id]: payload}; | 30 | state.products = {...state.products, [payload.product_id]: payload}; |
31 | ensureSelectedProduct(state, payload.product_id); | 31 | ensureSelectedProduct(state, payload.product_id); |
32 | }, | 32 | }, |
33 | - [Types.UPDATE_PRODUCT_TOP3](state, { productId, topList }) { | 33 | + [Types.UPDATE_BRAND_PRODUCT_TOP_LIST](state, { productId, topList }) { |
34 | state.topLists = {...state.topLists, [productId]: topList}; | 34 | state.topLists = {...state.topLists, [productId]: topList}; |
35 | }, | 35 | }, |
36 | [Types.UPDATE_PRODUCT_FAV](state, { productId, isFav }) { | 36 | [Types.UPDATE_PRODUCT_FAV](state, { productId, isFav }) { |
@@ -3,4 +3,4 @@ export const ENSURE_PRODUCT_DETAIL = 'ENSURE_PRODUCT_DETAIL'; | @@ -3,4 +3,4 @@ export const ENSURE_PRODUCT_DETAIL = 'ENSURE_PRODUCT_DETAIL'; | ||
3 | export const UPDATE_PRODUCT_FAV = 'UPDATE_PRODUCT_FAV'; | 3 | export const UPDATE_PRODUCT_FAV = 'UPDATE_PRODUCT_FAV'; |
4 | export const UPDATE_SELECTED_PRODUCT_SIZE = 'UPDATE_SELECTED_PRODUCT_SIZE'; | 4 | export const UPDATE_SELECTED_PRODUCT_SIZE = 'UPDATE_SELECTED_PRODUCT_SIZE'; |
5 | export const RESET_SELECTED_PRODUCT_SIZE = 'RESET_SELECTED_PRODUCT_SIZE'; | 5 | export const RESET_SELECTED_PRODUCT_SIZE = 'RESET_SELECTED_PRODUCT_SIZE'; |
6 | -export const UPDATE_PRODUCT_TOP3 = 'UPDATE_PRODUCT_TOP3'; | 6 | +export const UPDATE_BRAND_PRODUCT_TOP_LIST = 'UPDATE_BRAND_PRODUCT_TOP_LIST'; |
-
Please register or login to post a comment