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