@conecli/cone-render 0.10.1-shop3.6 → 0.10.1-shop3.7
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/index.h5.ts +1 -1
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -0
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/jumpExtMapUtil.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
|
APPID,
|
|
1
3
|
JshopxColorFunctionIdList,
|
|
2
4
|
PagesColorFunctionIdList,
|
|
3
5
|
PAGES_DOMAIN,
|
|
4
6
|
B2BColorFunctionIdList,
|
|
5
7
|
MobileVerifyColorList,
|
|
6
8
|
AppVerifyColorList,
|
|
7
9
|
JshopxVerifyColorList,
|
|
8
10
|
BMallVerifyColorList,
|
|
9
11
|
shopMemberColorFunctionIdList,
|
|
10
12
|
isLanguageForEn,
|
|
11
13
|
isJdApp,
|
|
12
14
|
showSuccessToast,
|
|
13
15
|
showFailToast,
|
|
14
16
|
isH5,
|
|
15
17
|
isWxMinAndWxapp,
|
|
16
18
|
isMin,
|
|
17
19
|
isPc,
|
|
18
20
|
cookiesStr: '',
|
|
19
21
|
requestHeaderContentType: {
|
|
20
22
|
jsonHeader: {
|
|
21
23
|
'content-type': 'application/json;charset=utf-8',
|
|
22
24
|
},
|
|
23
25
|
formDataHeader: {
|
|
24
26
|
'content-type': 'application/x-www-form-urlencoded',
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
requestBaseParam: {
|
|
28
30
|
data: null,
|
|
29
31
|
header: {
|
|
30
32
|
'content-type': 'application/json;charset=utf-8',
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
timeOut: 7000,
|
|
34
36
|
apiClientParams: {
|
|
35
37
|
appid: 'wx_mini_app',
|
|
36
38
|
clientVersion: '11.0.0',
|
|
37
39
|
client: 'wh5',
|
|
38
40
|
area: '1_72_2799_0',
|
|
39
41
|
screen: `${Math.ceil(getSystemInfo?.screenWidth * devicePixelRatio)}*${Math.ceil(
|
|
40
42
|
getSystemInfo?.screenHeight * devicePixelRatio,
|
|
41
43
|
)}`,
|
|
42
44
|
uuid: UUID,
|
|
43
45
|
loginType: '11',
|
|
44
46
|
},
|
|
45
47
|
public addressFetchInfo: {
|
|
46
48
|
reqState: boolean;
|
|
47
49
|
promiseInstance: null | Promise<any>;
|
|
48
50
|
};
|
|
49
51
|
public getPromotionConfig: {
|
|
50
52
|
projectId: null | string | number;
|
|
51
53
|
pageId: null | string | number;
|
|
52
54
|
};
|
|
53
55
|
public resInfo: ServiceInterFace.HttpRequestInfo;
|
|
54
56
|
public api: ServiceInterFace.HttpApi;
|
|
55
57
|
public isPageDomain: boolean;
|
|
56
58
|
public verifyColorList: string[];
|
|
57
59
|
constructor(opt) {
|
|
58
60
|
this._init();
|
|
59
61
|
this.addressFetchInfo = {
|
|
60
62
|
reqState: false,
|
|
61
63
|
promiseInstance: null,
|
|
62
64
|
};
|
|
63
65
|
this.getPromotionConfig = {
|
|
64
66
|
projectId: null,
|
|
65
67
|
pageId: null,
|
|
66
68
|
};
|
|
67
69
|
this._userAreaUpdateListen();
|
|
68
70
|
this.resInfo = this._getResConfig(opt);
|
|
69
71
|
this.api = api;
|
|
70
72
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
|
|
71
73
|
this.verifyColorList = [
|
|
72
74
|
...MobileVerifyColorList,
|
|
73
75
|
...AppVerifyColorList,
|
|
74
76
|
...JshopxVerifyColorList,
|
|
75
77
|
...BMallVerifyColorList,
|
|
76
78
|
];
|
|
77
79
|
}
|
|
78
80
|
_init(): void {
|
|
79
81
|
httpInterceptors.forEach((item) => {
|
|
80
82
|
Taro.addInterceptor((chain) => item(chain));
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
84
86
|
return Object.assign({}, DefaultConfig, opt);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
_userAreaUpdateListen() {
|
|
88
90
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
89
91
|
this.updateApiClientParamsResInfo({
|
|
90
92
|
area,
|
|
91
93
|
});
|
|
92
94
|
});
|
|
93
95
|
}
|
|
94
96
|
updateApiClientParamsResInfo(opt = {}) {
|
|
95
97
|
this.resInfo.apiClientParams = {
|
|
96
98
|
...this.resInfo.apiClientParams,
|
|
97
99
|
...opt,
|
|
98
100
|
};
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
checkFunctionIdToReturnAppId(functionId) {
|
|
102
104
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
103
105
|
return APPID.JSHOPX_COLOR_APPID;
|
|
104
106
|
} else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
|
|
105
107
|
return APPID.PAGES_COLOR_APPID;
|
|
106
108
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
107
109
|
return APPID.SHOP_MEMBER_COLOR_APPID;
|
|
108
110
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
109
111
|
return APPID.B2B_COLOR_APPID;
|
|
110
112
|
} else if (isPc) {
|
|
111
113
|
return APPID.MALL_COLOR_APPID;
|
|
112
114
|
} else {
|
|
113
115
|
return APPID.SHOP_COLOR_APPID;
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
|
|
118
120
|
if (
|
|
119
121
|
functionId === 'receiveShopCoupon'
|
|
120
122
|
) {
|
|
121
123
|
clientParams = Object.assign(
|
|
122
124
|
{},
|
|
123
125
|
{
|
|
124
126
|
loginType: '1',
|
|
125
127
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
126
128
|
},
|
|
127
129
|
clientParams,
|
|
128
130
|
);
|
|
129
131
|
}
|
|
130
132
|
const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
|
|
131
133
|
const isColorVerify = this.verifyColorList.includes(functionId);
|
|
132
134
|
const getReqData = {
|
|
133
135
|
functionId: functionId,
|
|
134
136
|
body: JSON.stringify(bodyParams),
|
|
135
137
|
t: Date.now(),
|
|
136
138
|
...apiClientParams,
|
|
137
139
|
};
|
|
138
140
|
return http
|
|
139
141
|
.request({
|
|
140
142
|
url: this.api.apiFunc,
|
|
141
143
|
data: getReqData,
|
|
142
144
|
isColorVerify,
|
|
143
145
|
})
|
|
144
146
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
145
147
|
const { statusCode, data } = res;
|
|
146
148
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
147
149
|
ok: true,
|
|
148
150
|
};
|
|
149
151
|
if (statusCode === 200 && data) {
|
|
150
152
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
151
153
|
? Number(res.data.code)
|
|
152
154
|
: -1;
|
|
153
155
|
const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
|
|
154
156
|
? Number(res.data.subCode)
|
|
155
157
|
: -1;
|
|
156
158
|
if (
|
|
157
159
|
data.success === true ||
|
|
158
160
|
data.isSuccess ||
|
|
159
161
|
resCode === 0 ||
|
|
160
162
|
resCode === 200 ||
|
|
161
163
|
subCode === 0
|
|
162
164
|
) {
|
|
163
165
|
changeRes = {
|
|
164
166
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
165
167
|
? data.result
|
|
166
168
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
167
169
|
? data.data
|
|
168
170
|
: data,
|
|
169
171
|
code: data.code || 200,
|
|
170
172
|
ok: true,
|
|
171
173
|
source: data,
|
|
172
174
|
};
|
|
173
175
|
return changeRes;
|
|
174
176
|
} else {
|
|
175
177
|
changeRes = {
|
|
176
178
|
...data,
|
|
177
179
|
ok: false,
|
|
178
180
|
statusCode: res.statusCode,
|
|
179
181
|
};
|
|
180
182
|
return changeRes;
|
|
181
183
|
}
|
|
182
184
|
} else {
|
|
183
185
|
changeRes = {
|
|
184
186
|
...data,
|
|
185
187
|
ok: false,
|
|
186
188
|
statusCode: res.statusCode,
|
|
187
189
|
};
|
|
188
190
|
return changeRes;
|
|
189
191
|
}
|
|
190
192
|
})
|
|
191
193
|
.catch((res) => {
|
|
192
194
|
return {
|
|
193
195
|
...res,
|
|
194
196
|
ok: false,
|
|
195
197
|
} as ServiceInterFace.RequestResponseFormatRes;
|
|
196
198
|
});
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
async receiveCoupon(param = {}, clientParams) {
|
|
200
202
|
console.warn("receiveCoupon 方法在微信京购小程序环境未经验证,请不要使用!")
|
|
201
203
|
return await this.gatewayReq(
|
|
202
204
|
'receiveShopCoupon',
|
|
203
205
|
{
|
|
204
206
|
operation: '3',
|
|
205
207
|
...param,
|
|
206
208
|
},
|
|
207
209
|
{ ...clientParams },
|
|
208
210
|
);
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
getCustomerCenterDispatch(params = {}) {
|
|
212
214
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
213
215
|
clientVersion: '9.2.0',
|
|
214
216
|
client: 'H5',
|
|
215
217
|
uuid: 88888,
|
|
216
218
|
appid: 'shopmember_m_jd_com',
|
|
217
219
|
});
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
batchAddCart(...args) {
|
|
221
223
|
let skuIds, num, showToast, giftCard;
|
|
222
224
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
223
225
|
[skuIds, num = 1, showToast = true, giftCard = false] = args;
|
|
224
226
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
225
227
|
const params = args[0];
|
|
226
228
|
skuIds = params.skuIds;
|
|
227
229
|
num = params.num || 1;
|
|
228
230
|
showToast = params.showToast !== undefined ? params.showToast : true;
|
|
229
231
|
giftCard = params.giftCard !== undefined ? params.giftCard : false;
|
|
230
232
|
} else {
|
|
231
233
|
console.error('batchAddCart() Invalid arguments!', args)
|
|
232
234
|
const msg = isLanguageForEn? 'Please retry later': '加入购物车失败,请稍后重试!'
|
|
233
235
|
showFailToast({
|
|
234
236
|
title: msg,
|
|
235
237
|
});
|
|
236
238
|
return Promise.resolve({
|
|
237
239
|
ok: false,
|
|
238
240
|
msg,
|
|
239
241
|
});
|
|
240
242
|
}
|
|
241
243
|
const addToWhereText = giftCard? '购物清单': '购物车'
|
|
242
244
|
const successMsg = isLanguageForEn? 'Success': `加入${addToWhereText}成功`
|
|
243
245
|
const failMsg = isLanguageForEn? 'Please retry later': `加入${addToWhereText}失败,请稍后重试!`
|
|
244
246
|
if (skuIds) {
|
|
245
247
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, {giftCard})
|
|
246
248
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
247
249
|
if (res?.ok) {
|
|
248
250
|
if (showToast && !res?.isOpenApp)
|
|
249
251
|
showSuccessToast({
|
|
250
252
|
title: successMsg,
|
|
251
253
|
})
|
|
252
254
|
} else {
|
|
253
255
|
showToast &&
|
|
254
256
|
showFailToast({
|
|
255
257
|
title: res?.errMsg || failMsg,
|
|
256
258
|
})
|
|
257
259
|
}
|
|
258
260
|
return Promise.resolve(res);
|
|
259
261
|
})
|
|
260
262
|
.catch((e) => {
|
|
261
263
|
console.log('调用加购方法异常=======>', e);
|
|
262
264
|
return Promise.resolve({
|
|
263
265
|
ok: false,
|
|
264
266
|
msg: failMsg,
|
|
265
267
|
})
|
|
266
268
|
})
|
|
267
269
|
} else {
|
|
268
270
|
return Promise.resolve({
|
|
269
271
|
ok: false,
|
|
270
272
|
msg: failMsg,
|
|
271
273
|
})
|
|
272
274
|
}
|
|
273
275
|
}
|
|
274
276
|
return this.gatewayReq(
|
|
275
277
|
'giftCardAddCart',
|
|
276
278
|
{
|
|
277
279
|
skuList,
|
|
278
280
|
num: Number(num)
|
|
279
281
|
},
|
|
280
282
|
);
|
|
281
283
|
}
|
|
282
284
|
|
|
283
285
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', {giftCard}) {
|
|
284
286
|
return new Promise((resolve) => {
|
|
285
287
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
|
|
286
288
|
if (productIdsArr.length > 0) {
|
|
287
289
|
if(giftCard){
|
|
288
290
|
this.giftCardAddCart(productIdsArr, addCardNum).then((res) => {
|
|
289
291
|
if(res?.code === '0' && res?.result?.value){
|
|
290
292
|
resolve({
|
|
291
293
|
ok: true,
|
|
292
294
|
})
|
|
293
295
|
}else{
|
|
294
296
|
resolve({
|
|
295
297
|
ok: false,
|
|
296
298
|
msg: '加购失败,请稍后重试',
|
|
297
299
|
});
|
|
298
300
|
}
|
|
299
301
|
}).catch((e) => {
|
|
300
302
|
console.error('礼品卡加车失败: ', e);
|
|
301
303
|
resolve({
|
|
302
304
|
ok: false,
|
|
303
305
|
msg: '加购失败,请稍后重试',
|
|
304
306
|
});
|
|
305
307
|
});
|
|
306
308
|
}else if (isJdApp) {
|
|
307
309
|
console.log('==========>', 'app原生批量加车!,小程序端暂不涉及')
|
|
308
310
|
} else if (isMin) {
|
|
309
311
|
console.log('==========>', '京购批量加车!');
|
|
310
312
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
311
313
|
return {
|
|
312
314
|
skuId: skuItem,
|
|
313
315
|
buyNum: addCardNum,
|
|
314
316
|
};
|
|
315
317
|
});
|
|
316
318
|
global.wxAppBizInstance
|
|
317
319
|
.addCart({ commArr: productsAddCartList })
|
|
318
320
|
.then((res) => {
|
|
319
321
|
console.log('dealCartSuccess: ', res);
|
|
320
322
|
resolve({
|
|
321
323
|
ok: true,
|
|
322
324
|
msg: '已加入购物车!',
|
|
323
325
|
data: res,
|
|
324
326
|
});
|
|
325
327
|
})
|
|
326
328
|
.catch((e) => {
|
|
327
329
|
console.log('京购小程序批量加车失败dealCartFail: ', e);
|
|
328
330
|
resolve({
|
|
329
331
|
ok: false,
|
|
330
332
|
msg: '加购失败,请稍后重试',
|
|
331
333
|
});
|
|
332
334
|
});
|
|
333
335
|
} else {
|
|
334
336
|
console.log('==========>', 'M站批量加车!');
|
|
335
337
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
|
|
336
338
|
}
|
|
337
339
|
} else {
|
|
338
340
|
resolve({
|
|
339
341
|
ok: false,
|
|
340
342
|
msg: '加购sku不能为空',
|
|
341
343
|
});
|
|
342
344
|
}
|
|
343
345
|
});
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
productAddToCart() {
|
|
347
349
|
return Promise.resolve({
|
|
348
350
|
ok: false,
|
|
349
351
|
msg: 'productAddToCart暂不支持小程序',
|
|
350
352
|
});
|
|
351
353
|
}
|
|
352
354
|
bMallGetUserInfo = () => {
|
|
353
355
|
return getBMallUserInfo();
|
|
354
356
|
};
|
|
355
357
|
async bMallAddCart(params = {}) {
|
|
356
358
|
console.warn("bMallAddCart 方法在微信京购小程序环境未经验证,请不要使用!")
|
|
357
359
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
358
360
|
client: 'H5',
|
|
359
361
|
clientVersion: '5.5.0',
|
|
360
362
|
});
|
|
361
363
|
}
|
|
362
364
|
async bMallChangeCart(params = {}) {
|
|
363
365
|
console.warn("bMallChangeCart 方法在微信京购小程序环境未经验证,请不要使用!")
|
|
364
366
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
365
367
|
client: 'H5',
|
|
366
368
|
clientVersion: '5.5.0',
|
|
367
369
|
});
|
|
368
370
|
}
|
|
369
371
|
async bMallRemoveCart(params = {}) {
|
|
370
372
|
console.warn("bMallRemoveCart 方法在微信京购小程序环境未经验证,请不要使用!")
|
|
371
373
|
return await this.gatewayReq(
|
|
372
374
|
'bmall_cartRemove',
|
|
373
375
|
params,
|
|
374
376
|
{
|
|
375
377
|
client: 'H5',
|
|
376
378
|
clientVersion: '5.5.0',
|
|
377
379
|
},
|
|
378
380
|
);
|
|
379
381
|
}
|
|
380
382
|
async bMallGetOmittedProduct(params = {}) {
|
|
381
383
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
382
384
|
client: 'H5',
|
|
383
385
|
clientVersion: '5.5.0',
|
|
384
386
|
});
|
|
385
387
|
}
|
|
386
388
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
387
389
|
const params = await getParams({ ...data, skuId, bMallTag, num });
|
|
388
390
|
return await this.bMallAddCart(params);
|
|
389
391
|
}
|
|
390
392
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
391
393
|
const params = await getParams({ bMallTag });
|
|
392
394
|
delete params.operations;
|
|
393
395
|
return await this.bMallGetOmittedProduct(params);
|
|
394
396
|
}
|
|
395
397
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
396
398
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
397
399
|
return await this.bMallRemoveCart(params);
|
|
398
400
|
}
|
|
399
401
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
400
402
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
401
403
|
return await this.bMallChangeCart(params);
|
|
402
404
|
}
|
|
403
405
|
|
|
404
406
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
405
407
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
406
408
|
return window?.bMallCartData;
|
|
407
409
|
}
|
|
408
410
|
const cartData = await this.bMallGetSkuNumService(bMallTag);
|
|
409
411
|
let items;
|
|
410
412
|
if (cartData.ok && cartData.result) {
|
|
411
413
|
items = cartData?.result?.items || {};
|
|
412
414
|
}
|
|
413
415
|
if (isH5) {
|
|
414
416
|
window.bMallCartData = items;
|
|
415
417
|
}
|
|
416
418
|
return items;
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
async bMallCartHandle(goodItem, num) {
|
|
420
422
|
try {
|
|
421
423
|
const {
|
|
422
424
|
skuUuid,
|
|
423
425
|
limitUpper,
|
|
424
426
|
limitLower,
|
|
425
427
|
} = goodItem;
|
|
426
428
|
let cartNum = Number(num);
|
|
427
429
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
428
430
|
cartNum = limitLower;
|
|
429
431
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
430
432
|
cartNum = limitUpper;
|
|
431
433
|
}
|
|
432
434
|
if (skuUuid && cartNum > 0) {
|
|
433
435
|
return this.bMallChangeCartService({
|
|
434
436
|
...goodItem,
|
|
435
437
|
skuUuid,
|
|
436
438
|
num: cartNum,
|
|
437
439
|
});
|
|
438
440
|
} else if (!skuUuid && cartNum > 0) {
|
|
439
441
|
return this.bMallAddCartService({ ...goodItem, num: cartNum });
|
|
440
442
|
} else if (skuUuid && !cartNum) {
|
|
441
443
|
return this.bMallRemoveCartService({
|
|
442
444
|
...goodItem,
|
|
443
445
|
skuUuid,
|
|
444
446
|
num: cartNum,
|
|
445
447
|
});
|
|
446
448
|
} else {
|
|
447
449
|
console.error('参数不全');
|
|
448
450
|
return false;
|
|
449
451
|
}
|
|
450
452
|
} catch (e) {
|
|
451
453
|
console.error(e);
|
|
452
454
|
}
|
|
453
455
|
}
|