actions.js
4.54 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import * as Types from './types';
import {first, get, flatten} from 'lodash';
export default {
/**
* 获取商品详细信息及尺码列表信息
* @param commit
* @param productId
* @param page
* @param refresh
* @param pageSize
* @returns {Promise<void>}
*/
async fetchProduct({commit}, {productId, page = 1, pageSize = 50, refresh = false}) {
commit(Types.FETCH_ORDER_PRODUCT_REQUEST);
let result;
if (refresh) {
const results = await Promise.all(Array.from(new Array(page)).map((v, i) => {
return this.$api.get('/api/ufo/seller/entryGoodsSizeList', {
productId,
page: i + 1,
limit: pageSize
});
}));
result = {
code: 200,
data: {
productInfo: get(first(results), 'data.productInfo'),
data: flatten(results.map(r => get(r, 'data.data', [])))
}
};
} else {
result = await this.$api.get('/api/ufo/seller/entryGoodsSizeList', {
productId,
page,
limit: pageSize
});
}
console.log(result);
if (result && result.code === 200) {
commit(Types.FETCH_ORDER_PRODUCT_SUCCESS, {
order: result.data,
refresh
});
} else {
commit(Types.FETCH_ORDER_PRODUCT_FAILED);
}
return result;
},
/**
* 获取未入驻商家出售的商品详情
* @param commit
* @param orderCode
* @returns {Promise<void>}
*/
async fetchOrder({commit}, {orderCode}) {
commit(Types.FETCH_NOENTRY_ORDER_PRODUCT_REQUEST);
let result;
result = await this.$api.get('/api/order/detail', {
orderCode,
tabType: 'sell'
});
// console.log('fetchOrder= ', result.data);
if (result && result.code === 200) {
commit(Types.FETCH_NOENTRY_ORDER_PRODUCT_SUCCESS, {
order: result
});
} else {
/*commit(Types.FETCH_NOENTRY_ORDER_PRODUCT_SUCCESS, {
order: result
});*/
commit(Types.FETCH_NOENTRY_ORDER_PRODUCT_FAILED);
}
},
/**
* 不卖了
* @param commit
* @param payload
* @returns {Promise<void>}
*/
async postNoSale({commit}, payload) {
commit(Types.POST_NOSALE_REQUEST);
const result = await this.$api.get('/api/ufo/sellerOrder/batchDownShelf', payload);
// console.log('下架=', result);
if (result && result.code === 200) {
commit(Types.POST_NOSALE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_CALCPRICE_FAILED);
}
return result || {};
},
/**
* 入驻商家试算调价
* @param commit
* @param payload
* @returns {Promise<*|{}>}
*/
async postCalcPrice({commit}, payload) {
commit(Types.POST_CALCPRICE_REQUEST);
const result = await this.$api.get('/api/ufo/sellerOrder/computeAdjustPrice', payload);
if (result && result.code === 200) {
commit(Types.POST_CALCPRICE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_CALCPRICE_FAILED);
}
return result || {};
},
/**
* 未入驻商家试算调价
* @param commit
* @param payload
* @returns {Promise<{}>}
*/
async postNoEntryCalcPrice({commit}, payload) {
commit(Types.POST_NOENTRY_CALCPRICE_REQUEST);
const result = await this.$api.get('/api/ufo/notEntrySeller/computeChangePrice', payload);
if (result && result.code === 200) {
commit(Types.POST_NOENTRY_CALCPRICE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_NOENTRY_CALCPRICE_FAILED);
}
return result || {};
},
/**
* 调价
* @param commit
* @param payload
* @returns {Promise<*|{}>}
*/
async postChangePrice({commit}, payload) {
commit(Types.POST_CHANGE_PRICE_REQUEST);
const result = await this.$api.get('/api/ufo/sellerOrder/batchAdjustPrice', payload);
if (result && result.code === 200) {
commit(Types.POST_CHANGEPRICE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_CHANGEPRICE_FAILED);
}
return result || {};
},
/**
* 未入驻商家调价
* @param commit
* @param payload
* @returns {Promise<*|{}>}
*/
async postNoEntryChangePrice({commit}, payload) {
commit(Types.POST_NOENTRY_CHANGE_PRICE_REQUEST);
const result = await this.$api.get('/api/ufo/notEntrySeller/changePrice', payload);
if (result && result.code === 200) {
commit(Types.POST_NOENTRY_CHANGE_PRICE_SUCCESS, {
order: result.data
});
} else {
commit(Types.POST_NOENTRY_CHANGE_PRICE_FAILED);
}
return result || {};
}
};