@conecli/cone-render 0.10.1-shop3.5 → 0.10.1-shop3.50
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/README.md +1 -1
- package/dist/common/accessibility.h5.ts +1 -0
- package/dist/common/accessibility.ts +0 -0
- 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/jdplayerSdk.weapp.tsx +1 -0
- package/dist/common/jssdk.ts +1 -1
- package/dist/common/jssdk.weapp.ts +1 -0
- package/dist/common/pageType.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/ErrorBoundary.tsx +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/CustomVideo/index.tsx +1 -1
- package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
- package/dist/components/base/Dialog/index.module.scss +11 -0
- package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
- package/dist/components/base/InViewRender/index.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
- package/dist/components/base/NetworkDataError/const.ts +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +118 -72
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Base/index.module.scss +12 -0
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.module.scss +24 -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/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/createReportFloorData.ts +1 -1
- package/dist/jumpEventReport/index.h5.ts +1 -1
- package/dist/jumpEventReport/index.jd.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
- 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.pc.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/language/en_US.json +231 -0
- package/dist/language/zh_CN.json +231 -0
- package/dist/language/zh_HK.json +231 -0
- 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/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/shopMember.weapp.ts +1 -0
- package/dist/open/api/util.ts +1 -1
- package/dist/open/index.ts +1 -1
- package/dist/sass/app.h5.scss +278 -224
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/fetchJsonp.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/http/httpInterceptors.weapp.ts +1 -0
- 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/harmonyCallRouter.h5.ts +1 -0
- package/dist/utils/harmonyCallRouter.ts +0 -0
- 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 → sColor.ts} +1 -1
- package/dist/utils/sColor.weapp.ts +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 +160 -141
- package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
- package/dist/utils/priceUtils.js +0 -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
|
cookiesStr: '',
|
|
743
743
|
requestHeaderContentType: {
|
|
744
744
|
jsonHeader: {
|
|
745
745
|
'content-type': 'application/json;charset=utf-8',
|
|
746
746
|
},
|
|
747
747
|
formDataHeader: {
|
|
748
748
|
'content-type': 'application/x-www-form-urlencoded',
|
|
749
749
|
},
|
|
750
750
|
},
|
|
751
751
|
requestBaseParam: {
|
|
752
752
|
data: null,
|
|
753
753
|
header: {
|
|
754
754
|
'content-type': 'application/json;charset=utf-8',
|
|
755
755
|
},
|
|
756
756
|
},
|
|
757
757
|
timeOut: 7000,
|
|
758
758
|
apiClientParams: {
|
|
759
759
|
appid: 'wx_mini_app',
|
|
760
760
|
clientVersion: '11.0.0',
|
|
761
761
|
client: 'wh5',
|
|
762
762
|
area: '1_72_2799_0',
|
|
763
763
|
screen: `${Math.ceil(
|
|
764
764
|
getSystemInfo?.screenWidth * devicePixelRatio,
|
|
765
765
|
)}*${Math.ceil(getSystemInfo?.screenHeight * devicePixelRatio)}`,
|
|
766
766
|
uuid: UUID,
|
|
767
767
|
loginType: '11',
|
|
768
768
|
},
|
|
769
769
|
public addressFetchInfo: {
|
|
770
770
|
reqState: boolean
|
|
771
771
|
promiseInstance: null | Promise<any>
|
|
772
772
|
}
|
|
773
773
|
public getPromotionConfig: {
|
|
774
774
|
projectId: null | string | number
|
|
775
775
|
pageId: null | string | number
|
|
776
776
|
}
|
|
777
777
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
778
778
|
public api: ServiceInterFace.HttpApi
|
|
779
779
|
public isPageDomain: boolean
|
|
780
780
|
public verifyColorList: string[]
|
|
781
781
|
constructor(opt) {
|
|
782
782
|
this._init()
|
|
783
783
|
this.addressFetchInfo = {
|
|
784
784
|
reqState: false,
|
|
785
785
|
promiseInstance: null,
|
|
786
786
|
}
|
|
787
787
|
this.getPromotionConfig = {
|
|
788
788
|
projectId: null,
|
|
789
789
|
pageId: null,
|
|
790
790
|
}
|
|
791
791
|
this._userAreaUpdateListen()
|
|
792
792
|
this.resInfo = this._getResConfig(opt)
|
|
793
793
|
this.api = api
|
|
794
794
|
this.isPageDomain = isH5
|
|
795
795
|
? window?.location?.hostname === PAGES_DOMAIN
|
|
796
796
|
: false
|
|
797
797
|
this.verifyColorList = [
|
|
798
798
|
...MobileVerifyColorList,
|
|
799
799
|
...AppVerifyColorList,
|
|
800
800
|
...JshopxVerifyColorList,
|
|
801
801
|
...BMallVerifyColorList,
|
|
802
802
|
]
|
|
803
803
|
}
|
|
804
804
|
_init(): void {
|
|
805
805
|
httpInterceptors.forEach((item) => {
|
|
806
806
|
Taro.addInterceptor((chain) => item(chain))
|
|
807
807
|
})
|
|
808
808
|
}
|
|
809
809
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
810
810
|
return Object.assign({}, DefaultConfig, opt)
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
_userAreaUpdateListen() {
|
|
814
814
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
|
|
815
815
|
this.updateApiClientParamsResInfo(areaInfo);
|
|
816
816
|
});
|
|
817
817
|
}
|
|
818
818
|
updateApiClientParamsResInfo(opt = {}) {
|
|
819
819
|
const { area, realTimeArea, ...others } = opt;
|
|
820
820
|
this.resInfo.apiClientParams = {
|
|
821
821
|
...this.resInfo.apiClientParams,
|
|
822
822
|
...others,
|
|
823
823
|
};
|
|
824
824
|
area && area !== '' && (this.resInfo.apiClientParams.area = area);
|
|
825
825
|
realTimeArea &&
|
|
826
826
|
realTimeArea !== '' &&
|
|
827
827
|
(this.resInfo.apiClientParams.realTimeArea = realTimeArea);
|
|
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(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
|
|
850
850
|
if (functionId === 'receiveShopCoupon') {
|
|
851
851
|
clientParams = Object.assign(
|
|
852
852
|
{},
|
|
853
853
|
{
|
|
854
854
|
loginType: '1',
|
|
855
855
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
856
856
|
},
|
|
857
857
|
clientParams,
|
|
858
858
|
)
|
|
859
859
|
}
|
|
860
860
|
const apiClientParams = Object.assign(
|
|
861
861
|
{},
|
|
862
862
|
this.resInfo.apiClientParams,
|
|
863
863
|
clientParams,
|
|
864
864
|
)
|
|
865
865
|
const isColorVerify = this.verifyColorList.includes(functionId);
|
|
866
866
|
const getReqData = {
|
|
867
867
|
functionId: functionId,
|
|
868
868
|
body: JSON.stringify(bodyParams),
|
|
869
869
|
t: Date.now(),
|
|
870
870
|
...apiClientParams,
|
|
871
871
|
}
|
|
872
872
|
const requestParams = {
|
|
873
873
|
functionId: getReqData?.functionId,
|
|
874
874
|
body: getReqData?.body,
|
|
875
875
|
appid: getReqData?.appid,
|
|
876
876
|
client: getReqData?.client,
|
|
877
877
|
clientVersion: getReqData?.clientVersion,
|
|
878
878
|
area: getReqData?.area,
|
|
879
879
|
requestTimeStamp: getReqData?.t,
|
|
880
880
|
}
|
|
881
881
|
return http
|
|
882
882
|
.request({
|
|
883
883
|
url: this.api.apiFunc,
|
|
884
884
|
data: getReqData,
|
|
885
885
|
isColorVerify,
|
|
886
886
|
})
|
|
887
887
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
888
888
|
const { statusCode, data, status, msg } = res
|
|
889
889
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
890
890
|
ok: true,
|
|
891
891
|
}
|
|
892
892
|
if ((statusCode === 200 || status === '0') && data) {
|
|
893
893
|
changeRes = this.dealResponseFormatRes(data, getReqData)
|
|
894
894
|
return changeRes
|
|
895
895
|
} else {
|
|
896
896
|
sgmCustomReport({
|
|
897
897
|
code: getSgmCustomCode('interface_data_error'),
|
|
898
898
|
msg: {
|
|
899
899
|
subMsg: '接口请求异常',
|
|
900
900
|
functionId,
|
|
901
901
|
statusCode,
|
|
902
902
|
source: 'remote',
|
|
903
903
|
status,
|
|
904
904
|
msg,
|
|
905
905
|
requestParams,
|
|
906
906
|
},
|
|
907
907
|
})
|
|
908
908
|
draInterfaceCustomReport({
|
|
909
909
|
...getReqData,
|
|
910
910
|
...res,
|
|
911
911
|
source: 'remote',
|
|
912
912
|
})
|
|
913
913
|
changeRes = {
|
|
914
914
|
...data,
|
|
915
915
|
statusCode,
|
|
916
916
|
status,
|
|
917
917
|
msg,
|
|
918
918
|
ok: false,
|
|
919
919
|
}
|
|
920
920
|
return changeRes
|
|
921
921
|
}
|
|
922
922
|
})
|
|
923
923
|
.catch((res) => {
|
|
924
924
|
const propertyNames = Object.getOwnPropertyNames(res)
|
|
925
925
|
const resObject = {}
|
|
926
926
|
propertyNames.forEach((propertyName) => {
|
|
927
927
|
resObject[propertyName] = res[propertyName]
|
|
928
928
|
})
|
|
929
929
|
sgmCustomReport({
|
|
930
930
|
code: getSgmCustomCode('interface_data_error'),
|
|
931
931
|
msg: {
|
|
932
932
|
subMsg: '接口请求错误',
|
|
933
933
|
functionId,
|
|
934
934
|
source: 'remote',
|
|
935
935
|
requestParams,
|
|
936
936
|
catchError: resObject,
|
|
937
937
|
},
|
|
938
938
|
})
|
|
939
939
|
draInterfaceCustomReport({
|
|
940
940
|
...getReqData,
|
|
941
941
|
...resObject,
|
|
942
942
|
source: 'remote',
|
|
943
943
|
})
|
|
944
944
|
return {
|
|
945
945
|
...resObject,
|
|
946
946
|
ok: false,
|
|
947
947
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
948
948
|
})
|
|
949
949
|
}
|
|
950
950
|
|
|
951
951
|
dealResponseFormatRes(data, reqData) {
|
|
952
952
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
953
953
|
ok: true,
|
|
954
954
|
}
|
|
955
955
|
const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
|
|
956
956
|
? Number(data.code)
|
|
957
957
|
: -1
|
|
958
958
|
const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
|
|
959
959
|
? Number(data.subCode)
|
|
960
960
|
: -1
|
|
961
961
|
if (
|
|
962
962
|
data.success === true ||
|
|
963
963
|
data.isSuccess ||
|
|
964
964
|
resCode === 0 ||
|
|
965
965
|
resCode === 200 ||
|
|
966
966
|
subCode === 0
|
|
967
967
|
) {
|
|
968
968
|
changeRes = {
|
|
969
969
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
970
970
|
? data.result
|
|
971
971
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
972
972
|
? data.data
|
|
973
973
|
: data,
|
|
974
974
|
code: data.code ?? 200,
|
|
975
975
|
ok: true,
|
|
976
976
|
source: data,
|
|
977
977
|
}
|
|
978
978
|
return changeRes
|
|
979
979
|
} else {
|
|
980
980
|
changeRes = {
|
|
981
981
|
...data,
|
|
982
982
|
ok: false,
|
|
983
983
|
}
|
|
984
984
|
if (reqData && resCode !== 3) {
|
|
985
985
|
const getReportMsgData = reqData['hybridId']
|
|
986
986
|
? {
|
|
987
987
|
subMsg: '预加载接口请求数据异常',
|
|
988
988
|
hybridId: reqData?.hybridId,
|
|
989
989
|
requestId: reqData?.requestId,
|
|
990
990
|
param: reqData?.param,
|
|
991
991
|
source: 'remote',
|
|
992
992
|
}
|
|
993
993
|
: {
|
|
994
994
|
subMsg: '接口请求返回数据异常',
|
|
995
995
|
functionId: reqData?.functionId,
|
|
996
996
|
code: resCode,
|
|
997
997
|
source: 'remote',
|
|
998
998
|
requestParams: {
|
|
999
999
|
functionId: reqData?.functionId,
|
|
1000
1000
|
body: reqData?.body,
|
|
1001
1001
|
appid: reqData?.appid,
|
|
1002
1002
|
client: reqData?.client,
|
|
1003
1003
|
clientVersion: reqData?.clientVersion,
|
|
1004
1004
|
area: reqData?.area,
|
|
1005
1005
|
requestTimeStamp: reqData?.t,
|
|
1006
1006
|
},
|
|
1007
1007
|
resData: data,
|
|
1008
1008
|
}
|
|
1009
1009
|
sgmCustomReport({
|
|
1010
1010
|
code: getSgmCustomCode('interface_data_error'),
|
|
1011
1011
|
msg: getReportMsgData,
|
|
1012
1012
|
})
|
|
1013
1013
|
draInterfaceCustomReport({
|
|
1014
1014
|
...reqData,
|
|
1015
1015
|
...data,
|
|
1016
1016
|
source: 'remote',
|
|
1017
1017
|
})
|
|
1018
1018
|
}
|
|
1019
1019
|
return changeRes
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
1023
|
async receiveCoupon(param = {}, clientParams) {
|
|
1024
1024
|
console.warn('receiveCoupon 方法在微信京购小程序环境未经验证,请不要使用!');
|
|
1025
1025
|
return await this.gatewayReq(
|
|
1026
1026
|
'receiveShopCoupon',
|
|
1027
1027
|
{
|
|
1028
1028
|
operation: '3',
|
|
1029
1029
|
...param,
|
|
1030
1030
|
},
|
|
1031
1031
|
{ ...clientParams },
|
|
1032
1032
|
);
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
1035
|
getCustomerCenterDispatch(params = {}) {
|
|
1036
1036
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
1037
1037
|
clientVersion: '9.2.0',
|
|
1038
1038
|
client: 'H5',
|
|
1039
1039
|
uuid: 88888,
|
|
1040
1040
|
appid: 'shopmember_m_jd_com',
|
|
1041
1041
|
})
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
1044
|
batchAddCart(...args) {
|
|
1045
1045
|
let skuIds, num, showToast, giftCard;
|
|
1046
1046
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
1047
1047
|
[skuIds, num = 1, showToast = true, giftCard = false] = args;
|
|
1048
1048
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
1049
1049
|
const params = args[0];
|
|
1050
1050
|
skuIds = params.skuIds;
|
|
1051
1051
|
num = params.num || 1;
|
|
1052
1052
|
showToast = params.showToast !== undefined ? params.showToast : true;
|
|
1053
1053
|
giftCard = params.giftCard !== undefined ? params.giftCard : false;
|
|
1054
1054
|
} else {
|
|
1055
1055
|
console.error('batchAddCart() Invalid arguments!', args);
|
|
1056
1056
|
const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
|
|
1057
1057
|
showFailToast({
|
|
1058
1058
|
title: msg,
|
|
1059
1059
|
});
|
|
1060
1060
|
return Promise.resolve({
|
|
1061
1061
|
ok: false,
|
|
1062
1062
|
msg,
|
|
1063
1063
|
});
|
|
1064
1064
|
}
|
|
1065
1065
|
const addToWhereText = giftCard ? '购物清单' : '购物车';
|
|
1066
1066
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
|
|
1067
1067
|
const failMsg = isLanguageForEn
|
|
1068
1068
|
? 'Please retry later'
|
|
1069
1069
|
: `加入${addToWhereText}失败,请稍后重试!`;
|
|
1070
1070
|
if (skuIds) {
|
|
1071
1071
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
1072
1072
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
1073
1073
|
if (res?.ok) {
|
|
1074
1074
|
if (showToast && !res?.isOpenApp)
|
|
1075
1075
|
showSuccessToast({
|
|
1076
1076
|
title: successMsg,
|
|
1077
1077
|
});
|
|
1078
1078
|
} else {
|
|
1079
1079
|
showToast &&
|
|
1080
1080
|
showFailToast({
|
|
1081
1081
|
title: res?.errMsg || failMsg,
|
|
1082
1082
|
});
|
|
1083
1083
|
}
|
|
1084
1084
|
return Promise.resolve(res)
|
|
1085
1085
|
})
|
|
1086
1086
|
.catch((e) => {
|
|
1087
1087
|
console.log('调用加购方法异常=======>', e)
|
|
1088
1088
|
return Promise.resolve({
|
|
1089
1089
|
ok: false,
|
|
1090
1090
|
msg: failMsg,
|
|
1091
1091
|
});
|
|
1092
1092
|
});
|
|
1093
1093
|
} else {
|
|
1094
1094
|
return Promise.resolve({
|
|
1095
1095
|
ok: false,
|
|
1096
1096
|
msg: failMsg,
|
|
1097
1097
|
});
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
1100
|
|
|
1101
1101
|
async giftCardAddCart(skuList, num) {
|
|
1102
1102
|
const loginType = isPc ? { loginType: 3 } : {};
|
|
1103
1103
|
return this.gatewayReq(
|
|
1104
1104
|
'giftCardAddCart',
|
|
1105
1105
|
{
|
|
1106
1106
|
skuList,
|
|
1107
1107
|
num: Number(num),
|
|
1108
1108
|
},
|
|
1109
1109
|
{ ...loginType },
|
|
1110
1110
|
);
|
|
1111
1111
|
}
|
|
1112
1112
|
|
|
1113
1113
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
1114
1114
|
return new Promise((resolve) => {
|
|
1115
1115
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
1116
1116
|
if (productIdsArr.length > 0) {
|
|
1117
1117
|
if (giftCard) {
|
|
1118
1118
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
1119
1119
|
.then((res) => {
|
|
1120
1120
|
if (res?.code === '0' && res?.result?.value) {
|
|
1121
1121
|
resolve({
|
|
1122
1122
|
ok: true,
|
|
1123
1123
|
});
|
|
1124
1124
|
} else {
|
|
1125
1125
|
resolve({
|
|
1126
1126
|
ok: false,
|
|
1127
1127
|
msg: '加购失败,请稍后重试',
|
|
1128
1128
|
});
|
|
1129
1129
|
}
|
|
1130
1130
|
})
|
|
1131
1131
|
.catch((e) => {
|
|
1132
1132
|
console.error('礼品卡加车失败: ', e);
|
|
1133
1133
|
resolve({
|
|
1134
1134
|
ok: false,
|
|
1135
1135
|
msg: '加购失败,请稍后重试',
|
|
1136
1136
|
});
|
|
1137
1137
|
});
|
|
1138
1138
|
} else if (isJdApp) {
|
|
1139
1139
|
console.log('==========>', 'app原生批量加车!,小程序端暂不涉及');
|
|
1140
1140
|
} else if (isMin) {
|
|
1141
1141
|
console.log('==========>', '京购批量加车!')
|
|
1142
1142
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
1143
1143
|
return {
|
|
1144
1144
|
skuId: skuItem,
|
|
1145
1145
|
buyNum: addCardNum,
|
|
1146
1146
|
}
|
|
1147
1147
|
})
|
|
1148
1148
|
global.wxAppBizInstance
|
|
1149
1149
|
.addCart({ commArr: productsAddCartList })
|
|
1150
1150
|
.then((res) => {
|
|
1151
1151
|
console.log('dealCartSuccess: ', res)
|
|
1152
1152
|
resolve({
|
|
1153
1153
|
ok: true,
|
|
1154
1154
|
msg: '已加入购物车!',
|
|
1155
1155
|
data: res,
|
|
1156
1156
|
})
|
|
1157
1157
|
})
|
|
1158
1158
|
.catch((e) => {
|
|
1159
1159
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
1160
1160
|
resolve({
|
|
1161
1161
|
ok: false,
|
|
1162
1162
|
msg: '加购失败,请稍后重试',
|
|
1163
1163
|
})
|
|
1164
1164
|
})
|
|
1165
1165
|
} else {
|
|
1166
1166
|
console.log('==========>', 'M站批量加车!')
|
|
1167
1167
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) =>
|
|
1168
1168
|
resolve(res),
|
|
1169
1169
|
)
|
|
1170
1170
|
}
|
|
1171
1171
|
} else {
|
|
1172
1172
|
resolve({
|
|
1173
1173
|
ok: false,
|
|
1174
1174
|
msg: '加购sku不能为空',
|
|
1175
1175
|
})
|
|
1176
1176
|
}
|
|
1177
1177
|
})
|
|
1178
1178
|
}
|
|
1179
1179
|
|
|
1180
1180
|
productAddToCart() {
|
|
1181
1181
|
return Promise.resolve({
|
|
1182
1182
|
ok: false,
|
|
1183
1183
|
msg: 'productAddToCart暂不支持小程序',
|
|
1184
1184
|
});
|
|
1185
1185
|
}
|
|
1186
1186
|
bMallGetUserInfo(){
|
|
1187
1187
|
return Promise.resolve({
|
|
1188
1188
|
ok: false,
|
|
1189
1189
|
msg: 'productAddToCart暂不支持小程序',
|
|
1190
1190
|
});
|
|
1191
1191
|
}
|
|
1192
1192
|
bMallGetSkuNumApi(){
|
|
1193
1193
|
return Promise.resolve({
|
|
1194
1194
|
ok: false,
|
|
1195
1195
|
msg: 'productAddToCart暂不支持小程序',
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
1198
1198
|
bMallCartHandle(){
|
|
1199
1199
|
return Promise.resolve({
|
|
1200
1200
|
ok: false,
|
|
1201
1201
|
msg: 'productAddToCart暂不支持小程序',
|
|
1202
1202
|
});
|
|
1203
1203
|
}
|