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