zero-service-new.js
2.98 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
/**
* zero-service-new.js
*@author dennis
*@createtime 2018/11/9
*@description 零元购新网络请求
*/
import BaseService from '../../../libs/services/baseService'
import { MINI_QR_TYPE, MINI_APP_TYPE} from '../../../libs/config';
import Promise from '../../../vendors/es6-promise';
import config from '../../../config.js'
const MODULE = '/activity/zerobuy';
function productTime(product) {
if (product.status === 1) {
product.end_time = 0;
}
return product;
}
export default class ZeroSellServices extends BaseService {
constructor(props) {
super(props)
this.url = config.domains.activityHost + MODULE
}
getList(data, complete) {
data.channel = 1
let self = this;
return new Promise(function (resolve, reject) {
self.GET(
{
...data,
},
{
path: '/list',
complete
}
).then(result => {
const products = result;
const newProducts = products.map(productTime)
resolve({
code: 200,
data: newProducts
})
})
.catch(error => {
console.log(error)
reject(error)
})
})
}
getDetail(data,complete) {
let self = this;
return new Promise(function (resolve, reject) {
self.GET(
{
...data
},
{
path: '/content',
complete
}
).then(result => {
let newProduct = productTime(result)
resolve(
{
code: 200,
data: newProduct
}
)
})
.catch(error => {
console.log(error)
reject(error)
})
})
}
getRecommend(data, complete) {
data.channel = 1
let self = this;
return new Promise(function (resolve, reject) {
self.GET(
{
...data
},
{
path: '/list/recommend',
complete
}
)
.then(result => {
const products = result;
const newProducts = products.map(productTime)
resolve({
code: 200,
data: newProducts
})
})
.catch(error => {
console.log(error)
reject(error)
})
})
}
getRecentAvatars(data, complete) {
return this.GET(
{
...data
},
{
path: '/code/recent',
complete
}
)
}
getMyList(data, complete) {
data.channel = 1
return this.GET(
{
...data
},
{
path: '/list/mine',
complete
}
)
}
getQrCode(page_param) {
return config.domains.yohoApi + '/wechat/miniapp/img-check.jpg?param=' + JSON.stringify(page_param) + `&miniQrType=${MINI_QR_TYPE}&miniapp_type=${MINI_APP_TYPE}`;
}
fetchCode(data, complete) {
data.miniAppType = MINI_APP_TYPE
return this.POST(
{
...data
},
{
path: '/code/gain',
complete
}
)
}
}