actions.js
1.88 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
import * as Types from './types';
export default {
/*
* @ description: 获取商品详情
* @ author: huzhiming
* @ date: 2019-11-22 10:15:13
* @ version: v1.0.0
*/
async fetchDetailById({ commit, state }, { skup = null }) {
let { data: info = null } = await this.$api.post('/api/ufo/secondhand/productDetail', { skup });
// console.log('[store/actions/fetchDetailById]:', info);
commit(Types.UPDATE_PRODUCT_DETAIL, {info});
},
/*
* @ description: 获取相同尺寸二手列表
* @ author: huzhiming
* @ date: 2019-11-22 17:05:04
* @ version: v1.0.0
*/
async fetchSameSizeSecondList({ commit, state }, { isReset, storage_id, second_type = null, sort = null }) {
let page = 1;
if (isReset) {
page = 1;
} else {
page = state.page;
}
let pageSize = 10;
const { data, code } = await this.$api.get('/api/ufo/secondhand/list', { page, pageSize, storage_id: storage_id, second_type, sort });
// console.log(page, pageSize, storage_id, second_type, sort);
// console.log('[store/actions/fetchSameSizeSecondList]:', data);
if (code === 200) {
commit(Types.UPDATE_PRODUCT_LIST, { data, isReset });
} else {
commit(Types.UPDATE_PRODUCT_LIST, { error: true, data, isReset });
}
return data || [];
},
/*
* @ description: 获取筛选数据
* @ author: huzhiming
* @ date: 2019-11-22 14:32:46
* @ version: v1.0.0
*/
async fetchFilterData({ commit, state }, { storage_id = null }) {
let { data: { filter = [] } } = await this.$api.post('/api/ufo/secondhand/filter', { storage_id });
// console.log('[store/actions/fetchFilterData]:', JSON.stringify(filter));
commit(Types.UPDATE_PRODUCT_FILTER, { filter });
return filter;
},
fetchStorageCount(ctx, { storageId }) {
return this.$api.post('/api/ufo/secondhand/storageCount', { storage_id: storageId });
}
};