index.js
6.86 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
import api from '../../common/api';
import config from '../../common/config';
export default {
/**
* [记录表单提交ID]
* @param {[type]} formId [表单ID]
*/
addFormId(formId) {
if (!formId) {
return Promise.resolve({code: 401, data: {}, message: 'form id is empty'});
}
let app = getApp();
let openId = app && app.getOpenID();
let uid = app && app.getUid();
if (!openId) {
return Promise.resolve({code: 401, data: {}, message: 'open id is empty'});
}
if (!uid) {
return Promise.resolve({code: 401, data: {}, message: 'uid id is empty'});
}
return api.get({
data: {
method: 'wechat.formId.add',
miniapp_type: config.miniapp_type,
formId: formId,
openId: openId
}
});
},
/**
* [解析小程序二维码生成的参数]
* @param {[type]} code [description]
* @return {[type]} [description]
*/
getMiniAppRealParam(code) {
return api.get({
url: '/wechat/miniapp/getMiniAppRealParam',
data: {
md5Param: code,
miniapp_type: config.miniapp_type
}
}).then(res => {
return JSON.parse(res.data || '{}');
}).catch(e => {
return {code: 401, message: e.message};
});
},
/**
* 解析用户信息
* @param thirdSession
* @param encryptedData
* @param iv
* @returns {*}
*/
decodeUserInfo(thirdSession, encryptedData, iv) {
return api.get({
url: '/wechat/',
data: {
iv,
encryptedData,
srdSession: thirdSession,
method: 'wechat.smallProgram.decodeUserInfo'
}
});
},
/**
* 判断有货微信账户是否绑定手机号
* @param unionID
* @param nickName
* @returns {*}
*/
wechatUserIsBind(unionID, nickName) {
return api.get({
url: '',
data: {
method: 'app.passport.signinByOpenID',
openId: unionID,
source_type: 'wechat',
nickname: nickName,
}
});
},
/**
* 微信登录小程序
* @param code
* @returns {*}
*/
wechatMiniAppLogin(code) {
return api.get({
url: '/wechat/',
data: {
method: 'wechat.smallProgram.onLogin',
jsCode: code,
miniapp_type: config.miniapp_type
}
});
},
/**
* 绑定小程序
* @param unionId
* @param mobile
* @param code
* @param area
* @returns {*}
*/
bindMiniapp(unionId, mobile, code, area = 86, fromPage = '') {
return api.get({
url: '',
data: {
code,
mobile,
fromPage,
area,
open_id: unionId,
source_type: 'wechat',
method: 'app.passport.bindMiniapp'
}
});
},
/**
* 自动绑定小程序
* @param unionId
* @param mobile
* @param area
* @returns {*}
*/
bindMiniAppByAuto(unionId, mobile, area = 86, fromPage = '') {
return api.get({
url: '',
data: {
mobile,
area,
fromPage,
open_id: unionId,
source_type: 'wechat',
method: 'app.passport.miniAppBindByAuto'
}
});
},
/**
* 新注册用户上报
* @param storeId
* @param fromPage
* @returns {*}
*/
recordRegisterSource({storeId, fromPage}) {
return api.get({
url: '',
data: {
fromPage,
storeId,
source_type: 'wechat',
method: 'app.passport.recordRegisterSource'
}
});
},
/**
* 自动登录
* @param mobile
* @param code
* @param area
* @returns {*}
*/
autoSignIn(mobile, code, area = 86, fromPage = '') {
return api.get({
url: '',
data: {
code,
area,
fromPage,
profile: mobile,
source_type: 'wechat',
method: 'app.passport.autoSignin'
}
});
},
/**
* sessionKey是否失效验证
* @returns {*}
*/
verify() {
return api.get({
url: '',
data: {
method: 'app.passport.verify'
}
});
},
/**
* 获取用户信息
* @param uid 用户UID
* @returns {*}
*/
getProfile() {
return api.get({
url: '',
data: {
method: 'app.passport.profile'
}
});
},
/**
* 获取优惠券总数
* @returns {*}
*/
getCouponTotal() {
return api.get({
url: '/coupon/total.do',
data: {},
api: 'store'
});
},
/**
* 获取有货币总数
* @returns {*}
*/
getCoinTotal() {
return api.get({
url: '',
data: {
method: 'app.yohocoin.total'
}
});
},
/**
* 获取国家和地区
* @returns {*}
*/
getArea() {
return api.get({
url: '',
data: {
source_type: 'wechat',
method: 'app.passport.getArea'
}
});
},
/**
* 用户未授权-发送验证码
* @param area 国家码
* @param mobile 手机号
* @param degrees 验证码
* @returns {*}
*/
sendSms(area, mobile, degrees) {
return api.get({
url: '',
data: {
area,
mobile,
degrees,
source_type: 'wechat',
fromPage: 'miniapp',
method: 'app.message.sendSms'
}
});
},
/**
* 用户已授权-发送验证码
* @param mobile 手机号
* @param area 国家码
* @param degrees 验证码
* @returns {*}
*/
sendCodeByMiniApp(area, mobile, openId, degrees) {
return api.get({
url: '',
data: {
area,
mobile,
degrees,
open_id: openId,
source_type: 'wechat',
fromPage: 'miniapp',
method: 'app.bind.sendThirdBindMobileCodeOnlyImg'
}
});
},
/**
* 是否需要验证码
*/
isNeedImgCheck() {
return api.get({
url: '/smart/way',
});
}
};