@conecli/cone-render 0.10.1-shop3.5 → 0.10.1-shop3.6
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/const.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/components/base/CommonFloorHead/index.module.scss +126 -111
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +11 -0
- package/dist/components/base/InViewRender/index.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/interface/common.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -56
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/sass/app.h5.scss +252 -224
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -1
- package/dist/service/requestServer.h5.ts +1 -1
- package/dist/service/requestServer.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/jumpExtMapUtil.js +1 -0
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
APPID,
|
|
3
2
|
JshopxColorFunctionIdList,
|
|
4
3
|
PagesColorFunctionIdList,
|
|
5
4
|
PAGES_DOMAIN,
|
|
6
5
|
B2BColorFunctionIdList,
|
|
7
6
|
MobileVerifyColorList,
|
|
8
7
|
AppVerifyColorList,
|
|
9
8
|
JshopxVerifyColorList,
|
|
10
9
|
BMallVerifyColorList,
|
|
11
10
|
shopMemberColorFunctionIdList,
|
|
12
11
|
isLanguageForEn,
|
|
13
12
|
isJdApp,
|
|
14
13
|
isIosDevice,
|
|
15
14
|
isAndroidDevice,
|
|
16
15
|
showSuccessToast,
|
|
17
16
|
showFailToast,
|
|
18
17
|
isH5,
|
|
19
18
|
isWxMinAndWxapp,
|
|
20
19
|
isMin,
|
|
21
20
|
isPc,
|
|
22
21
|
sgmCustomReport,
|
|
23
22
|
getSgmCustomCode,
|
|
24
23
|
draInterfaceCustomReport,
|
|
25
24
|
callRouterIOS,
|
|
26
25
|
callRouterAndroid,
|
|
27
26
|
cookiesStr: '',
|
|
28
27
|
requestHeaderContentType: {
|
|
29
28
|
jsonHeader: {
|
|
30
29
|
'content-type': 'application/json;charset=utf-8',
|
|
31
30
|
},
|
|
32
31
|
formDataHeader: {
|
|
33
32
|
'content-type': 'application/x-www-form-urlencoded',
|
|
34
33
|
},
|
|
35
34
|
},
|
|
36
35
|
requestBaseParam: {
|
|
37
36
|
data: null,
|
|
38
37
|
header: {
|
|
39
38
|
'content-type': 'application/json;charset=utf-8',
|
|
40
39
|
},
|
|
41
40
|
},
|
|
42
41
|
timeOut: 7000,
|
|
43
42
|
apiClientParams: {
|
|
44
43
|
clientVersion:
|
|
45
44
|
isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
46
45
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
47
46
|
area: '1_72_2799_0',
|
|
48
47
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
|
|
49
48
|
window.screen?.height * devicePixelRatio,
|
|
50
49
|
)}`,
|
|
51
50
|
uuid: UUID,
|
|
52
51
|
},
|
|
53
52
|
public addressFetchInfo: {
|
|
54
53
|
reqState: boolean
|
|
55
54
|
promiseInstance: null | Promise<any>
|
|
56
55
|
}
|
|
57
56
|
public getPromotionConfig: {
|
|
58
57
|
projectId: null | string | number
|
|
59
58
|
pageId: null | string | number
|
|
60
59
|
}
|
|
61
60
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
62
61
|
public api: ServiceInterFace.HttpApi
|
|
63
62
|
public isPageDomain: boolean
|
|
64
63
|
public verifyColorList: string[]
|
|
65
64
|
constructor(opt) {
|
|
66
65
|
this._init()
|
|
67
66
|
this.addressFetchInfo = {
|
|
68
67
|
reqState: false,
|
|
69
68
|
promiseInstance: null,
|
|
70
69
|
}
|
|
71
70
|
this.getPromotionConfig = {
|
|
72
71
|
projectId: null,
|
|
73
72
|
pageId: null,
|
|
74
73
|
}
|
|
75
74
|
this._userAreaUpdateListen()
|
|
76
75
|
this.resInfo = this._getResConfig(opt)
|
|
77
76
|
this.api = api
|
|
78
77
|
this.isPageDomain = isH5
|
|
79
78
|
? window?.location?.hostname === PAGES_DOMAIN
|
|
80
79
|
: false
|
|
81
80
|
this.verifyColorList = [
|
|
82
81
|
...MobileVerifyColorList,
|
|
83
82
|
...AppVerifyColorList,
|
|
84
83
|
...JshopxVerifyColorList,
|
|
85
84
|
...BMallVerifyColorList,
|
|
86
85
|
]
|
|
87
86
|
}
|
|
88
87
|
_init(): void {
|
|
89
88
|
httpInterceptors.forEach((item) => {
|
|
90
89
|
Taro.addInterceptor((chain) => item(chain))
|
|
91
90
|
})
|
|
92
91
|
}
|
|
93
92
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
94
93
|
return Object.assign({}, DefaultConfig, opt)
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
_userAreaUpdateListen() {
|
|
98
97
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
99
98
|
this.updateApiClientParamsResInfo({
|
|
100
99
|
area,
|
|
101
100
|
})
|
|
102
101
|
})
|
|
103
102
|
}
|
|
104
103
|
updateApiClientParamsResInfo(opt = {}) {
|
|
105
104
|
this.resInfo.apiClientParams = {
|
|
106
105
|
...this.resInfo.apiClientParams,
|
|
107
106
|
...opt,
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
checkFunctionIdToReturnAppId(functionId) {
|
|
112
111
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
113
112
|
return APPID.JSHOPX_COLOR_APPID
|
|
114
113
|
} else if (
|
|
115
114
|
this.isPageDomain &&
|
|
116
115
|
PagesColorFunctionIdList.includes(functionId)
|
|
117
116
|
) {
|
|
118
117
|
return APPID.PAGES_COLOR_APPID
|
|
119
118
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
120
119
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
121
120
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
122
121
|
return APPID.B2B_COLOR_APPID
|
|
123
122
|
} else if (isPc) {
|
|
124
123
|
return APPID.MALL_COLOR_APPID
|
|
125
124
|
} else {
|
|
126
125
|
return APPID.SHOP_COLOR_APPID
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
gatewayReq(
|
|
131
130
|
functionId: string,
|
|
132
131
|
bodyParams = {},
|
|
133
132
|
clientParams = {},
|
|
134
133
|
): Promise<any> {
|
|
135
134
|
if (
|
|
136
135
|
functionId === 'receiveShopCoupon' &&
|
|
137
136
|
((isH5 &&
|
|
138
137
|
(window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
|
|
139
138
|
isWxMinAndWxapp)
|
|
140
139
|
) {
|
|
141
140
|
clientParams = Object.assign(
|
|
142
141
|
{},
|
|
143
142
|
{
|
|
144
143
|
loginType: '1',
|
|
145
144
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
146
145
|
},
|
|
147
146
|
clientParams,
|
|
148
147
|
)
|
|
149
148
|
}
|
|
150
149
|
const apiClientParams = Object.assign(
|
|
151
150
|
{},
|
|
152
151
|
this.resInfo.apiClientParams,
|
|
153
152
|
clientParams,
|
|
154
153
|
)
|
|
155
154
|
typeof apiClientParams.appid === 'undefined' &&
|
|
156
155
|
(apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
157
156
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
158
157
|
const getReqData = {
|
|
159
158
|
functionId: functionId,
|
|
160
159
|
body: JSON.stringify(bodyParams),
|
|
161
160
|
t: Date.now(),
|
|
162
161
|
...apiClientParams,
|
|
163
162
|
}
|
|
164
163
|
const requestParams = {
|
|
165
164
|
functionId: getReqData?.functionId,
|
|
166
165
|
body: getReqData?.body,
|
|
167
166
|
appid: getReqData?.appid,
|
|
168
167
|
client: getReqData?.client,
|
|
169
168
|
clientVersion: getReqData?.clientVersion,
|
|
170
169
|
area: getReqData?.area,
|
|
171
170
|
requestTimeStamp: getReqData?.t,
|
|
172
171
|
}
|
|
173
172
|
return http
|
|
174
173
|
.request({
|
|
175
174
|
url: this.api.apiFunc,
|
|
176
175
|
data: getReqData,
|
|
177
176
|
isColorVerify,
|
|
178
177
|
})
|
|
179
178
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
180
179
|
const { statusCode, data, status, msg } = res
|
|
181
180
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
182
181
|
ok: true,
|
|
183
182
|
}
|
|
184
183
|
if ((statusCode === 200 || status === '0') && data) {
|
|
185
184
|
changeRes = this.dealResponseFormatRes(data, getReqData)
|
|
186
185
|
return changeRes
|
|
187
186
|
} else {
|
|
188
187
|
sgmCustomReport({
|
|
189
188
|
code: getSgmCustomCode('interface_data_error'),
|
|
190
189
|
msg: {
|
|
191
190
|
subMsg: '接口请求异常',
|
|
192
191
|
functionId,
|
|
193
192
|
statusCode,
|
|
194
193
|
source: 'remote',
|
|
195
194
|
status,
|
|
196
195
|
msg,
|
|
197
196
|
requestParams,
|
|
198
197
|
},
|
|
199
198
|
})
|
|
200
199
|
draInterfaceCustomReport({
|
|
201
200
|
...getReqData,
|
|
202
201
|
...res,
|
|
203
202
|
source: 'remote',
|
|
204
203
|
})
|
|
205
204
|
changeRes = {
|
|
206
205
|
...data,
|
|
207
206
|
statusCode,
|
|
208
207
|
status,
|
|
209
208
|
msg,
|
|
210
209
|
ok: false,
|
|
211
210
|
}
|
|
212
211
|
return changeRes
|
|
213
212
|
}
|
|
214
213
|
})
|
|
215
214
|
.catch((res) => {
|
|
216
215
|
const propertyNames = Object.getOwnPropertyNames(res)
|
|
217
216
|
const resObject = {}
|
|
218
217
|
propertyNames.forEach((propertyName) => {
|
|
219
218
|
resObject[propertyName] = res[propertyName]
|
|
220
219
|
})
|
|
221
220
|
sgmCustomReport({
|
|
222
221
|
code: getSgmCustomCode('interface_data_error'),
|
|
223
222
|
msg: {
|
|
224
223
|
subMsg: '接口请求错误',
|
|
225
224
|
functionId,
|
|
226
225
|
source: 'remote',
|
|
227
226
|
requestParams,
|
|
228
227
|
catchError: resObject,
|
|
229
228
|
},
|
|
230
229
|
})
|
|
231
230
|
draInterfaceCustomReport({
|
|
232
231
|
...getReqData,
|
|
233
232
|
...resObject,
|
|
234
233
|
source: 'remote',
|
|
235
234
|
})
|
|
236
235
|
return {
|
|
237
236
|
...resObject,
|
|
238
237
|
ok: false,
|
|
239
238
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
240
239
|
})
|
|
241
240
|
}
|
|
242
241
|
|
|
243
242
|
dealResponseFormatRes(data, reqData) {
|
|
244
243
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
245
244
|
ok: true,
|
|
246
245
|
}
|
|
247
246
|
const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
|
|
248
247
|
? Number(data.code)
|
|
249
248
|
: -1
|
|
250
249
|
const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
|
|
251
250
|
? Number(data.subCode)
|
|
252
251
|
: -1
|
|
253
252
|
if (
|
|
254
253
|
data.success === true ||
|
|
255
254
|
data.isSuccess ||
|
|
256
255
|
resCode === 0 ||
|
|
257
256
|
resCode === 200 ||
|
|
258
257
|
subCode === 0
|
|
259
258
|
) {
|
|
260
259
|
changeRes = {
|
|
261
260
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
262
261
|
? data.result
|
|
263
262
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
264
263
|
? data.data
|
|
265
264
|
: data,
|
|
266
265
|
code: data.code ?? 200,
|
|
267
266
|
ok: true,
|
|
268
267
|
source: data,
|
|
269
268
|
}
|
|
270
269
|
return changeRes
|
|
271
270
|
} else {
|
|
272
271
|
changeRes = {
|
|
273
272
|
...data,
|
|
274
273
|
ok: false,
|
|
275
274
|
}
|
|
276
275
|
if (reqData && resCode !== 3) {
|
|
277
276
|
const getReportMsgData = reqData['hybridId']
|
|
278
277
|
? {
|
|
279
278
|
subMsg: '预加载接口请求数据异常',
|
|
280
279
|
hybridId: reqData?.hybridId,
|
|
281
280
|
requestId: reqData?.requestId,
|
|
282
281
|
param: reqData?.param,
|
|
283
282
|
source: 'remote',
|
|
284
283
|
}
|
|
285
284
|
: {
|
|
286
285
|
subMsg: '接口请求返回数据异常',
|
|
287
286
|
functionId: reqData?.functionId,
|
|
288
287
|
code: resCode,
|
|
289
288
|
source: 'remote',
|
|
290
289
|
requestParams: {
|
|
291
290
|
functionId: reqData?.functionId,
|
|
292
291
|
body: reqData?.body,
|
|
293
292
|
appid: reqData?.appid,
|
|
294
293
|
client: reqData?.client,
|
|
295
294
|
clientVersion: reqData?.clientVersion,
|
|
296
295
|
area: reqData?.area,
|
|
297
296
|
requestTimeStamp: reqData?.t,
|
|
298
297
|
},
|
|
299
298
|
resData: data,
|
|
300
299
|
}
|
|
301
300
|
sgmCustomReport({
|
|
302
301
|
code: getSgmCustomCode('interface_data_error'),
|
|
303
302
|
msg: getReportMsgData,
|
|
304
303
|
})
|
|
305
304
|
draInterfaceCustomReport({
|
|
306
305
|
...reqData,
|
|
307
306
|
...data,
|
|
308
307
|
source: 'remote',
|
|
309
308
|
})
|
|
310
309
|
}
|
|
311
310
|
return changeRes
|
|
312
311
|
}
|
|
313
312
|
}
|
|
314
313
|
|
|
315
314
|
async receiveCoupon(param = {}, clientParams) {
|
|
316
315
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
317
316
|
return await this.gatewayReq(
|
|
318
317
|
'receiveShopCoupon',
|
|
319
318
|
{
|
|
320
319
|
operation: '3',
|
|
321
320
|
...param,
|
|
322
321
|
},
|
|
323
322
|
{ ...loginType, ...clientParams },
|
|
324
323
|
)
|
|
325
324
|
}
|
|
326
325
|
|
|
327
326
|
getCustomerCenterDispatch(params = {}) {
|
|
328
327
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
329
328
|
clientVersion: '9.2.0',
|
|
330
329
|
client: 'H5',
|
|
331
330
|
uuid: 88888,
|
|
332
331
|
appid: 'shopmember_m_jd_com',
|
|
333
332
|
})
|
|
334
333
|
}
|
|
335
334
|
|
|
336
335
|
batchAddCart(...args) {
|
|
337
336
|
let skuIds, num, showToast, giftCard
|
|
338
337
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
339
338
|
;[skuIds, num = 1, showToast = true, giftCard = false] = args
|
|
340
339
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
341
340
|
const params = args[0]
|
|
342
341
|
skuIds = params.skuIds
|
|
343
342
|
num = params.num || 1
|
|
344
343
|
showToast = params.showToast !== undefined ? params.showToast : true
|
|
345
344
|
giftCard = params.giftCard !== undefined ? params.giftCard : false
|
|
346
345
|
} else {
|
|
347
346
|
console.error('batchAddCart() Invalid arguments!', args)
|
|
348
347
|
const msg = isLanguageForEn
|
|
349
348
|
? 'Please retry later'
|
|
350
349
|
: '加入购物车失败,请稍后重试!'
|
|
351
350
|
showFailToast({
|
|
352
351
|
title: msg,
|
|
353
352
|
})
|
|
354
353
|
return Promise.resolve({
|
|
355
354
|
ok: false,
|
|
356
355
|
msg,
|
|
357
356
|
})
|
|
358
357
|
}
|
|
359
358
|
const addToWhereText = giftCard ? '购物清单' : '购物车'
|
|
360
359
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`
|
|
361
360
|
const failMsg = isLanguageForEn
|
|
362
361
|
? 'Please retry later'
|
|
363
362
|
: `加入${addToWhereText}失败,请稍后重试!`
|
|
364
363
|
if (skuIds) {
|
|
365
364
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
366
365
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
367
366
|
if (res?.ok) {
|
|
368
367
|
if (showToast && !res?.isOpenApp)
|
|
369
368
|
showSuccessToast({
|
|
370
369
|
title: successMsg,
|
|
371
370
|
})
|
|
372
371
|
} else {
|
|
373
372
|
showToast &&
|
|
374
373
|
showFailToast({
|
|
375
374
|
title: res?.errMsg || failMsg,
|
|
376
375
|
})
|
|
377
376
|
}
|
|
378
377
|
return Promise.resolve(res)
|
|
379
378
|
})
|
|
380
379
|
.catch((e) => {
|
|
381
380
|
console.log('调用加购方法异常=======>', e)
|
|
382
381
|
return Promise.resolve({
|
|
383
382
|
ok: false,
|
|
384
383
|
msg: failMsg,
|
|
385
384
|
})
|
|
386
385
|
})
|
|
387
386
|
} else {
|
|
388
387
|
return Promise.resolve({
|
|
389
388
|
ok: false,
|
|
390
389
|
msg: failMsg,
|
|
391
390
|
})
|
|
392
391
|
}
|
|
393
392
|
}
|
|
394
393
|
|
|
395
394
|
async giftCardAddCart(skuList, num) {
|
|
396
395
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
397
396
|
return this.gatewayReq(
|
|
398
397
|
'giftCardAddCart',
|
|
399
398
|
{
|
|
400
399
|
skuList,
|
|
401
400
|
num: Number(num),
|
|
402
401
|
},
|
|
403
402
|
{ ...loginType },
|
|
404
403
|
)
|
|
405
404
|
}
|
|
406
405
|
|
|
407
406
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
408
407
|
return new Promise((resolve) => {
|
|
409
408
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
410
409
|
if (productIdsArr.length > 0) {
|
|
411
410
|
if (giftCard) {
|
|
412
411
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
413
412
|
.then((res) => {
|
|
414
413
|
if (res?.code === '0' && res?.result?.value) {
|
|
415
414
|
resolve({
|
|
416
415
|
ok: true,
|
|
417
416
|
})
|
|
418
417
|
} else {
|
|
419
418
|
resolve({
|
|
420
419
|
ok: false,
|
|
421
420
|
msg: '加购失败,请稍后重试',
|
|
422
421
|
})
|
|
423
422
|
}
|
|
424
423
|
})
|
|
425
424
|
.catch((e) => {
|
|
426
425
|
console.error('礼品卡加车失败: ', e)
|
|
427
426
|
resolve({
|
|
428
427
|
ok: false,
|
|
429
428
|
msg: '加购失败,请稍后重试',
|
|
430
429
|
})
|
|
431
430
|
})
|
|
432
431
|
} else if (isJdApp) {
|
|
433
432
|
console.log('==========>', '原生批量加车!')
|
|
434
433
|
const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`
|
|
435
434
|
if (!window[nativeAddCartCallBack]) {
|
|
436
435
|
window[nativeAddCartCallBack] = (res) => {
|
|
437
436
|
const getMessageJsonData =
|
|
438
437
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
439
438
|
console.info(
|
|
440
439
|
'获取批量加车原始数据',
|
|
441
440
|
res,
|
|
442
441
|
'====转换后的json数据为===',
|
|
443
442
|
getMessageJsonData,
|
|
444
443
|
)
|
|
445
444
|
try {
|
|
446
445
|
if (isAndroidDevice) {
|
|
447
446
|
getMessageJsonData?.status === '0'
|
|
448
447
|
? resolve({
|
|
449
448
|
ok: true,
|
|
450
449
|
msg: '已加入购物车!',
|
|
451
450
|
})
|
|
452
451
|
: resolve({
|
|
453
452
|
ok: false,
|
|
454
453
|
msg: '加购失败,请稍后重试',
|
|
455
454
|
})
|
|
456
455
|
} else if (isIosDevice) {
|
|
457
456
|
getMessageJsonData?.status === '0' &&
|
|
458
457
|
getMessageJsonData?.data?.code === 0
|
|
459
458
|
? resolve({
|
|
460
459
|
ok: true,
|
|
461
460
|
msg: '已加入购物车!',
|
|
462
461
|
})
|
|
463
462
|
: resolve({
|
|
464
463
|
ok: false,
|
|
465
464
|
msg: '批量加车失败,请稍后重试',
|
|
466
465
|
})
|
|
467
466
|
} else {
|
|
468
467
|
resolve({
|
|
469
468
|
ok: false,
|
|
470
469
|
msg: '加购失败,请稍后重试',
|
|
471
470
|
})
|
|
472
471
|
}
|
|
473
472
|
} catch (e) {
|
|
474
473
|
resolve({
|
|
475
474
|
ok: false,
|
|
476
475
|
msg: '加购失败,请稍后重试',
|
|
477
476
|
})
|
|
478
477
|
console.warn('批量加车转换数据异常', e)
|
|
479
478
|
}
|
|
480
479
|
window[nativeAddCartCallBack] = null
|
|
481
480
|
}
|
|
482
481
|
}
|
|
483
482
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
484
483
|
return isAndroidDevice
|
|
485
484
|
? {
|
|
486
485
|
sku: skuItem,
|
|
487
486
|
num: addCardNum,
|
|
488
487
|
}
|
|
489
488
|
: {
|
|
490
489
|
productCode: skuItem,
|
|
491
490
|
buyCount: addCardNum,
|
|
492
491
|
}
|
|
493
492
|
})
|
|
494
493
|
if (isAndroidDevice) {
|
|
495
494
|
const androidProductsStr = JSON.stringify(productsAddCartList)
|
|
496
495
|
callRouterAndroid({
|
|
497
496
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
|
|
498
497
|
routerParam: {
|
|
499
498
|
wareList: productsAddCartList,
|
|
500
499
|
},
|
|
501
500
|
callBackName: nativeAddCartCallBack,
|
|
502
501
|
})
|
|
503
502
|
} else if (isIosDevice) {
|
|
504
503
|
if (isLowAppVer) {
|
|
505
504
|
const lowVersionAppList = productIdsArr.map((skuItem) => {
|
|
506
505
|
return {
|
|
507
506
|
sku: skuItem,
|
|
508
507
|
num: addCardNum,
|
|
509
508
|
}
|
|
510
509
|
})
|
|
511
510
|
const lowVersionAppListStr = JSON.stringify(lowVersionAppList)
|
|
512
511
|
const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`
|
|
513
512
|
jump.side.jdJumpToWeb(url, {})
|
|
514
513
|
resolve({
|
|
515
514
|
ok: true,
|
|
516
515
|
isOpenApp: true,
|
|
517
516
|
msg: '加购完成, 加购结果请点击购物车确认',
|
|
518
517
|
})
|
|
519
518
|
} else {
|
|
520
519
|
callRouterIOS({
|
|
521
520
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
522
521
|
routerParam: {
|
|
523
522
|
sourceType: 'h5',
|
|
524
523
|
sourceValue: '店铺批量加购',
|
|
525
524
|
businessName: 'storeModel',
|
|
526
525
|
isNewMode: '1',
|
|
527
526
|
NotPassWebview: '1',
|
|
528
527
|
products: productsAddCartList,
|
|
529
528
|
},
|
|
530
529
|
callBackName: nativeAddCartCallBack,
|
|
531
530
|
})
|
|
532
531
|
}
|
|
533
532
|
}
|
|
534
533
|
} else if (isMin) {
|
|
535
534
|
console.log('==========>', '京购批量加车!')
|
|
536
535
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
537
536
|
return {
|
|
538
537
|
skuId: skuItem,
|
|
539
538
|
buyNum: addCardNum,
|
|
540
539
|
}
|
|
541
540
|
})
|
|
542
541
|
global.wxAppBizInstance
|
|
543
542
|
.addCart({ commArr: productsAddCartList })
|
|
544
543
|
.then((res) => {
|
|
545
544
|
console.log('dealCartSuccess: ', res)
|
|
546
545
|
resolve({
|
|
547
546
|
ok: true,
|
|
548
547
|
msg: '已加入购物车!',
|
|
549
548
|
data: res,
|
|
550
549
|
})
|
|
551
550
|
})
|
|
552
551
|
.catch((e) => {
|
|
553
552
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
554
553
|
resolve({
|
|
555
554
|
ok: false,
|
|
556
555
|
msg: '加购失败,请稍后重试',
|
|
557
556
|
})
|
|
558
557
|
})
|
|
559
558
|
} else {
|
|
560
559
|
console.log('==========>', 'M站批量加车!')
|
|
561
560
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) =>
|
|
562
561
|
resolve(res),
|
|
563
562
|
)
|
|
564
563
|
}
|
|
565
564
|
} else {
|
|
566
565
|
resolve({
|
|
567
566
|
ok: false,
|
|
568
567
|
msg: '加购sku不能为空',
|
|
569
568
|
})
|
|
570
569
|
}
|
|
571
570
|
})
|
|
572
571
|
}
|
|
573
572
|
|
|
574
573
|
productAddToCart(skuIdsStr, num) {
|
|
575
574
|
return new Promise((resolve) => {
|
|
576
575
|
if (window.AddcartToolObj) {
|
|
577
576
|
window.AddcartToolObj.addCart({
|
|
578
577
|
skuId: skuIdsStr,
|
|
579
578
|
num,
|
|
580
579
|
source: 'sjdpyw',
|
|
581
580
|
actId: '1',
|
|
582
581
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
583
582
|
sucFun(res) {
|
|
584
583
|
console.log(
|
|
585
584
|
'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
|
|
586
585
|
res,
|
|
587
586
|
)
|
|
588
587
|
if (res.errId === '0' && res.cartJson) {
|
|
589
588
|
resolve({
|
|
590
589
|
ok: true,
|
|
591
590
|
msg: '已加入购物车!',
|
|
592
591
|
...res,
|
|
593
592
|
})
|
|
594
593
|
} else {
|
|
595
594
|
if (res.errId === '13') {
|
|
596
595
|
global.doLogin()
|
|
597
596
|
} else {
|
|
598
597
|
resolve({
|
|
599
598
|
ok: false,
|
|
600
599
|
msg: '加购失败,请稍后重试',
|
|
601
600
|
...res,
|
|
602
601
|
})
|
|
603
602
|
}
|
|
604
603
|
}
|
|
605
604
|
},
|
|
606
605
|
failFun(err) {
|
|
607
606
|
console.log('fail', err)
|
|
608
607
|
resolve({
|
|
609
608
|
ok: false,
|
|
610
609
|
msg: '加购失败,请稍后重试',
|
|
611
610
|
...err,
|
|
612
611
|
})
|
|
613
612
|
},
|
|
614
613
|
})
|
|
615
614
|
} else {
|
|
616
615
|
resolve({
|
|
617
616
|
ok: false,
|
|
618
617
|
msg: '购物车方法检查异常',
|
|
619
618
|
})
|
|
620
619
|
}
|
|
621
620
|
})
|
|
622
621
|
}
|
|
623
622
|
bMallGetUserInfo = () => {
|
|
624
623
|
return getBMallUserInfo()
|
|
625
624
|
}
|
|
626
625
|
async bMallAddCart(params = {}) {
|
|
627
626
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
628
627
|
client: 'H5',
|
|
629
628
|
clientVersion: '5.5.0',
|
|
630
629
|
})
|
|
631
630
|
}
|
|
632
631
|
async bMallChangeCart(params = {}) {
|
|
633
632
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
634
633
|
client: 'H5',
|
|
635
634
|
clientVersion: '5.5.0',
|
|
636
635
|
})
|
|
637
636
|
}
|
|
638
637
|
async bMallRemoveCart(params = {}) {
|
|
639
638
|
return await this.gatewayReq(
|
|
640
639
|
'bmall_cartRemove',
|
|
641
640
|
params,
|
|
642
641
|
{
|
|
643
642
|
client: 'H5',
|
|
644
643
|
clientVersion: '5.5.0',
|
|
645
644
|
},
|
|
646
645
|
)
|
|
647
646
|
}
|
|
648
647
|
async bMallGetOmittedProduct(params = {}) {
|
|
649
648
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
650
649
|
client: 'H5',
|
|
651
650
|
clientVersion: '5.5.0',
|
|
652
651
|
})
|
|
653
652
|
}
|
|
654
653
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
655
654
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
656
655
|
return await this.bMallAddCart(params)
|
|
657
656
|
}
|
|
658
657
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
659
658
|
const params = await getParams({ bMallTag })
|
|
660
659
|
delete params.operations
|
|
661
660
|
return await this.bMallGetOmittedProduct(params)
|
|
662
661
|
}
|
|
663
662
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
664
663
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
665
664
|
return await this.bMallRemoveCart(params)
|
|
666
665
|
}
|
|
667
666
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
668
667
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
669
668
|
return await this.bMallChangeCart(params)
|
|
670
669
|
}
|
|
671
670
|
|
|
672
671
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
673
672
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
674
673
|
return window?.bMallCartData
|
|
675
674
|
}
|
|
676
675
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
677
676
|
let items
|
|
678
677
|
if (cartData.ok && cartData.result) {
|
|
679
678
|
items = cartData?.result?.items || {}
|
|
680
679
|
}
|
|
681
680
|
if (isH5) {
|
|
682
681
|
window.bMallCartData = items
|
|
683
682
|
}
|
|
684
683
|
return items
|
|
685
684
|
}
|
|
686
685
|
|
|
687
686
|
async bMallCartHandle(goodItem, num) {
|
|
688
687
|
try {
|
|
689
688
|
const {
|
|
690
689
|
skuUuid,
|
|
691
690
|
limitUpper,
|
|
692
691
|
limitLower,
|
|
693
692
|
} = goodItem
|
|
694
693
|
let cartNum = Number(num)
|
|
695
694
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
696
695
|
cartNum = limitLower
|
|
697
696
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
698
697
|
cartNum = limitUpper
|
|
699
698
|
}
|
|
700
699
|
if (skuUuid && cartNum > 0) {
|
|
701
700
|
return this.bMallChangeCartService({
|
|
702
701
|
...goodItem,
|
|
703
702
|
skuUuid,
|
|
704
703
|
num: cartNum,
|
|
705
704
|
})
|
|
706
705
|
} else if (!skuUuid && cartNum > 0) {
|
|
707
706
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
708
707
|
} else if (skuUuid && !cartNum) {
|
|
709
708
|
return this.bMallRemoveCartService({
|
|
710
709
|
...goodItem,
|
|
711
710
|
skuUuid,
|
|
712
711
|
num: cartNum,
|
|
713
712
|
})
|
|
714
713
|
} else {
|
|
715
714
|
console.error('参数不全')
|
|
716
715
|
return false
|
|
717
716
|
}
|
|
718
717
|
} catch (e) {
|
|
719
718
|
console.error(e)
|
|
720
719
|
}
|
|
721
720
|
}
|
|
721
|
+
import Taro from '@tarojs/taro'
|
|
722
722
|
APPID,
|
|
723
723
|
JshopxColorFunctionIdList,
|
|
724
724
|
PagesColorFunctionIdList,
|
|
725
725
|
PAGES_DOMAIN,
|
|
726
726
|
B2BColorFunctionIdList,
|
|
727
727
|
MobileVerifyColorList,
|
|
728
728
|
AppVerifyColorList,
|
|
729
729
|
JshopxVerifyColorList,
|
|
730
730
|
BMallVerifyColorList,
|
|
731
731
|
shopMemberColorFunctionIdList,
|
|
732
732
|
isLanguageForEn,
|
|
733
733
|
isJdApp,
|
|
734
734
|
isIosDevice,
|
|
735
735
|
isAndroidDevice,
|
|
736
736
|
showSuccessToast,
|
|
737
737
|
showFailToast,
|
|
738
738
|
isH5,
|
|
739
739
|
isWxMinAndWxapp,
|
|
740
740
|
isMin,
|
|
741
741
|
isPc,
|
|
742
742
|
sgmCustomReport,
|
|
743
743
|
getSgmCustomCode,
|
|
744
744
|
draInterfaceCustomReport,
|
|
745
745
|
callRouterIOS,
|
|
746
746
|
callRouterAndroid,
|
|
747
747
|
cookiesStr: '',
|
|
748
748
|
requestHeaderContentType: {
|
|
749
749
|
jsonHeader: {
|
|
750
750
|
'content-type': 'application/json;charset=utf-8',
|
|
751
751
|
},
|
|
752
752
|
formDataHeader: {
|
|
753
753
|
'content-type': 'application/x-www-form-urlencoded',
|
|
754
754
|
},
|
|
755
755
|
},
|
|
756
756
|
requestBaseParam: {
|
|
757
757
|
data: null,
|
|
758
758
|
header: {
|
|
759
759
|
'content-type': 'application/json;charset=utf-8',
|
|
760
760
|
},
|
|
761
761
|
},
|
|
762
762
|
timeOut: 7000,
|
|
763
763
|
apiClientParams: {
|
|
764
764
|
clientVersion: '11.0.0',
|
|
765
765
|
client: 'wh5',
|
|
766
766
|
area: '1_72_2799_0',
|
|
767
767
|
screen: `${Math.ceil(
|
|
768
768
|
getSystemInfo?.screenWidth * devicePixelRatio,
|
|
769
769
|
)}*${Math.ceil(getSystemInfo?.screenHeight * devicePixelRatio)}`,
|
|
770
770
|
uuid: UUID,
|
|
771
771
|
},
|
|
772
772
|
public addressFetchInfo: {
|
|
773
773
|
reqState: boolean
|
|
774
774
|
promiseInstance: null | Promise<any>
|
|
775
775
|
}
|
|
776
776
|
public getPromotionConfig: {
|
|
777
777
|
projectId: null | string | number
|
|
778
778
|
pageId: null | string | number
|
|
779
779
|
}
|
|
780
780
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
781
781
|
public api: ServiceInterFace.HttpApi
|
|
782
782
|
public isPageDomain: boolean
|
|
783
783
|
public verifyColorList: string[]
|
|
784
784
|
constructor(opt) {
|
|
785
785
|
this._init()
|
|
786
786
|
this.addressFetchInfo = {
|
|
787
787
|
reqState: false,
|
|
788
788
|
promiseInstance: null,
|
|
789
789
|
}
|
|
790
790
|
this.getPromotionConfig = {
|
|
791
791
|
projectId: null,
|
|
792
792
|
pageId: null,
|
|
793
793
|
}
|
|
794
794
|
this._userAreaUpdateListen()
|
|
795
795
|
this.resInfo = this._getResConfig(opt)
|
|
796
796
|
this.api = api
|
|
797
797
|
this.isPageDomain = isH5
|
|
798
798
|
? window?.location?.hostname === PAGES_DOMAIN
|
|
799
799
|
: false
|
|
800
800
|
this.verifyColorList = [
|
|
801
801
|
...MobileVerifyColorList,
|
|
802
802
|
...AppVerifyColorList,
|
|
803
803
|
...JshopxVerifyColorList,
|
|
804
804
|
...BMallVerifyColorList,
|
|
805
805
|
]
|
|
806
806
|
}
|
|
807
807
|
_init(): void {
|
|
808
808
|
httpInterceptors.forEach((item) => {
|
|
809
809
|
Taro.addInterceptor((chain) => item(chain))
|
|
810
810
|
})
|
|
811
811
|
}
|
|
812
812
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
813
813
|
return Object.assign({}, DefaultConfig, opt)
|
|
814
814
|
}
|
|
815
815
|
|
|
816
816
|
_userAreaUpdateListen() {
|
|
817
817
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
818
818
|
this.updateApiClientParamsResInfo({
|
|
819
819
|
area,
|
|
820
820
|
})
|
|
821
821
|
})
|
|
822
822
|
}
|
|
823
823
|
updateApiClientParamsResInfo(opt = {}) {
|
|
824
824
|
this.resInfo.apiClientParams = {
|
|
825
825
|
...this.resInfo.apiClientParams,
|
|
826
826
|
...opt,
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
|
|
830
830
|
checkFunctionIdToReturnAppId(functionId) {
|
|
831
831
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
832
832
|
return APPID.JSHOPX_COLOR_APPID
|
|
833
833
|
} else if (
|
|
834
834
|
this.isPageDomain &&
|
|
835
835
|
PagesColorFunctionIdList.includes(functionId)
|
|
836
836
|
) {
|
|
837
837
|
return APPID.PAGES_COLOR_APPID
|
|
838
838
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
839
839
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
840
840
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
841
841
|
return APPID.B2B_COLOR_APPID
|
|
842
842
|
} else if (isPc) {
|
|
843
843
|
return APPID.MALL_COLOR_APPID
|
|
844
844
|
} else {
|
|
845
845
|
return APPID.SHOP_COLOR_APPID
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
848
|
|
|
849
849
|
gatewayReq(
|
|
850
850
|
functionId: string,
|
|
851
851
|
bodyParams = {},
|
|
852
852
|
clientParams = {},
|
|
853
853
|
): Promise<any> {
|
|
854
854
|
if (
|
|
855
855
|
functionId === 'receiveShopCoupon' &&
|
|
856
856
|
((isH5 &&
|
|
857
857
|
(window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
|
|
858
858
|
isWxMinAndWxapp)
|
|
859
859
|
) {
|
|
860
860
|
clientParams = Object.assign(
|
|
861
861
|
{},
|
|
862
862
|
{
|
|
863
863
|
loginType: '1',
|
|
864
864
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
865
865
|
},
|
|
866
866
|
clientParams,
|
|
867
867
|
)
|
|
868
868
|
}
|
|
869
869
|
const apiClientParams = Object.assign(
|
|
870
870
|
{},
|
|
871
871
|
this.resInfo.apiClientParams,
|
|
872
872
|
clientParams,
|
|
873
873
|
)
|
|
874
874
|
typeof apiClientParams.appid === 'undefined' &&
|
|
875
875
|
(apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
876
876
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
877
877
|
const getReqData = {
|
|
878
878
|
functionId: functionId,
|
|
879
879
|
body: JSON.stringify(bodyParams),
|
|
880
880
|
t: Date.now(),
|
|
881
881
|
...apiClientParams,
|
|
882
882
|
}
|
|
883
883
|
const requestParams = {
|
|
884
884
|
functionId: getReqData?.functionId,
|
|
885
885
|
body: getReqData?.body,
|
|
886
886
|
appid: getReqData?.appid,
|
|
887
887
|
client: getReqData?.client,
|
|
888
888
|
clientVersion: getReqData?.clientVersion,
|
|
889
889
|
area: getReqData?.area,
|
|
890
890
|
requestTimeStamp: getReqData?.t,
|
|
891
891
|
}
|
|
892
892
|
return http
|
|
893
893
|
.request({
|
|
894
894
|
url: this.api.apiFunc,
|
|
895
895
|
data: getReqData,
|
|
896
896
|
isColorVerify,
|
|
897
897
|
})
|
|
898
898
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
899
899
|
const { statusCode, data, status, msg } = res
|
|
900
900
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
901
901
|
ok: true,
|
|
902
902
|
}
|
|
903
903
|
if ((statusCode === 200 || status === '0') && data) {
|
|
904
904
|
changeRes = this.dealResponseFormatRes(data, getReqData)
|
|
905
905
|
return changeRes
|
|
906
906
|
} else {
|
|
907
907
|
sgmCustomReport({
|
|
908
908
|
code: getSgmCustomCode('interface_data_error'),
|
|
909
909
|
msg: {
|
|
910
910
|
subMsg: '接口请求异常',
|
|
911
911
|
functionId,
|
|
912
912
|
statusCode,
|
|
913
913
|
source: 'remote',
|
|
914
914
|
status,
|
|
915
915
|
msg,
|
|
916
916
|
requestParams,
|
|
917
917
|
},
|
|
918
918
|
})
|
|
919
919
|
draInterfaceCustomReport({
|
|
920
920
|
...getReqData,
|
|
921
921
|
...res,
|
|
922
922
|
source: 'remote',
|
|
923
923
|
})
|
|
924
924
|
changeRes = {
|
|
925
925
|
...data,
|
|
926
926
|
statusCode,
|
|
927
927
|
status,
|
|
928
928
|
msg,
|
|
929
929
|
ok: false,
|
|
930
930
|
}
|
|
931
931
|
return changeRes
|
|
932
932
|
}
|
|
933
933
|
})
|
|
934
934
|
.catch((res) => {
|
|
935
935
|
const propertyNames = Object.getOwnPropertyNames(res)
|
|
936
936
|
const resObject = {}
|
|
937
937
|
propertyNames.forEach((propertyName) => {
|
|
938
938
|
resObject[propertyName] = res[propertyName]
|
|
939
939
|
})
|
|
940
940
|
sgmCustomReport({
|
|
941
941
|
code: getSgmCustomCode('interface_data_error'),
|
|
942
942
|
msg: {
|
|
943
943
|
subMsg: '接口请求错误',
|
|
944
944
|
functionId,
|
|
945
945
|
source: 'remote',
|
|
946
946
|
requestParams,
|
|
947
947
|
catchError: resObject,
|
|
948
948
|
},
|
|
949
949
|
})
|
|
950
950
|
draInterfaceCustomReport({
|
|
951
951
|
...getReqData,
|
|
952
952
|
...resObject,
|
|
953
953
|
source: 'remote',
|
|
954
954
|
})
|
|
955
955
|
return {
|
|
956
956
|
...resObject,
|
|
957
957
|
ok: false,
|
|
958
958
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
959
959
|
})
|
|
960
960
|
}
|
|
961
961
|
|
|
962
962
|
dealResponseFormatRes(data, reqData) {
|
|
963
963
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
964
964
|
ok: true,
|
|
965
965
|
}
|
|
966
966
|
const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
|
|
967
967
|
? Number(data.code)
|
|
968
968
|
: -1
|
|
969
969
|
const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
|
|
970
970
|
? Number(data.subCode)
|
|
971
971
|
: -1
|
|
972
972
|
if (
|
|
973
973
|
data.success === true ||
|
|
974
974
|
data.isSuccess ||
|
|
975
975
|
resCode === 0 ||
|
|
976
976
|
resCode === 200 ||
|
|
977
977
|
subCode === 0
|
|
978
978
|
) {
|
|
979
979
|
changeRes = {
|
|
980
980
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
981
981
|
? data.result
|
|
982
982
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
983
983
|
? data.data
|
|
984
984
|
: data,
|
|
985
985
|
code: data.code ?? 200,
|
|
986
986
|
ok: true,
|
|
987
987
|
source: data,
|
|
988
988
|
}
|
|
989
989
|
return changeRes
|
|
990
990
|
} else {
|
|
991
991
|
changeRes = {
|
|
992
992
|
...data,
|
|
993
993
|
ok: false,
|
|
994
994
|
}
|
|
995
995
|
if (reqData && resCode !== 3) {
|
|
996
996
|
const getReportMsgData = reqData['hybridId']
|
|
997
997
|
? {
|
|
998
998
|
subMsg: '预加载接口请求数据异常',
|
|
999
999
|
hybridId: reqData?.hybridId,
|
|
1000
1000
|
requestId: reqData?.requestId,
|
|
1001
1001
|
param: reqData?.param,
|
|
1002
1002
|
source: 'remote',
|
|
1003
1003
|
}
|
|
1004
1004
|
: {
|
|
1005
1005
|
subMsg: '接口请求返回数据异常',
|
|
1006
1006
|
functionId: reqData?.functionId,
|
|
1007
1007
|
code: resCode,
|
|
1008
1008
|
source: 'remote',
|
|
1009
1009
|
requestParams: {
|
|
1010
1010
|
functionId: reqData?.functionId,
|
|
1011
1011
|
body: reqData?.body,
|
|
1012
1012
|
appid: reqData?.appid,
|
|
1013
1013
|
client: reqData?.client,
|
|
1014
1014
|
clientVersion: reqData?.clientVersion,
|
|
1015
1015
|
area: reqData?.area,
|
|
1016
1016
|
requestTimeStamp: reqData?.t,
|
|
1017
1017
|
},
|
|
1018
1018
|
resData: data,
|
|
1019
1019
|
}
|
|
1020
1020
|
sgmCustomReport({
|
|
1021
1021
|
code: getSgmCustomCode('interface_data_error'),
|
|
1022
1022
|
msg: getReportMsgData,
|
|
1023
1023
|
})
|
|
1024
1024
|
draInterfaceCustomReport({
|
|
1025
1025
|
...reqData,
|
|
1026
1026
|
...data,
|
|
1027
1027
|
source: 'remote',
|
|
1028
1028
|
})
|
|
1029
1029
|
}
|
|
1030
1030
|
return changeRes
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
1033
1033
|
|
|
1034
1034
|
async receiveCoupon(param = {}, clientParams) {
|
|
1035
1035
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
1036
1036
|
return await this.gatewayReq(
|
|
1037
1037
|
'receiveShopCoupon',
|
|
1038
1038
|
{
|
|
1039
1039
|
operation: '3',
|
|
1040
1040
|
...param,
|
|
1041
1041
|
},
|
|
1042
1042
|
{ ...loginType, ...clientParams },
|
|
1043
1043
|
)
|
|
1044
1044
|
}
|
|
1045
1045
|
|
|
1046
1046
|
getCustomerCenterDispatch(params = {}) {
|
|
1047
1047
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
1048
1048
|
clientVersion: '9.2.0',
|
|
1049
1049
|
client: 'H5',
|
|
1050
1050
|
uuid: 88888,
|
|
1051
1051
|
appid: 'shopmember_m_jd_com',
|
|
1052
1052
|
})
|
|
1053
1053
|
}
|
|
1054
1054
|
|
|
1055
1055
|
batchAddCart(...args) {
|
|
1056
1056
|
let skuIds, num, showToast, giftCard
|
|
1057
1057
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
1058
1058
|
;[skuIds, num = 1, showToast = true, giftCard = false] = args
|
|
1059
1059
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
1060
1060
|
const params = args[0]
|
|
1061
1061
|
skuIds = params.skuIds
|
|
1062
1062
|
num = params.num || 1
|
|
1063
1063
|
showToast = params.showToast !== undefined ? params.showToast : true
|
|
1064
1064
|
giftCard = params.giftCard !== undefined ? params.giftCard : false
|
|
1065
1065
|
} else {
|
|
1066
1066
|
console.error('batchAddCart() Invalid arguments!', args)
|
|
1067
1067
|
const msg = isLanguageForEn
|
|
1068
1068
|
? 'Please retry later'
|
|
1069
1069
|
: '加入购物车失败,请稍后重试!'
|
|
1070
1070
|
showFailToast({
|
|
1071
1071
|
title: msg,
|
|
1072
1072
|
})
|
|
1073
1073
|
return Promise.resolve({
|
|
1074
1074
|
ok: false,
|
|
1075
1075
|
msg,
|
|
1076
1076
|
})
|
|
1077
1077
|
}
|
|
1078
1078
|
const addToWhereText = giftCard ? '购物清单' : '购物车'
|
|
1079
1079
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`
|
|
1080
1080
|
const failMsg = isLanguageForEn
|
|
1081
1081
|
? 'Please retry later'
|
|
1082
1082
|
: `加入${addToWhereText}失败,请稍后重试!`
|
|
1083
1083
|
if (skuIds) {
|
|
1084
1084
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
1085
1085
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
1086
1086
|
if (res?.ok) {
|
|
1087
1087
|
if (showToast && !res?.isOpenApp)
|
|
1088
1088
|
showSuccessToast({
|
|
1089
1089
|
title: successMsg,
|
|
1090
1090
|
})
|
|
1091
1091
|
} else {
|
|
1092
1092
|
showToast &&
|
|
1093
1093
|
showFailToast({
|
|
1094
1094
|
title: res?.errMsg || failMsg,
|
|
1095
1095
|
})
|
|
1096
1096
|
}
|
|
1097
1097
|
return Promise.resolve(res)
|
|
1098
1098
|
})
|
|
1099
1099
|
.catch((e) => {
|
|
1100
1100
|
console.log('调用加购方法异常=======>', e)
|
|
1101
1101
|
return Promise.resolve({
|
|
1102
1102
|
ok: false,
|
|
1103
1103
|
msg: failMsg,
|
|
1104
1104
|
})
|
|
1105
1105
|
})
|
|
1106
1106
|
} else {
|
|
1107
1107
|
return Promise.resolve({
|
|
1108
1108
|
ok: false,
|
|
1109
1109
|
msg: failMsg,
|
|
1110
1110
|
})
|
|
1111
1111
|
}
|
|
1112
1112
|
}
|
|
1113
1113
|
|
|
1114
1114
|
async giftCardAddCart(skuList, num) {
|
|
1115
1115
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
1116
1116
|
return this.gatewayReq(
|
|
1117
1117
|
'giftCardAddCart',
|
|
1118
1118
|
{
|
|
1119
1119
|
skuList,
|
|
1120
1120
|
num: Number(num),
|
|
1121
1121
|
},
|
|
1122
1122
|
{ ...loginType },
|
|
1123
1123
|
)
|
|
1124
1124
|
}
|
|
1125
1125
|
|
|
1126
1126
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
1127
1127
|
return new Promise((resolve) => {
|
|
1128
1128
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
1129
1129
|
if (productIdsArr.length > 0) {
|
|
1130
1130
|
if (giftCard) {
|
|
1131
1131
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
1132
1132
|
.then((res) => {
|
|
1133
1133
|
if (res?.code === '0' && res?.result?.value) {
|
|
1134
1134
|
resolve({
|
|
1135
1135
|
ok: true,
|
|
1136
1136
|
})
|
|
1137
1137
|
} else {
|
|
1138
1138
|
resolve({
|
|
1139
1139
|
ok: false,
|
|
1140
1140
|
msg: '加购失败,请稍后重试',
|
|
1141
1141
|
})
|
|
1142
1142
|
}
|
|
1143
1143
|
})
|
|
1144
1144
|
.catch((e) => {
|
|
1145
1145
|
console.error('礼品卡加车失败: ', e)
|
|
1146
1146
|
resolve({
|
|
1147
1147
|
ok: false,
|
|
1148
1148
|
msg: '加购失败,请稍后重试',
|
|
1149
1149
|
})
|
|
1150
1150
|
})
|
|
1151
1151
|
} else if (isJdApp) {
|
|
1152
1152
|
const nativeAddCartCallBack = `nativeBatchAddCart${
|
|
1153
1153
|
Date.now() + Number(productIdsArr[0]) + Number(addCardNum)
|
|
1154
1154
|
}`
|
|
1155
1155
|
console.log(
|
|
1156
1156
|
'==========>',
|
|
1157
1157
|
'原生批量加车, 回调方法保证唯一添加skuid和数量,nativeAddCartCallBack',
|
|
1158
1158
|
nativeAddCartCallBack,
|
|
1159
1159
|
)
|
|
1160
1160
|
if (!window[nativeAddCartCallBack]) {
|
|
1161
1161
|
window[nativeAddCartCallBack] = (res) => {
|
|
1162
1162
|
const getMessageJsonData =
|
|
1163
1163
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
1164
1164
|
console.info(
|
|
1165
1165
|
'获取批量加车原始数据',
|
|
1166
1166
|
res,
|
|
1167
1167
|
'====转换后的json数据为===',
|
|
1168
1168
|
getMessageJsonData,
|
|
1169
1169
|
)
|
|
1170
1170
|
try {
|
|
1171
1171
|
if (isAndroidDevice) {
|
|
1172
1172
|
getMessageJsonData?.status === '0'
|
|
1173
1173
|
? resolve({
|
|
1174
1174
|
ok: true,
|
|
1175
1175
|
msg: '已加入购物车!',
|
|
1176
1176
|
})
|
|
1177
1177
|
: resolve({
|
|
1178
1178
|
ok: false,
|
|
1179
1179
|
msg: '加购失败,请稍后重试',
|
|
1180
1180
|
})
|
|
1181
1181
|
} else if (isIosDevice) {
|
|
1182
1182
|
getMessageJsonData?.status === '0' &&
|
|
1183
1183
|
getMessageJsonData?.data?.code === 0
|
|
1184
1184
|
? resolve({
|
|
1185
1185
|
ok: true,
|
|
1186
1186
|
msg: '已加入购物车!',
|
|
1187
1187
|
})
|
|
1188
1188
|
: resolve({
|
|
1189
1189
|
ok: false,
|
|
1190
1190
|
msg: '批量加车失败,请稍后重试',
|
|
1191
1191
|
})
|
|
1192
1192
|
} else {
|
|
1193
1193
|
resolve({
|
|
1194
1194
|
ok: false,
|
|
1195
1195
|
msg: '加购失败,请稍后重试',
|
|
1196
1196
|
})
|
|
1197
1197
|
}
|
|
1198
1198
|
} catch (e) {
|
|
1199
1199
|
resolve({
|
|
1200
1200
|
ok: false,
|
|
1201
1201
|
msg: '加购失败,请稍后重试',
|
|
1202
1202
|
})
|
|
1203
1203
|
console.warn('批量加车转换数据异常', e)
|
|
1204
1204
|
}
|
|
1205
1205
|
window[nativeAddCartCallBack] = null
|
|
1206
1206
|
}
|
|
1207
1207
|
}
|
|
1208
1208
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
1209
1209
|
return isAndroidDevice
|
|
1210
1210
|
? {
|
|
1211
1211
|
sku: skuItem,
|
|
1212
1212
|
num: addCardNum,
|
|
1213
1213
|
}
|
|
1214
1214
|
: {
|
|
1215
1215
|
productCode: skuItem,
|
|
1216
1216
|
buyCount: addCardNum,
|
|
1217
1217
|
}
|
|
1218
1218
|
})
|
|
1219
1219
|
if (isAndroidDevice) {
|
|
1220
1220
|
const androidProductsStr = JSON.stringify(productsAddCartList)
|
|
1221
1221
|
callRouterAndroid({
|
|
1222
1222
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
|
|
1223
1223
|
routerParam: {
|
|
1224
1224
|
wareList: productsAddCartList,
|
|
1225
1225
|
},
|
|
1226
1226
|
callBackName: nativeAddCartCallBack,
|
|
1227
1227
|
})
|
|
1228
1228
|
} else if (isIosDevice) {
|
|
1229
1229
|
if (isLowAppVer) {
|
|
1230
1230
|
const lowVersionAppList = productIdsArr.map((skuItem) => {
|
|
1231
1231
|
return {
|
|
1232
1232
|
sku: skuItem,
|
|
1233
1233
|
num: addCardNum,
|
|
1234
1234
|
}
|
|
1235
1235
|
})
|
|
1236
1236
|
const lowVersionAppListStr = JSON.stringify(lowVersionAppList)
|
|
1237
1237
|
const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`
|
|
1238
1238
|
jump.side.jdJumpToWeb(url, {})
|
|
1239
1239
|
resolve({
|
|
1240
1240
|
ok: true,
|
|
1241
1241
|
isOpenApp: true,
|
|
1242
1242
|
msg: '加购完成, 加购结果请点击购物车确认',
|
|
1243
1243
|
})
|
|
1244
1244
|
} else {
|
|
1245
1245
|
callRouterIOS({
|
|
1246
1246
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
1247
1247
|
routerParam: {
|
|
1248
1248
|
sourceType: 'h5',
|
|
1249
1249
|
sourceValue: '店铺批量加购',
|
|
1250
1250
|
businessName: 'storeModel',
|
|
1251
1251
|
isNewMode: '1',
|
|
1252
1252
|
NotPassWebview: '1',
|
|
1253
1253
|
products: productsAddCartList,
|
|
1254
1254
|
},
|
|
1255
1255
|
callBackName: nativeAddCartCallBack,
|
|
1256
1256
|
})
|
|
1257
1257
|
}
|
|
1258
1258
|
}
|
|
1259
1259
|
} else if (isMin) {
|
|
1260
1260
|
console.log('==========>', '京购批量加车!')
|
|
1261
1261
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
1262
1262
|
return {
|
|
1263
1263
|
skuId: skuItem,
|
|
1264
1264
|
buyNum: addCardNum,
|
|
1265
1265
|
}
|
|
1266
1266
|
})
|
|
1267
1267
|
global.wxAppBizInstance
|
|
1268
1268
|
.addCart({ commArr: productsAddCartList })
|
|
1269
1269
|
.then((res) => {
|
|
1270
1270
|
console.log('dealCartSuccess: ', res)
|
|
1271
1271
|
resolve({
|
|
1272
1272
|
ok: true,
|
|
1273
1273
|
msg: '已加入购物车!',
|
|
1274
1274
|
data: res,
|
|
1275
1275
|
})
|
|
1276
1276
|
})
|
|
1277
1277
|
.catch((e) => {
|
|
1278
1278
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
1279
1279
|
resolve({
|
|
1280
1280
|
ok: false,
|
|
1281
1281
|
msg: '加购失败,请稍后重试',
|
|
1282
1282
|
})
|
|
1283
1283
|
})
|
|
1284
1284
|
} else {
|
|
1285
1285
|
console.log('==========>', 'M站批量加车!')
|
|
1286
1286
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) =>
|
|
1287
1287
|
resolve(res),
|
|
1288
1288
|
)
|
|
1289
1289
|
}
|
|
1290
1290
|
} else {
|
|
1291
1291
|
resolve({
|
|
1292
1292
|
ok: false,
|
|
1293
1293
|
msg: '加购sku不能为空',
|
|
1294
1294
|
})
|
|
1295
1295
|
}
|
|
1296
1296
|
})
|
|
1297
1297
|
}
|
|
1298
1298
|
|
|
1299
1299
|
productAddToCart(skuIdsStr, num) {
|
|
1300
1300
|
return new Promise((resolve) => {
|
|
1301
1301
|
if (window.AddcartToolObj) {
|
|
1302
1302
|
window.AddcartToolObj.addCart({
|
|
1303
1303
|
skuId: skuIdsStr,
|
|
1304
1304
|
num,
|
|
1305
1305
|
source: 'sjdpyw',
|
|
1306
1306
|
actId: '1',
|
|
1307
1307
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
1308
1308
|
sucFun(res) {
|
|
1309
1309
|
console.log(
|
|
1310
1310
|
'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
|
|
1311
1311
|
res,
|
|
1312
1312
|
)
|
|
1313
1313
|
if (res.errId === '0' && res.cartJson) {
|
|
1314
1314
|
resolve({
|
|
1315
1315
|
ok: true,
|
|
1316
1316
|
msg: '已加入购物车!',
|
|
1317
1317
|
...res,
|
|
1318
1318
|
})
|
|
1319
1319
|
} else {
|
|
1320
1320
|
if (res.errId === '13') {
|
|
1321
1321
|
global.doLogin()
|
|
1322
1322
|
} else {
|
|
1323
1323
|
resolve({
|
|
1324
1324
|
ok: false,
|
|
1325
1325
|
msg: '加购失败,请稍后重试',
|
|
1326
1326
|
...res,
|
|
1327
1327
|
})
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
1330
1330
|
},
|
|
1331
1331
|
failFun(err) {
|
|
1332
1332
|
console.log('fail', err)
|
|
1333
1333
|
resolve({
|
|
1334
1334
|
ok: false,
|
|
1335
1335
|
msg: '加购失败,请稍后重试',
|
|
1336
1336
|
...err,
|
|
1337
1337
|
})
|
|
1338
1338
|
},
|
|
1339
1339
|
})
|
|
1340
1340
|
} else {
|
|
1341
1341
|
resolve({
|
|
1342
1342
|
ok: false,
|
|
1343
1343
|
msg: '购物车方法检查异常',
|
|
1344
1344
|
})
|
|
1345
1345
|
}
|
|
1346
1346
|
})
|
|
1347
1347
|
}
|
|
1348
1348
|
bMallGetUserInfo = () => {
|
|
1349
1349
|
return getBMallUserInfo()
|
|
1350
1350
|
}
|
|
1351
1351
|
async bMallAddCart(params = {}) {
|
|
1352
1352
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
1353
1353
|
client: 'H5',
|
|
1354
1354
|
clientVersion: '5.5.0',
|
|
1355
1355
|
})
|
|
1356
1356
|
}
|
|
1357
1357
|
async bMallChangeCart(params = {}) {
|
|
1358
1358
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
1359
1359
|
client: 'H5',
|
|
1360
1360
|
clientVersion: '5.5.0',
|
|
1361
1361
|
})
|
|
1362
1362
|
}
|
|
1363
1363
|
async bMallRemoveCart(params = {}) {
|
|
1364
1364
|
return await this.gatewayReq(
|
|
1365
1365
|
'bmall_cartRemove',
|
|
1366
1366
|
params,
|
|
1367
1367
|
{
|
|
1368
1368
|
client: 'H5',
|
|
1369
1369
|
clientVersion: '5.5.0',
|
|
1370
1370
|
},
|
|
1371
1371
|
)
|
|
1372
1372
|
}
|
|
1373
1373
|
async bMallGetOmittedProduct(params = {}) {
|
|
1374
1374
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
1375
1375
|
client: 'H5',
|
|
1376
1376
|
clientVersion: '5.5.0',
|
|
1377
1377
|
})
|
|
1378
1378
|
}
|
|
1379
1379
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
1380
1380
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
1381
1381
|
return await this.bMallAddCart(params)
|
|
1382
1382
|
}
|
|
1383
1383
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
1384
1384
|
const params = await getParams({ bMallTag })
|
|
1385
1385
|
delete params.operations
|
|
1386
1386
|
return await this.bMallGetOmittedProduct(params)
|
|
1387
1387
|
}
|
|
1388
1388
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
1389
1389
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
1390
1390
|
return await this.bMallRemoveCart(params)
|
|
1391
1391
|
}
|
|
1392
1392
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
1393
1393
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
1394
1394
|
return await this.bMallChangeCart(params)
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
1397
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
1398
1398
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
1399
1399
|
return window?.bMallCartData
|
|
1400
1400
|
}
|
|
1401
1401
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
1402
1402
|
let items
|
|
1403
1403
|
if (cartData.ok && cartData.result) {
|
|
1404
1404
|
items = cartData?.result?.items || {}
|
|
1405
1405
|
}
|
|
1406
1406
|
if (isH5) {
|
|
1407
1407
|
window.bMallCartData = items
|
|
1408
1408
|
}
|
|
1409
1409
|
return items
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
1412
1412
|
async bMallCartHandle(goodItem, num) {
|
|
1413
1413
|
try {
|
|
1414
1414
|
const {
|
|
1415
1415
|
skuUuid,
|
|
1416
1416
|
limitUpper,
|
|
1417
1417
|
limitLower,
|
|
1418
1418
|
} = goodItem
|
|
1419
1419
|
let cartNum = Number(num)
|
|
1420
1420
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
1421
1421
|
cartNum = limitLower
|
|
1422
1422
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
1423
1423
|
cartNum = limitUpper
|
|
1424
1424
|
}
|
|
1425
1425
|
if (skuUuid && cartNum > 0) {
|
|
1426
1426
|
return this.bMallChangeCartService({
|
|
1427
1427
|
...goodItem,
|
|
1428
1428
|
skuUuid,
|
|
1429
1429
|
num: cartNum,
|
|
1430
1430
|
})
|
|
1431
1431
|
} else if (!skuUuid && cartNum > 0) {
|
|
1432
1432
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
1433
1433
|
} else if (skuUuid && !cartNum) {
|
|
1434
1434
|
return this.bMallRemoveCartService({
|
|
1435
1435
|
...goodItem,
|
|
1436
1436
|
skuUuid,
|
|
1437
1437
|
num: cartNum,
|
|
1438
1438
|
})
|
|
1439
1439
|
} else {
|
|
1440
1440
|
console.error('参数不全')
|
|
1441
1441
|
return false
|
|
1442
1442
|
}
|
|
1443
1443
|
} catch (e) {
|
|
1444
1444
|
console.error(e)
|
|
1445
1445
|
}
|
|
1446
1446
|
}
|