index.js
1.93 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import actions from './actions';
import mutations from './mutations';
export function defaultState() {
return {
product: {
brand_name: '',
canPublishSecondHand: false,
gender: '通用',
goods_list: [
{
canAddSize: false,
color_name: '',
goods_id: null,
goods_name: '-',
image_list: [
],
size_list: [
]
}
],
least_price: null,
max_price: null,
max_sort_id: null,
min_price: null,
offer_price: null,
product_code: null,
product_id: null,
product_name: null,
sale_time: null,
sellerCanPublish: true,
series_name: null,
shelve_status: null,
resource: null,
activity: [],
recommend: [],
top3: [],
},
topList: {},
fav: {},
/**
* 用户在商品详情页选择的交易信息
* productId: 商品id
* product: 商品详情
* sizeId: 尺寸id
* storageId: 库存id
* size: 尺寸信息
*/
selectedProductInfo: {
productId: null,
product: {},
sizeId: null,
storageId: null,
size: {},
},
};
}
export default function() {
return {
namespaced: true,
state: defaultState(),
mutations,
actions,
getters: {
productDetail(state) {
return state.product;
},
imageList(state) {
return state.product.goods_list[0].image_list;
},
resource(state) {
return state.product.resource;
},
activity(state) {
return state.product.activity;
},
isFav(state) {
return state.fav[state.product.product_id];
},
topList(state) {
return state.topList[state.product.product_id];
},
recommend(state) {
return state.product.recommend;
},
selectedSize(state) {
return state.selectedProductInfo.size;
}
}
};
}