actions.js
1.57 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
import * as Types from './types';
const TYPE = {notuse: 'notuse', use: 'use', overtime: 'overtime'};
function _handleCoupon(item, type) {
if (type === TYPE.use) {
item.is_used = true;
}
if (type === TYPE.use || item.is_overtime === 'Y' || item.is_invalid === 'Y') {
item.usedOvertimeOrInValid = true;
}
item.useNowLink = 'fdsafdsa';
return item;
}
export default {
async fetchYohoList({commit}, {type, filter, limit, page}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
const result = await this.$api.get('/api/coupon/yoho/list', {type, filter, limit, page});
if (result && result.code === 200) {
commit(Types.FETCH_YOHO_COUPON_SUCCESS, {
type,
list: result.data.couponList.map(_handleCoupon),
filter: result.data.filters
});
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
},
async fetchYohoNum({commit}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
const result = await this.$api.get('/api/coupon/yoho/num', {});
if (result && result.code === 200) {
commit(Types.FETCH_YOHO_COUPON_NUM_SUCCESS, result.data);
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
},
async fetchUfoList({commit}, {limit, page}) {
commit(Types.FETCH_YOHO_COUPON_REQUEST);
const result = await this.$api.get('/api/coupon/ufo/list', {limit: 20, page: 1});
if (result && result.code === 200) {
commit(Types.FETCH_UFO_COUPON_SUCCESS, {
list: result.data.couponList.map(_handleCoupon),
});
} else {
commit(Types.FETCH_YOHO_COUPON_FAILED);
}
},
};