@conecli/cone-render 0.10.1-beta.5 → 0.10.1-beta.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/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/index.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/pageType.ts +1 -1
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/components/base/CountDown/index.module.scss +49 -44
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomVideo/common.ts +1 -0
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +11 -6
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.module.scss +8 -0
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/isv/Floor/index.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/index.jd.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.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.jdb.ts +1 -1
- package/dist/jumpEventReport/web.jdjch.ts +1 -1
- package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
- package/dist/jumpEventReport/web.pc.ts +1 -1
- package/dist/jumpEventReport/web.tjapp.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/sass/base.scss +142 -141
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- package/dist/service/requestServer.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +35 -29
- package/dist/utils/memberFormatUtils.js +0 -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
|
isJdApp,
|
|
11
13
|
isIosDevice,
|
|
12
14
|
isAndroidDevice,
|
|
13
15
|
showSuccessToast,
|
|
14
16
|
showFailToast,
|
|
15
17
|
isH5,
|
|
16
18
|
isWxMinAndWxapp,
|
|
17
19
|
isMin,
|
|
18
20
|
isPc,
|
|
19
21
|
sgmCustomReport,
|
|
20
22
|
getSgmCustomCode,
|
|
21
23
|
draInterfaceCustomReport,
|
|
22
24
|
callRouterIOS,
|
|
23
25
|
callRouterAndroid,
|
|
24
26
|
cookiesStr: '',
|
|
25
27
|
requestHeaderContentType: {
|
|
26
28
|
jsonHeader: {
|
|
27
29
|
'content-type': 'application/json;charset=utf-8',
|
|
28
30
|
},
|
|
29
31
|
formDataHeader: {
|
|
30
32
|
'content-type': 'application/x-www-form-urlencoded',
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
requestBaseParam: {
|
|
34
36
|
data: null,
|
|
35
37
|
header: {
|
|
36
38
|
'content-type': 'application/json;charset=utf-8',
|
|
37
39
|
},
|
|
38
40
|
},
|
|
39
41
|
timeOut: 7000,
|
|
40
42
|
apiClientParams: {
|
|
41
43
|
clientVersion:
|
|
42
44
|
isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
43
45
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
44
46
|
area: '1_72_2799_0',
|
|
45
47
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
|
|
46
48
|
window.screen?.height * devicePixelRatio,
|
|
47
49
|
)}`,
|
|
48
50
|
uuid: UUID,
|
|
49
51
|
},
|
|
50
52
|
public addressFetchInfo: {
|
|
51
53
|
reqState: boolean
|
|
52
54
|
promiseInstance: null | Promise<any>
|
|
53
55
|
}
|
|
54
56
|
public getPromotionConfig: {
|
|
55
57
|
projectId: null | string | number
|
|
56
58
|
pageId: null | string | number
|
|
57
59
|
}
|
|
58
60
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
59
61
|
public api: ServiceInterFace.HttpApi
|
|
60
62
|
public isPageDomain: boolean
|
|
61
63
|
public verifyColorList: string[]
|
|
62
64
|
constructor(opt) {
|
|
63
65
|
this._init()
|
|
64
66
|
this.addressFetchInfo = {
|
|
65
67
|
reqState: false,
|
|
66
68
|
promiseInstance: null,
|
|
67
69
|
}
|
|
68
70
|
this.getPromotionConfig = {
|
|
69
71
|
projectId: null,
|
|
70
72
|
pageId: null,
|
|
71
73
|
}
|
|
72
74
|
this._userAreaUpdateListen()
|
|
73
75
|
this.resInfo = this._getResConfig(opt)
|
|
74
76
|
this.api = api
|
|
75
77
|
this.isPageDomain = isH5
|
|
76
78
|
? window?.location?.hostname === PAGES_DOMAIN
|
|
77
79
|
: false
|
|
78
80
|
this.verifyColorList = [
|
|
79
81
|
...MobileVerifyColorList,
|
|
80
82
|
...AppVerifyColorList,
|
|
81
83
|
...JshopxVerifyColorList,
|
|
82
84
|
...BMallVerifyColorList,
|
|
83
85
|
]
|
|
84
86
|
}
|
|
85
87
|
_init(): void {
|
|
86
88
|
httpInterceptors.forEach((item) => {
|
|
87
89
|
Taro.addInterceptor((chain) => item(chain))
|
|
88
90
|
})
|
|
89
91
|
}
|
|
90
92
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
91
93
|
return Object.assign({}, DefaultConfig, opt)
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
_userAreaUpdateListen() {
|
|
95
97
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
96
98
|
area && area !== "" && this.updateApiClientParamsResInfo({
|
|
97
99
|
area,
|
|
98
100
|
})
|
|
99
101
|
console.log("cone-render收到原生端获取传来的四级地址信息",area,"更新后的接口底层信息", this.resInfo.apiClientParams)
|
|
100
102
|
})
|
|
101
103
|
}
|
|
102
104
|
updateApiClientParamsResInfo(opt = {}) {
|
|
103
105
|
const { area, ...others} = opt
|
|
104
106
|
this.resInfo.apiClientParams = {
|
|
105
107
|
...this.resInfo.apiClientParams,
|
|
106
108
|
...others
|
|
107
109
|
}
|
|
108
110
|
if(area){
|
|
109
111
|
this.resInfo.apiClientParams.area = area
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
checkFunctionIdToReturnAppId(functionId) {
|
|
114
116
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
115
117
|
return APPID.JSHOPX_COLOR_APPID
|
|
116
118
|
} else if (
|
|
117
119
|
this.isPageDomain &&
|
|
118
120
|
PagesColorFunctionIdList.includes(functionId)
|
|
119
121
|
) {
|
|
120
122
|
return APPID.PAGES_COLOR_APPID
|
|
121
123
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
122
124
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
123
125
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
124
126
|
return APPID.B2B_COLOR_APPID
|
|
125
127
|
} else if (isPc) {
|
|
126
128
|
return APPID.MALL_COLOR_APPID
|
|
127
129
|
} else {
|
|
128
130
|
return APPID.SHOP_COLOR_APPID
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
gatewayReq(
|
|
133
135
|
functionId: string,
|
|
134
136
|
bodyParams = {},
|
|
135
137
|
clientParams = {},
|
|
136
138
|
): Promise<any> {
|
|
137
139
|
if (
|
|
138
140
|
functionId === 'receiveShopCoupon' &&
|
|
139
141
|
((isH5 &&
|
|
140
142
|
(window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
|
|
141
143
|
isWxMinAndWxapp)
|
|
142
144
|
) {
|
|
143
145
|
clientParams = Object.assign(
|
|
144
146
|
{},
|
|
145
147
|
{
|
|
146
148
|
loginType: '1',
|
|
147
149
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
148
150
|
},
|
|
149
151
|
clientParams,
|
|
150
152
|
)
|
|
151
153
|
}
|
|
152
154
|
const apiClientParams = Object.assign(
|
|
153
155
|
{},
|
|
154
156
|
this.resInfo.apiClientParams,
|
|
155
157
|
clientParams,
|
|
156
158
|
)
|
|
157
159
|
typeof apiClientParams.appid === 'undefined' &&
|
|
158
160
|
(apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
159
161
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
160
162
|
const getReqData = {
|
|
161
163
|
functionId: functionId,
|
|
162
164
|
body: JSON.stringify(bodyParams),
|
|
163
165
|
t: Date.now(),
|
|
164
166
|
...apiClientParams,
|
|
165
167
|
}
|
|
166
168
|
return http
|
|
167
169
|
.request({
|
|
168
170
|
url: this.api.apiFunc,
|
|
169
171
|
data: getReqData,
|
|
170
172
|
isColorVerify,
|
|
171
173
|
})
|
|
172
174
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
173
175
|
const { statusCode, data, status, msg } = res
|
|
174
176
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
175
177
|
ok: true,
|
|
176
178
|
}
|
|
177
179
|
if ((statusCode === 200 || status === '0') && data) {
|
|
178
180
|
changeRes = this.dealResponseFormatRes(data)
|
|
179
181
|
return changeRes
|
|
180
182
|
} else {
|
|
181
183
|
changeRes = {
|
|
182
184
|
...data,
|
|
183
185
|
statusCode,
|
|
184
186
|
status,
|
|
185
187
|
msg,
|
|
186
188
|
ok: false,
|
|
187
189
|
}
|
|
188
190
|
return changeRes
|
|
189
191
|
}
|
|
190
192
|
})
|
|
191
193
|
.catch((res) => {
|
|
192
194
|
const propertyNames = Object.getOwnPropertyNames(res);
|
|
193
195
|
const resObject = {};
|
|
194
196
|
propertyNames.forEach((propertyName) => {
|
|
195
197
|
resObject[propertyName] = res[propertyName];
|
|
196
198
|
});
|
|
197
199
|
draInterfaceCustomReport({
|
|
198
200
|
subMsg:
|
|
199
201
|
'接口请求异常,进入catch逻辑,例如h5请求神盾(反爬、小号、风控)或加固拦截返回status为403等',
|
|
200
202
|
url: this.api.apiFunc,
|
|
201
203
|
source: 'remote',
|
|
202
204
|
requestType: res?.requestType,
|
|
203
205
|
errorType: 'catchError',
|
|
204
206
|
functionId: getReqData?.functionId,
|
|
205
207
|
appid: getReqData?.appid,
|
|
206
208
|
client: getReqData?.client,
|
|
207
209
|
clientVersion: getReqData?.clientVersion,
|
|
208
210
|
statusCode: res?.statusCode,
|
|
209
211
|
status: res?.status,
|
|
210
212
|
statusText: res?.statusText,
|
|
211
213
|
code: res?.data?.code || res?.data?.subCode,
|
|
212
214
|
errMsg: res?.errMsg || res?.msg || res?.message || res?.data?.echo,
|
|
213
215
|
originReqDataStr: JSON.stringify(getReqData),
|
|
214
216
|
originResDataStr: JSON.stringify(res, propertyNames),
|
|
215
217
|
});
|
|
216
218
|
return {
|
|
217
219
|
...resObject,
|
|
218
220
|
ok: false,
|
|
219
221
|
} as ServiceInterFace.RequestResponseFormatRes;
|
|
220
222
|
})
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
dealResponseFormatRes(data) {
|
|
224
226
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
225
227
|
ok: true,
|
|
226
228
|
}
|
|
227
229
|
const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
|
|
228
230
|
? Number(data.code)
|
|
229
231
|
: -1
|
|
230
232
|
const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
|
|
231
233
|
? Number(data.subCode)
|
|
232
234
|
: -1
|
|
233
235
|
if (
|
|
234
236
|
data.success === true ||
|
|
235
237
|
data.isSuccess ||
|
|
236
238
|
resCode === 0 ||
|
|
237
239
|
resCode === 200 ||
|
|
238
240
|
subCode === 0
|
|
239
241
|
) {
|
|
240
242
|
changeRes = {
|
|
241
243
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
242
244
|
? data.result
|
|
243
245
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
244
246
|
? data.data
|
|
245
247
|
: data,
|
|
246
248
|
code: data.code ?? 200,
|
|
247
249
|
ok: true,
|
|
248
250
|
source: data,
|
|
249
251
|
}
|
|
250
252
|
return changeRes
|
|
251
253
|
} else {
|
|
252
254
|
changeRes = {
|
|
253
255
|
...data,
|
|
254
256
|
ok: false,
|
|
255
257
|
}
|
|
256
258
|
return changeRes
|
|
257
259
|
}
|
|
258
260
|
}
|
|
259
261
|
|
|
260
262
|
async receiveCoupon(param = {}, clientParams) {
|
|
261
263
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
262
264
|
return await this.gatewayReq(
|
|
263
265
|
'receiveShopCoupon',
|
|
264
266
|
{
|
|
265
267
|
operation: '3',
|
|
266
268
|
...param,
|
|
267
269
|
},
|
|
268
270
|
{ ...loginType, ...clientParams },
|
|
269
271
|
)
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
getCustomerCenterDispatch(params = {}) {
|
|
273
275
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
274
276
|
clientVersion: '9.2.0',
|
|
275
277
|
client: 'H5',
|
|
276
278
|
uuid: 88888,
|
|
277
279
|
appid: 'shopmember_m_jd_com',
|
|
278
280
|
})
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
batchAddCart(skuIdsStr, num = 1, showToast = true) {
|
|
282
284
|
if (skuIdsStr) {
|
|
283
285
|
return this._addShopGoodCart(`${skuIdsStr}`, `${num}`)
|
|
284
286
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
285
287
|
if (res?.ok) {
|
|
286
288
|
if (showToast && !res?.isOpenApp)
|
|
287
289
|
showSuccessToast({
|
|
288
290
|
title: '加入购物车成功',
|
|
289
291
|
})
|
|
290
292
|
} else {
|
|
291
293
|
showToast &&
|
|
292
294
|
showFailToast({
|
|
293
295
|
title: res?.errMsg || '加入购物车失败,请稍后重试!',
|
|
294
296
|
})
|
|
295
297
|
}
|
|
296
298
|
return Promise.resolve(res)
|
|
297
299
|
})
|
|
298
300
|
.catch((e) => {
|
|
299
301
|
console.log('调用加购方法异常=======>', e)
|
|
300
302
|
return Promise.resolve({
|
|
301
303
|
ok: false,
|
|
302
304
|
msg: '加入购物车失败,请稍后重试!',
|
|
303
305
|
})
|
|
304
306
|
})
|
|
305
307
|
} else {
|
|
306
308
|
return Promise.resolve({
|
|
307
309
|
ok: false,
|
|
308
310
|
msg: '加入购物车失败,请稍后重试!',
|
|
309
311
|
})
|
|
310
312
|
}
|
|
311
313
|
}
|
|
312
314
|
|
|
313
315
|
_addShopGoodCart(skuIdsStr, addCardNum = '1') {
|
|
314
316
|
return new Promise((resolve) => {
|
|
315
317
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
316
318
|
if (productIdsArr.length > 0) {
|
|
317
319
|
if (isJdApp) {
|
|
318
320
|
console.log('==========>', '原生批量加车!')
|
|
319
321
|
const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`
|
|
320
322
|
if (!window[nativeAddCartCallBack]) {
|
|
321
323
|
window[nativeAddCartCallBack] = (res) => {
|
|
322
324
|
const getMessageJsonData =
|
|
323
325
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
324
326
|
console.info(
|
|
325
327
|
'获取批量加车原始数据',
|
|
326
328
|
res,
|
|
327
329
|
'====转换后的json数据为===',
|
|
328
330
|
getMessageJsonData,
|
|
329
331
|
)
|
|
330
332
|
try {
|
|
331
333
|
if (isAndroidDevice) {
|
|
332
334
|
getMessageJsonData?.status === '0'
|
|
333
335
|
? resolve({
|
|
334
336
|
ok: true,
|
|
335
337
|
msg: '已加入购物车!',
|
|
336
338
|
})
|
|
337
339
|
: resolve({
|
|
338
340
|
ok: false,
|
|
339
341
|
msg: '加购失败,请稍后重试',
|
|
340
342
|
})
|
|
341
343
|
} else if (isIosDevice) {
|
|
342
344
|
getMessageJsonData?.status === '0' &&
|
|
343
345
|
getMessageJsonData?.data?.code === 0
|
|
344
346
|
? resolve({
|
|
345
347
|
ok: true,
|
|
346
348
|
msg: '已加入购物车!',
|
|
347
349
|
})
|
|
348
350
|
: resolve({
|
|
349
351
|
ok: false,
|
|
350
352
|
msg: '批量加车失败,请稍后重试',
|
|
351
353
|
})
|
|
352
354
|
} else {
|
|
353
355
|
resolve({
|
|
354
356
|
ok: false,
|
|
355
357
|
msg: '加购失败,请稍后重试',
|
|
356
358
|
})
|
|
357
359
|
}
|
|
358
360
|
} catch (e) {
|
|
359
361
|
resolve({
|
|
360
362
|
ok: false,
|
|
361
363
|
msg: '加购失败,请稍后重试',
|
|
362
364
|
})
|
|
363
365
|
console.warn('批量加车转换数据异常', e)
|
|
364
366
|
}
|
|
365
367
|
window[nativeAddCartCallBack] = null
|
|
366
368
|
}
|
|
367
369
|
}
|
|
368
370
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
369
371
|
return isAndroidDevice
|
|
370
372
|
? {
|
|
371
373
|
sku: skuItem,
|
|
372
374
|
num: addCardNum,
|
|
373
375
|
}
|
|
374
376
|
: {
|
|
375
377
|
productCode: skuItem,
|
|
376
378
|
buyCount: addCardNum,
|
|
377
379
|
}
|
|
378
380
|
})
|
|
379
381
|
if (isAndroidDevice) {
|
|
380
382
|
const androidProductsStr = JSON.stringify(productsAddCartList)
|
|
381
383
|
callRouterAndroid({
|
|
382
384
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
|
|
383
385
|
routerParam: {
|
|
384
386
|
wareList: productsAddCartList,
|
|
385
387
|
},
|
|
386
388
|
callBackName: nativeAddCartCallBack,
|
|
387
389
|
})
|
|
388
390
|
} else if (isIosDevice) {
|
|
389
391
|
if (isLowAppVer) {
|
|
390
392
|
const lowVersionAppList = productIdsArr.map((skuItem) => {
|
|
391
393
|
return {
|
|
392
394
|
sku: skuItem,
|
|
393
395
|
num: addCardNum,
|
|
394
396
|
}
|
|
395
397
|
})
|
|
396
398
|
const lowVersionAppListStr = JSON.stringify(lowVersionAppList)
|
|
397
399
|
const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`
|
|
398
400
|
jump.side.jdJumpToWeb(url, {})
|
|
399
401
|
resolve({
|
|
400
402
|
ok: true,
|
|
401
403
|
isOpenApp: true,
|
|
402
404
|
msg: '加购完成, 加购结果请点击购物车确认',
|
|
403
405
|
})
|
|
404
406
|
} else {
|
|
405
407
|
callRouterIOS({
|
|
406
408
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
407
409
|
routerParam: {
|
|
408
410
|
sourceType: 'h5',
|
|
409
411
|
sourceValue: '店铺批量加购',
|
|
410
412
|
businessName: 'storeModel',
|
|
411
413
|
isNewMode: '1',
|
|
412
414
|
NotPassWebview: '1',
|
|
413
415
|
products: productsAddCartList,
|
|
414
416
|
},
|
|
415
417
|
callBackName: nativeAddCartCallBack,
|
|
416
418
|
})
|
|
417
419
|
}
|
|
418
420
|
}
|
|
419
421
|
} else if (isMin) {
|
|
420
422
|
console.log('==========>', '京购批量加车!')
|
|
421
423
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
422
424
|
return {
|
|
423
425
|
skuId: skuItem,
|
|
424
426
|
buyNum: addCardNum,
|
|
425
427
|
}
|
|
426
428
|
})
|
|
427
429
|
global.wxAppBizInstance
|
|
428
430
|
.addCart({ commArr: productsAddCartList })
|
|
429
431
|
.then((res) => {
|
|
430
432
|
console.log('dealCartSuccess: ', res)
|
|
431
433
|
resolve({
|
|
432
434
|
ok: true,
|
|
433
435
|
msg: '已加入购物车!',
|
|
434
436
|
data: res,
|
|
435
437
|
})
|
|
436
438
|
})
|
|
437
439
|
.catch((e) => {
|
|
438
440
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
439
441
|
resolve({
|
|
440
442
|
ok: false,
|
|
441
443
|
msg: '加购失败,请稍后重试',
|
|
442
444
|
})
|
|
443
445
|
})
|
|
444
446
|
} else {
|
|
445
447
|
console.log('==========>', 'M站批量加车!')
|
|
446
448
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) =>
|
|
447
449
|
resolve(res),
|
|
448
450
|
)
|
|
449
451
|
}
|
|
450
452
|
} else {
|
|
451
453
|
resolve({
|
|
452
454
|
ok: false,
|
|
453
455
|
msg: '加购sku不能为空',
|
|
454
456
|
})
|
|
455
457
|
}
|
|
456
458
|
})
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
productAddToCart(skuIdsStr, num) {
|
|
460
462
|
return new Promise((resolve) => {
|
|
461
463
|
if (window.AddcartToolObj) {
|
|
462
464
|
window.AddcartToolObj.addCart({
|
|
463
465
|
skuId: skuIdsStr,
|
|
464
466
|
num,
|
|
465
467
|
source: 'sjdpyw',
|
|
466
468
|
actId: '1',
|
|
467
469
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
468
470
|
sucFun(res) {
|
|
469
471
|
console.log(
|
|
470
472
|
'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
|
|
471
473
|
res,
|
|
472
474
|
)
|
|
473
475
|
if (res.errId === '0' && res.cartJson) {
|
|
474
476
|
resolve({
|
|
475
477
|
ok: true,
|
|
476
478
|
msg: '已加入购物车!',
|
|
477
479
|
...res,
|
|
478
480
|
})
|
|
479
481
|
} else {
|
|
480
482
|
if (res.errId === '13') {
|
|
481
483
|
global.doLogin()
|
|
482
484
|
} else {
|
|
483
485
|
resolve({
|
|
484
486
|
ok: false,
|
|
485
487
|
msg: '加购失败,请稍后重试',
|
|
486
488
|
...res,
|
|
487
489
|
})
|
|
488
490
|
}
|
|
489
491
|
}
|
|
490
492
|
},
|
|
491
493
|
failFun(err) {
|
|
492
494
|
console.log('fail', err)
|
|
493
495
|
resolve({
|
|
494
496
|
ok: false,
|
|
495
497
|
msg: '加购失败,请稍后重试',
|
|
496
498
|
...err,
|
|
497
499
|
})
|
|
498
500
|
},
|
|
499
501
|
})
|
|
500
502
|
} else {
|
|
501
503
|
resolve({
|
|
502
504
|
ok: false,
|
|
503
505
|
msg: '购物车方法检查异常',
|
|
504
506
|
})
|
|
505
507
|
}
|
|
506
508
|
})
|
|
507
509
|
}
|
|
508
510
|
bMallGetUserInfo = () => {
|
|
509
511
|
return getBMallUserInfo()
|
|
510
512
|
}
|
|
511
513
|
async bMallAddCart(params = {}) {
|
|
512
514
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
513
515
|
client: 'H5',
|
|
514
516
|
clientVersion: '5.5.0',
|
|
515
517
|
})
|
|
516
518
|
}
|
|
517
519
|
async bMallChangeCart(params = {}) {
|
|
518
520
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
519
521
|
client: 'H5',
|
|
520
522
|
clientVersion: '5.5.0',
|
|
521
523
|
})
|
|
522
524
|
}
|
|
523
525
|
async bMallRemoveCart(params = {}) {
|
|
524
526
|
return await this.gatewayReq(
|
|
525
527
|
'bmall_cartRemove',
|
|
526
528
|
params,
|
|
527
529
|
{
|
|
528
530
|
client: 'H5',
|
|
529
531
|
clientVersion: '5.5.0',
|
|
530
532
|
},
|
|
531
533
|
)
|
|
532
534
|
}
|
|
533
535
|
async bMallGetOmittedProduct(params = {}) {
|
|
534
536
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
535
537
|
client: 'H5',
|
|
536
538
|
clientVersion: '5.5.0',
|
|
537
539
|
})
|
|
538
540
|
}
|
|
539
541
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
540
542
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
541
543
|
return await this.bMallAddCart(params)
|
|
542
544
|
}
|
|
543
545
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
544
546
|
const params = await getParams({ bMallTag })
|
|
545
547
|
delete params.operations
|
|
546
548
|
return await this.bMallGetOmittedProduct(params)
|
|
547
549
|
}
|
|
548
550
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
549
551
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
550
552
|
return await this.bMallRemoveCart(params)
|
|
551
553
|
}
|
|
552
554
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
553
555
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
554
556
|
return await this.bMallChangeCart(params)
|
|
555
557
|
}
|
|
556
558
|
|
|
557
559
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
558
560
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
559
561
|
return window?.bMallCartData
|
|
560
562
|
}
|
|
561
563
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
562
564
|
let items
|
|
563
565
|
if (cartData.ok && cartData.result) {
|
|
564
566
|
items = cartData?.result?.items || {}
|
|
565
567
|
}
|
|
566
568
|
if (isH5) {
|
|
567
569
|
window.bMallCartData = items
|
|
568
570
|
}
|
|
569
571
|
return items
|
|
570
572
|
}
|
|
571
573
|
|
|
572
574
|
async bMallCartHandle(goodItem, num) {
|
|
573
575
|
try {
|
|
574
576
|
const {
|
|
575
577
|
skuUuid,
|
|
576
578
|
limitUpper,
|
|
577
579
|
limitLower,
|
|
578
580
|
} = goodItem
|
|
579
581
|
let cartNum = Number(num)
|
|
580
582
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
581
583
|
cartNum = limitLower
|
|
582
584
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
583
585
|
cartNum = limitUpper
|
|
584
586
|
}
|
|
585
587
|
if (skuUuid && cartNum > 0) {
|
|
586
588
|
return this.bMallChangeCartService({
|
|
587
589
|
...goodItem,
|
|
588
590
|
skuUuid,
|
|
589
591
|
num: cartNum,
|
|
590
592
|
})
|
|
591
593
|
} else if (!skuUuid && cartNum > 0) {
|
|
592
594
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
593
595
|
} else if (skuUuid && !cartNum) {
|
|
594
596
|
return this.bMallRemoveCartService({
|
|
595
597
|
...goodItem,
|
|
596
598
|
skuUuid,
|
|
597
599
|
num: cartNum,
|
|
598
600
|
})
|
|
599
601
|
} else {
|
|
600
602
|
console.error('参数不全')
|
|
601
603
|
return false
|
|
602
604
|
}
|
|
603
605
|
} catch (e) {
|
|
604
606
|
console.error(e)
|
|
605
607
|
}
|
|
606
608
|
}
|