@conecli/cone-render 0.10.1-shop3.93 → 0.10.1-shop3.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/language/en_US.json +2 -2
- package/dist/language/zh_CN.json +2 -2
- package/dist/language/zh_HK.json +2 -2
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -1
- package/dist/utils/jumpExtMapUtil.weapp.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
1
|
WxappVerifyColorList,
|
|
3
2
|
isLanguageForEn,
|
|
4
3
|
isJdApp,
|
|
5
4
|
showSuccessToast,
|
|
6
5
|
showFailToast,
|
|
7
6
|
isMin,
|
|
8
7
|
cookiesStr: '',
|
|
9
8
|
requestHeaderContentType: {
|
|
10
9
|
jsonHeader: {
|
|
11
10
|
'content-type': 'application/json;charset=utf-8',
|
|
12
11
|
},
|
|
13
12
|
formDataHeader: {
|
|
14
13
|
'content-type': 'application/x-www-form-urlencoded',
|
|
15
14
|
},
|
|
16
15
|
},
|
|
17
16
|
requestBaseParam: {
|
|
18
17
|
data: null,
|
|
19
18
|
header: {
|
|
20
19
|
'content-type': 'application/json;charset=utf-8',
|
|
21
20
|
},
|
|
22
21
|
},
|
|
23
22
|
timeOut: 7000,
|
|
24
23
|
apiClientParams: {
|
|
25
24
|
appid: 'wx_mini_app',
|
|
26
25
|
clientVersion: '11.0.0',
|
|
27
26
|
client: 'wh5',
|
|
28
27
|
area: '1_72_2799_0',
|
|
29
28
|
screen: `${Math.ceil(getSystemInfo?.screenWidth * devicePixelRatio)}*${Math.ceil(
|
|
30
29
|
getSystemInfo?.screenHeight * devicePixelRatio,
|
|
31
30
|
)}`,
|
|
32
31
|
uuid: '-1',
|
|
33
32
|
loginType: '11',
|
|
34
33
|
},
|
|
35
34
|
public addressFetchInfo: {
|
|
36
35
|
reqState: boolean;
|
|
37
36
|
promiseInstance: null | Promise<any>;
|
|
38
37
|
};
|
|
39
38
|
public getPromotionConfig: {
|
|
40
39
|
projectId: null | string | number;
|
|
41
40
|
pageId: null | string | number;
|
|
42
41
|
};
|
|
43
42
|
public resInfo: ServiceInterFace.HttpRequestInfo;
|
|
44
43
|
public api: ServiceInterFace.HttpApi;
|
|
45
44
|
public verifyColorList: string[];
|
|
46
45
|
constructor(opt) {
|
|
47
46
|
this._init();
|
|
48
47
|
this.addressFetchInfo = {
|
|
49
48
|
reqState: false,
|
|
50
49
|
promiseInstance: null,
|
|
51
50
|
};
|
|
52
51
|
this.getPromotionConfig = {
|
|
53
52
|
projectId: null,
|
|
54
53
|
pageId: null,
|
|
55
54
|
};
|
|
56
55
|
this._userAreaUpdateListen();
|
|
57
56
|
this.resInfo = this._getResConfig(opt);
|
|
58
57
|
this.api = api;
|
|
59
58
|
this.verifyColorList = [
|
|
60
59
|
...WxappVerifyColorList,
|
|
61
60
|
];
|
|
62
61
|
}
|
|
63
62
|
_init(): void {
|
|
64
63
|
httpInterceptors.forEach((item) => {
|
|
65
64
|
Taro.addInterceptor((chain) => item(chain));
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
69
68
|
return Object.assign({}, DefaultConfig, opt);
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
_userAreaUpdateListen() {
|
|
73
72
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
|
|
74
73
|
this.updateApiClientParamsResInfo(areaInfo);
|
|
75
74
|
});
|
|
76
75
|
}
|
|
77
76
|
updateApiClientParamsResInfo(opt = {}) {
|
|
78
77
|
const { area, realTimeArea, ...others } = opt;
|
|
79
78
|
this.resInfo.apiClientParams = {
|
|
80
79
|
...this.resInfo.apiClientParams,
|
|
81
80
|
...others,
|
|
82
81
|
};
|
|
83
82
|
area && area !== '' && (this.resInfo.apiClientParams.area = area);
|
|
84
83
|
realTimeArea &&
|
|
85
84
|
realTimeArea !== '' &&
|
|
86
85
|
(this.resInfo.apiClientParams.realTimeArea = realTimeArea);
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
|
|
90
89
|
if (functionId === 'receiveShopCoupon') {
|
|
91
90
|
clientParams = Object.assign(
|
|
92
91
|
{},
|
|
93
92
|
{
|
|
94
93
|
loginType: '1',
|
|
95
94
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
96
95
|
},
|
|
97
96
|
clientParams,
|
|
98
97
|
);
|
|
99
98
|
}
|
|
100
99
|
const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
|
|
101
100
|
const isColorVerify = this.verifyColorList.includes(functionId);
|
|
102
101
|
const getReqData = {
|
|
103
102
|
functionId: functionId,
|
|
104
103
|
body: JSON.stringify(bodyParams),
|
|
105
104
|
t: Date.now(),
|
|
106
105
|
...apiClientParams,
|
|
107
106
|
};
|
|
108
107
|
return http
|
|
109
108
|
.request({
|
|
110
109
|
url: this.api.apiFunc,
|
|
111
110
|
data: getReqData,
|
|
112
111
|
isColorVerify,
|
|
113
112
|
})
|
|
114
113
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
115
114
|
const { statusCode, data } = res;
|
|
116
115
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
117
116
|
ok: true,
|
|
118
117
|
};
|
|
119
118
|
if (statusCode === 200 && data) {
|
|
120
119
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
121
120
|
? Number(res.data.code)
|
|
122
121
|
: -1;
|
|
123
122
|
const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
|
|
124
123
|
? Number(res.data.subCode)
|
|
125
124
|
: -1;
|
|
126
125
|
if (
|
|
127
126
|
data.success === true ||
|
|
128
127
|
data.isSuccess ||
|
|
129
128
|
resCode === 0 ||
|
|
130
129
|
resCode === 200 ||
|
|
131
130
|
subCode === 0
|
|
132
131
|
) {
|
|
133
132
|
changeRes = {
|
|
134
133
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
135
134
|
? data.result
|
|
136
135
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
137
136
|
? data.data
|
|
138
137
|
: data,
|
|
139
138
|
code: data.code || 200,
|
|
140
139
|
ok: true,
|
|
141
140
|
source: data,
|
|
142
141
|
};
|
|
143
142
|
return changeRes;
|
|
144
143
|
} else {
|
|
145
144
|
changeRes = {
|
|
146
145
|
...data,
|
|
147
146
|
ok: false,
|
|
148
147
|
statusCode: res.statusCode,
|
|
149
148
|
};
|
|
150
149
|
return changeRes;
|
|
151
150
|
}
|
|
152
151
|
} else {
|
|
153
152
|
changeRes = {
|
|
154
153
|
...data,
|
|
155
154
|
ok: false,
|
|
156
155
|
statusCode: res.statusCode,
|
|
157
156
|
};
|
|
158
157
|
return changeRes;
|
|
159
158
|
}
|
|
160
159
|
})
|
|
161
160
|
.catch((res) => {
|
|
162
161
|
return {
|
|
163
162
|
...res,
|
|
164
163
|
ok: false,
|
|
165
164
|
} as ServiceInterFace.RequestResponseFormatRes;
|
|
166
165
|
});
|
|
167
166
|
}
|
|
168
167
|
|
|
169
168
|
async receiveCoupon(param = {}, clientParams) {
|
|
170
169
|
console.warn('receiveCoupon 方法在微信京购小程序环境未经验证,请不要使用!');
|
|
171
170
|
return await this.gatewayReq(
|
|
172
171
|
'receiveShopCoupon',
|
|
173
172
|
{
|
|
174
173
|
operation: '3',
|
|
175
174
|
...param,
|
|
176
175
|
},
|
|
177
176
|
{ ...clientParams },
|
|
178
177
|
);
|
|
179
178
|
}
|
|
180
179
|
|
|
181
180
|
getCustomerCenterDispatch(params = {}) {
|
|
182
181
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
183
182
|
clientVersion: '9.2.0',
|
|
184
183
|
client: 'H5',
|
|
185
184
|
uuid: 88888,
|
|
186
185
|
appid: 'shopmember_m_jd_com',
|
|
187
186
|
});
|
|
188
187
|
}
|
|
189
188
|
|
|
190
189
|
batchAddCart(...args) {
|
|
191
190
|
let skuIds, num, showToast, giftCard;
|
|
192
191
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
193
192
|
[skuIds, num = 1, showToast = true, giftCard = false] = args;
|
|
194
193
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
195
194
|
const params = args[0];
|
|
196
195
|
skuIds = params.skuIds;
|
|
197
196
|
num = params.num || 1;
|
|
198
197
|
showToast = params.showToast !== undefined ? params.showToast : true;
|
|
199
198
|
giftCard = params.giftCard !== undefined ? params.giftCard : false;
|
|
200
199
|
} else {
|
|
201
200
|
console.error('batchAddCart() Invalid arguments!', args);
|
|
202
201
|
const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
|
|
203
202
|
showFailToast({
|
|
204
203
|
title: msg,
|
|
205
204
|
});
|
|
206
205
|
return Promise.resolve({
|
|
207
206
|
ok: false,
|
|
208
207
|
msg,
|
|
209
208
|
});
|
|
210
209
|
}
|
|
211
210
|
const addToWhereText = giftCard ? '购物清单' : '购物车';
|
|
212
211
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
|
|
213
212
|
const failMsg = isLanguageForEn
|
|
214
213
|
? 'Please retry later'
|
|
215
214
|
: `加入${addToWhereText}失败,请稍后重试!`;
|
|
216
215
|
if (skuIds) {
|
|
217
216
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
218
217
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
219
218
|
if (res?.ok) {
|
|
220
219
|
if (showToast && !res?.isOpenApp)
|
|
221
220
|
showSuccessToast({
|
|
222
221
|
title: successMsg,
|
|
223
222
|
});
|
|
224
223
|
} else {
|
|
225
224
|
showToast &&
|
|
226
225
|
showFailToast({
|
|
227
226
|
title: res?.errMsg || failMsg,
|
|
228
227
|
});
|
|
229
228
|
}
|
|
230
229
|
return Promise.resolve(res);
|
|
231
230
|
})
|
|
232
231
|
.catch((e) => {
|
|
233
232
|
console.log('调用加购方法异常=======>', e);
|
|
234
233
|
return Promise.resolve({
|
|
235
234
|
ok: false,
|
|
236
235
|
msg: failMsg,
|
|
237
236
|
});
|
|
238
237
|
});
|
|
239
238
|
} else {
|
|
240
239
|
return Promise.resolve({
|
|
241
240
|
ok: false,
|
|
242
241
|
msg: failMsg,
|
|
243
242
|
});
|
|
244
243
|
}
|
|
245
244
|
}
|
|
246
245
|
|
|
247
246
|
async giftCardAddCart(skuList, num) {
|
|
248
247
|
return this.gatewayReq('giftCardAddCart', {
|
|
249
248
|
skuList,
|
|
250
249
|
num: Number(num),
|
|
251
250
|
});
|
|
252
251
|
}
|
|
253
252
|
|
|
254
253
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
255
254
|
return new Promise((resolve) => {
|
|
256
255
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
|
|
257
256
|
if (productIdsArr.length > 0) {
|
|
258
257
|
if (giftCard) {
|
|
259
258
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
260
259
|
.then((res) => {
|
|
261
260
|
if (res?.code === '0' && res?.result?.value) {
|
|
262
261
|
resolve({
|
|
263
262
|
ok: true,
|
|
264
263
|
});
|
|
265
264
|
} else {
|
|
266
265
|
resolve({
|
|
267
266
|
ok: false,
|
|
268
267
|
msg: '加购失败,请稍后重试',
|
|
269
268
|
});
|
|
270
269
|
}
|
|
271
270
|
})
|
|
272
271
|
.catch((e) => {
|
|
273
272
|
console.error('礼品卡加车失败: ', e);
|
|
274
273
|
resolve({
|
|
275
274
|
ok: false,
|
|
276
275
|
msg: '加购失败,请稍后重试',
|
|
277
276
|
});
|
|
278
277
|
});
|
|
279
278
|
} else if (isJdApp) {
|
|
280
279
|
console.log('==========>', 'app原生批量加车!,小程序端暂不涉及');
|
|
281
280
|
} else if (isMin) {
|
|
282
281
|
console.log('==========>', '京购批量加车!');
|
|
283
282
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
284
283
|
return {
|
|
285
284
|
skuId: skuItem,
|
|
286
285
|
buyNum: addCardNum,
|
|
287
286
|
};
|
|
288
287
|
});
|
|
289
288
|
global.wxAppBizInstance
|
|
290
289
|
.addCart({ commArr: productsAddCartList })
|
|
291
290
|
.then((res) => {
|
|
292
291
|
console.log('dealCartSuccess: ', res);
|
|
293
292
|
resolve({
|
|
294
293
|
ok: true,
|
|
295
294
|
msg: '已加入购物车!',
|
|
296
295
|
data: res,
|
|
297
296
|
});
|
|
298
297
|
})
|
|
299
298
|
.catch((e) => {
|
|
300
299
|
console.log('京购小程序批量加车失败dealCartFail: ', e);
|
|
301
300
|
resolve({
|
|
302
301
|
ok: false,
|
|
303
302
|
msg: '加购失败,请稍后重试',
|
|
304
303
|
});
|
|
305
304
|
});
|
|
306
305
|
} else {
|
|
307
306
|
console.log('==========>', 'M站批量加车!');
|
|
308
307
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
|
|
309
308
|
}
|
|
310
309
|
} else {
|
|
311
310
|
resolve({
|
|
312
311
|
ok: false,
|
|
313
312
|
msg: '加购sku不能为空',
|
|
314
313
|
});
|
|
315
314
|
}
|
|
316
315
|
});
|
|
317
316
|
}
|
|
318
317
|
|
|
319
318
|
productAddToCart() {
|
|
320
319
|
return Promise.resolve({
|
|
321
320
|
ok: false,
|
|
322
321
|
msg: 'productAddToCart暂不支持小程序',
|
|
323
322
|
});
|
|
324
323
|
}
|
|
325
324
|
bMallGetUserInfo(){
|
|
326
325
|
return Promise.resolve({
|
|
327
326
|
ok: false,
|
|
328
327
|
msg: 'productAddToCart暂不支持小程序',
|
|
329
328
|
});
|
|
330
329
|
}
|
|
331
330
|
bMallGetSkuNumApi(){
|
|
332
331
|
return Promise.resolve({
|
|
333
332
|
ok: false,
|
|
334
333
|
msg: 'productAddToCart暂不支持小程序',
|
|
335
334
|
});
|
|
336
335
|
}
|
|
337
336
|
bMallCartHandle(){
|
|
338
337
|
return Promise.resolve({
|
|
339
338
|
ok: false,
|
|
340
339
|
msg: 'productAddToCart暂不支持小程序',
|
|
341
340
|
});
|
|
342
341
|
}
|
|
342
|
+
import Taro from '@tarojs/taro';
|
|
343
343
|
cookiesStr: '',
|
|
344
344
|
requestHeaderContentType: {
|
|
345
345
|
jsonHeader: {
|
|
346
346
|
'content-type': 'application/json;charset=utf-8',
|
|
347
347
|
},
|
|
348
348
|
formDataHeader: {
|
|
349
349
|
'content-type': 'application/x-www-form-urlencoded',
|
|
350
350
|
},
|
|
351
351
|
},
|
|
352
352
|
requestBaseParam: {
|
|
353
353
|
data: null,
|
|
354
354
|
header: {
|
|
355
355
|
'content-type': 'application/json;charset=utf-8',
|
|
356
356
|
},
|
|
357
357
|
},
|
|
358
358
|
timeOut: 7000,
|
|
359
359
|
apiClientParams: {
|
|
360
360
|
appid: 'wx_mini_app',
|
|
361
361
|
clientVersion: '11.0.0',
|
|
362
362
|
client: 'wh5',
|
|
363
363
|
area: '1_72_2799_0',
|
|
364
364
|
screen: `${Math.ceil(getSystemInfo?.screenWidth * devicePixelRatio)}*${Math.ceil(
|
|
365
365
|
getSystemInfo?.screenHeight * devicePixelRatio,
|
|
366
366
|
)}`,
|
|
367
367
|
uuid: '-1',
|
|
368
368
|
loginType: '11',
|
|
369
369
|
},
|
|
370
370
|
public addressFetchInfo: {
|
|
371
371
|
reqState: boolean;
|
|
372
372
|
promiseInstance: null | Promise<any>;
|
|
373
373
|
};
|
|
374
374
|
public getPromotionConfig: {
|
|
375
375
|
projectId: null | string | number;
|
|
376
376
|
pageId: null | string | number;
|
|
377
377
|
};
|
|
378
378
|
public resInfo: ServiceInterFace.HttpRequestInfo;
|
|
379
379
|
public api: ServiceInterFace.HttpApi;
|
|
380
380
|
public verifyColorList: string[];
|
|
381
381
|
constructor(opt) {
|
|
382
382
|
this._init();
|
|
383
383
|
this.addressFetchInfo = {
|
|
384
384
|
reqState: false,
|
|
385
385
|
promiseInstance: null,
|
|
386
386
|
};
|
|
387
387
|
this.getPromotionConfig = {
|
|
388
388
|
projectId: null,
|
|
389
389
|
pageId: null,
|
|
390
390
|
};
|
|
391
391
|
this._userAreaUpdateListen();
|
|
392
392
|
this.resInfo = this._getResConfig(opt);
|
|
393
393
|
this.api = api;
|
|
394
394
|
this.verifyColorList = [...WxappVerifyColorList];
|
|
395
395
|
}
|
|
396
396
|
_init(): void {
|
|
397
397
|
httpInterceptors.forEach((item) => {
|
|
398
398
|
Taro.addInterceptor((chain) => item(chain));
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
401
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
402
402
|
return Object.assign({}, DefaultConfig, opt);
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
_userAreaUpdateListen() {
|
|
406
406
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
|
|
407
407
|
this.updateApiClientParamsResInfo(areaInfo);
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
410
|
updateApiClientParamsResInfo(opt = {}) {
|
|
411
411
|
const { area, realTimeArea, ...others } = opt;
|
|
412
412
|
this.resInfo.apiClientParams = {
|
|
413
413
|
...this.resInfo.apiClientParams,
|
|
414
414
|
...others,
|
|
415
415
|
};
|
|
416
416
|
area && area !== '' && (this.resInfo.apiClientParams.area = area);
|
|
417
417
|
realTimeArea &&
|
|
418
418
|
realTimeArea !== '' &&
|
|
419
419
|
(this.resInfo.apiClientParams.realTimeArea = realTimeArea);
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
|
|
423
423
|
if (functionId === 'receiveShopCoupon') {
|
|
424
424
|
clientParams = Object.assign(
|
|
425
425
|
{},
|
|
426
426
|
{
|
|
427
427
|
loginType: '1',
|
|
428
428
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
429
429
|
},
|
|
430
430
|
clientParams,
|
|
431
431
|
);
|
|
432
432
|
}
|
|
433
433
|
const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
|
|
434
434
|
const isColorVerify = this.verifyColorList.includes(functionId);
|
|
435
435
|
const getReqData = {
|
|
436
436
|
functionId: functionId,
|
|
437
437
|
body: JSON.stringify(bodyParams),
|
|
438
438
|
t: Date.now(),
|
|
439
439
|
...apiClientParams,
|
|
440
440
|
};
|
|
441
441
|
return http
|
|
442
442
|
.request({
|
|
443
443
|
url: this.api.apiFunc,
|
|
444
444
|
data: getReqData,
|
|
445
445
|
isColorVerify,
|
|
446
446
|
})
|
|
447
447
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
448
448
|
const { statusCode, data } = res;
|
|
449
449
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
450
450
|
ok: true,
|
|
451
451
|
};
|
|
452
452
|
if (statusCode === 200 && data) {
|
|
453
453
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
454
454
|
? Number(res.data.code)
|
|
455
455
|
: -1;
|
|
456
456
|
const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
|
|
457
457
|
? Number(res.data.subCode)
|
|
458
458
|
: -1;
|
|
459
459
|
if (
|
|
460
460
|
data.success === true ||
|
|
461
461
|
data.isSuccess ||
|
|
462
462
|
resCode === 0 ||
|
|
463
463
|
resCode === 200 ||
|
|
464
464
|
subCode === 0
|
|
465
465
|
) {
|
|
466
466
|
changeRes = {
|
|
467
467
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
468
468
|
? data.result
|
|
469
469
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
470
470
|
? data.data
|
|
471
471
|
: data,
|
|
472
472
|
code: data.code || 200,
|
|
473
473
|
ok: true,
|
|
474
474
|
source: data,
|
|
475
475
|
};
|
|
476
476
|
return changeRes;
|
|
477
477
|
} else {
|
|
478
478
|
changeRes = {
|
|
479
479
|
...data,
|
|
480
480
|
ok: false,
|
|
481
481
|
statusCode: res.statusCode,
|
|
482
482
|
};
|
|
483
483
|
return changeRes;
|
|
484
484
|
}
|
|
485
485
|
} else {
|
|
486
486
|
changeRes = {
|
|
487
487
|
...data,
|
|
488
488
|
ok: false,
|
|
489
489
|
statusCode: res.statusCode,
|
|
490
490
|
};
|
|
491
491
|
return changeRes;
|
|
492
492
|
}
|
|
493
493
|
})
|
|
494
494
|
.catch((res) => {
|
|
495
495
|
return {
|
|
496
496
|
...res,
|
|
497
497
|
ok: false,
|
|
498
498
|
} as ServiceInterFace.RequestResponseFormatRes;
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
async receiveCoupon(param = {}, clientParams) {
|
|
503
503
|
console.warn('receiveCoupon 方法在微信京购小程序环境未经验证,请不要使用!');
|
|
504
504
|
return await this.gatewayReq(
|
|
505
505
|
'receiveShopCoupon',
|
|
506
506
|
{
|
|
507
507
|
operation: '3',
|
|
508
508
|
...param,
|
|
509
509
|
},
|
|
510
510
|
{ ...clientParams },
|
|
511
511
|
);
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
getCustomerCenterDispatch(params = {}) {
|
|
515
515
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
516
516
|
clientVersion: '9.2.0',
|
|
517
517
|
client: 'H5',
|
|
518
518
|
uuid: 88888,
|
|
519
519
|
appid: 'shopmember_m_jd_com',
|
|
520
520
|
});
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
batchAddCart(...args) {
|
|
524
524
|
let skuIds, num, showToast, giftCard;
|
|
525
525
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
526
526
|
[skuIds, num = 1, showToast = true, giftCard = false] = args;
|
|
527
527
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
528
528
|
const params = args[0];
|
|
529
529
|
skuIds = params.skuIds;
|
|
530
530
|
num = params.num || 1;
|
|
531
531
|
showToast = params.showToast !== undefined ? params.showToast : true;
|
|
532
532
|
giftCard = params.giftCard !== undefined ? params.giftCard : false;
|
|
533
533
|
} else {
|
|
534
534
|
console.error('batchAddCart() Invalid arguments!', args);
|
|
535
535
|
const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
|
|
536
536
|
showFailToast({
|
|
537
537
|
title: msg,
|
|
538
538
|
});
|
|
539
539
|
return Promise.resolve({
|
|
540
540
|
ok: false,
|
|
541
541
|
msg,
|
|
542
542
|
});
|
|
543
543
|
}
|
|
544
544
|
const addToWhereText = giftCard ? '购物清单' : '购物车';
|
|
545
545
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
|
|
546
546
|
const failMsg = isLanguageForEn
|
|
547
547
|
? 'Please retry later'
|
|
548
548
|
: `加入${addToWhereText}失败,请稍后重试!`;
|
|
549
549
|
if (skuIds) {
|
|
550
550
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
551
551
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
552
552
|
if (res?.ok) {
|
|
553
553
|
if (showToast && !res?.isOpenApp)
|
|
554
554
|
showSuccessToast({
|
|
555
555
|
title: successMsg,
|
|
556
556
|
});
|
|
557
557
|
} else {
|
|
558
558
|
showToast &&
|
|
559
559
|
showFailToast({
|
|
560
560
|
title: res?.errMsg || failMsg,
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
563
|
return Promise.resolve(res);
|
|
564
564
|
})
|
|
565
565
|
.catch((e) => {
|
|
566
566
|
console.log('调用加购方法异常=======>', e);
|
|
567
567
|
return Promise.resolve({
|
|
568
568
|
ok: false,
|
|
569
569
|
msg: failMsg,
|
|
570
570
|
});
|
|
571
571
|
});
|
|
572
572
|
} else {
|
|
573
573
|
return Promise.resolve({
|
|
574
574
|
ok: false,
|
|
575
575
|
msg: failMsg,
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
async giftCardAddCart(skuList, num) {
|
|
581
581
|
return this.gatewayReq('giftCardAddCart', {
|
|
582
582
|
skuList,
|
|
583
583
|
num: Number(num),
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
588
588
|
return new Promise((resolve) => {
|
|
589
589
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
|
|
590
590
|
if (productIdsArr.length > 0) {
|
|
591
591
|
if (giftCard) {
|
|
592
592
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
593
593
|
.then((res) => {
|
|
594
594
|
if (res?.code === '0' && res?.result?.value) {
|
|
595
595
|
resolve({
|
|
596
596
|
ok: true,
|
|
597
597
|
});
|
|
598
598
|
} else {
|
|
599
599
|
resolve({
|
|
600
600
|
ok: false,
|
|
601
601
|
msg: '加购失败,请稍后重试',
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
604
|
})
|
|
605
605
|
.catch((e) => {
|
|
606
606
|
console.error('礼品卡加车失败: ', e);
|
|
607
607
|
resolve({
|
|
608
608
|
ok: false,
|
|
609
609
|
msg: '加购失败,请稍后重试',
|
|
610
610
|
});
|
|
611
611
|
});
|
|
612
612
|
} else if (isJdApp) {
|
|
613
613
|
console.log('==========>', 'app原生批量加车!,小程序端暂不涉及');
|
|
614
614
|
} else if (isMin) {
|
|
615
615
|
console.log('==========>', '京购批量加车!');
|
|
616
616
|
let singleSkuAdParams;
|
|
617
617
|
if (productIdsArr.length === 1) {
|
|
618
618
|
const adInfos = getAdInfoBySkuId(productIdsArr[0]);
|
|
619
619
|
if (adInfos) {
|
|
620
620
|
singleSkuAdParams = {
|
|
621
621
|
addExtendParams: adInfos,
|
|
622
622
|
skuId: Number(productIdsArr[0]),
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
627
627
|
return {
|
|
628
628
|
skuId: skuItem,
|
|
629
629
|
buyNum: addCardNum,
|
|
630
630
|
};
|
|
631
631
|
});
|
|
632
632
|
global.wxAppBizInstance
|
|
633
633
|
.addCart({
|
|
634
634
|
...(singleSkuAdParams ? singleSkuAdParams : { commArr: productsAddCartList }),
|
|
635
635
|
})
|
|
636
636
|
.then((res) => {
|
|
637
637
|
console.log('dealCartSuccess: ', res);
|
|
638
638
|
resolve({
|
|
639
639
|
ok: true,
|
|
640
640
|
msg: '已加入购物车!',
|
|
641
641
|
data: res,
|
|
642
642
|
});
|
|
643
643
|
})
|
|
644
644
|
.catch((e) => {
|
|
645
645
|
console.log('京购小程序批量加车失败dealCartFail: ', e);
|
|
646
646
|
resolve({
|
|
647
647
|
ok: false,
|
|
648
648
|
msg: '加购失败,请稍后重试',
|
|
649
649
|
});
|
|
650
650
|
});
|
|
651
651
|
} else {
|
|
652
652
|
console.log('==========>', 'M站批量加车!');
|
|
653
653
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
|
|
654
654
|
}
|
|
655
655
|
} else {
|
|
656
656
|
resolve({
|
|
657
657
|
ok: false,
|
|
658
658
|
msg: '加购sku不能为空',
|
|
659
659
|
});
|
|
660
660
|
}
|
|
661
661
|
});
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
productAddToCart() {
|
|
665
665
|
return Promise.resolve({
|
|
666
666
|
ok: false,
|
|
667
667
|
msg: 'productAddToCart暂不支持小程序',
|
|
668
668
|
});
|
|
669
669
|
}
|
|
670
670
|
bMallGetUserInfo() {
|
|
671
671
|
return Promise.resolve({
|
|
672
672
|
ok: false,
|
|
673
673
|
msg: 'productAddToCart暂不支持小程序',
|
|
674
674
|
});
|
|
675
675
|
}
|
|
676
676
|
bMallGetSkuNumApi() {
|
|
677
677
|
return Promise.resolve({
|
|
678
678
|
ok: false,
|
|
679
679
|
msg: 'productAddToCart暂不支持小程序',
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
bMallCartHandle() {
|
|
683
683
|
return Promise.resolve({
|
|
684
684
|
ok: false,
|
|
685
685
|
msg: 'productAddToCart暂不支持小程序',
|
|
686
686
|
});
|
|
687
687
|
}
|