zero-sell.js
2.5 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
import Service from './service'
import { ACTIVITY_HOST, API_HOST, MINI_QR_TYPE, MINI_APP_TYPE} from '../../../libs/config';
const MODULE = '/activity/zerobuy';
function productTime(product) {
if (product.status === 1) {
product.end_time = 0;
}
return product;
}
class ZeroSellService extends Service {
constructor() {
super(ACTIVITY_HOST + MODULE);
}
getList(data) {
data.channel = 0
return this._get('/list', data).then(result => {
if (result.code === 200) {
const products = result.data.list ? result.data.list : result.data;
const newProducts = products.map(productTime)
result.data = newProducts;
return result;
}
return result;
})
}
getDetail(data) {
return this._get('/content', data).then(result => {
if (result.code === 200) {
Object.keys(result.data).forEach(item => {
if (item === 'my_code_num') {
result.data['myCodeNum'] = result.data[item];
}
})
productTime(result.data)
return result;
}
return result;
});
}
getYohoodDetail(data) {
return this._get('/yohood/content', data).then(result => {
if (result.code === 200) {
Object.keys(result.data).forEach(item => {
if (item === 'my_code_num') {
result.data['myCodeNum'] = result.data[item];
}
})
return result;
}
return result;
});
}
getRecommend(data) {
data.channel = 0
return this._get('/list/recommend', data).then(result => {
if (result.code === 200) {
const products = result.data;
const newProducts = products.map(productTime)
result.data = newProducts;
return result;
}
return result
});
}
getMyList(data) {
data.channel = 0
return this._get('/list/mine', data);
}
getRecentAvatars(data) {
return this._get('/code/recent', data);
}
fetchCode(data) {
data.miniAppType = MINI_APP_TYPE
return this._post('/code/gain', data);
}
fetchMyPrizeList(data) {
return this._get('/code/mine', data);
}
fetchActivitySum(data) {
return this._get('/join/sum', data);
}
getQrCode(page_param) {
return API_HOST + '/wechat/miniapp/img-check.jpg?param=' + JSON.stringify(page_param) + `&miniQrType=${MINI_QR_TYPE}` + `&miniapp_type=${MINI_APP_TYPE}`;
}
getUserProfile(data) {
return this._get('', {
method: 'app.passport.profile',
uid: data.uid
});
}
}
export default ZeroSellService;