@conecli/cone-render 0.10.1-beta.3 → 0.10.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/const.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/components/base/ExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.module.scss +8 -0
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/open/api/request.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- 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/utils.ts +1 -1
- package/package.json +23 -23
|
@@ -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
|
cookiesStr: '',
|
|
13
12
|
requestHeaderContentType: {
|
|
14
13
|
jsonHeader: {
|
|
15
14
|
'content-type': 'application/json;charset=utf-8',
|
|
16
15
|
},
|
|
17
16
|
formDataHeader: {
|
|
18
17
|
'content-type': 'application/x-www-form-urlencoded',
|
|
19
18
|
},
|
|
20
19
|
},
|
|
21
20
|
requestBaseParam: {
|
|
22
21
|
data: null,
|
|
23
22
|
header: {
|
|
24
23
|
'content-type': 'application/json;charset=utf-8',
|
|
25
24
|
},
|
|
26
25
|
},
|
|
27
26
|
timeOut: 7000,
|
|
28
27
|
apiClientParams: {
|
|
29
28
|
clientVersion:
|
|
30
29
|
isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
31
30
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
32
31
|
area: '1_72_2799_0',
|
|
33
32
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(window.screen?.height * devicePixelRatio)}`,
|
|
34
33
|
uuid: UUID,
|
|
35
34
|
},
|
|
36
35
|
public addressFetchInfo: {
|
|
37
36
|
reqState: boolean
|
|
38
37
|
promiseInstance: null | Promise<any>
|
|
39
38
|
}
|
|
40
39
|
public getPromotionConfig: {
|
|
41
40
|
projectId: null | string | number
|
|
42
41
|
pageId: null | string | number
|
|
43
42
|
}
|
|
44
43
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
45
44
|
public api: ServiceInterFace.HttpApi
|
|
46
45
|
public isPageDomain: boolean
|
|
47
46
|
public verifyColorList: string[]
|
|
48
47
|
constructor(opt) {
|
|
49
48
|
this._init()
|
|
50
49
|
this.addressFetchInfo = {
|
|
51
50
|
reqState: false,
|
|
52
51
|
promiseInstance: null,
|
|
53
52
|
}
|
|
54
53
|
this.getPromotionConfig = {
|
|
55
54
|
projectId: null,
|
|
56
55
|
pageId: null,
|
|
57
56
|
}
|
|
58
57
|
this._userAreaUpdateListen()
|
|
59
58
|
this.resInfo = this._getResConfig(opt)
|
|
60
59
|
this.api = api
|
|
61
60
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
|
|
62
61
|
this.verifyColorList = [
|
|
63
62
|
...MobileVerifyColorList,
|
|
64
63
|
...AppVerifyColorList,
|
|
65
64
|
...JshopxVerifyColorList,
|
|
66
65
|
...BMallVerifyColorList,
|
|
67
66
|
]
|
|
68
67
|
}
|
|
69
68
|
_init(): void {
|
|
70
69
|
httpInterceptors.forEach((item) => {
|
|
71
70
|
Taro.addInterceptor((chain) => item(chain))
|
|
72
71
|
})
|
|
73
72
|
}
|
|
74
73
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
75
74
|
return Object.assign({}, DefaultConfig, opt)
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
_userAreaUpdateListen() {
|
|
79
78
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
80
79
|
this.updateApiClientParamsResInfo({
|
|
81
80
|
area,
|
|
82
81
|
})
|
|
83
82
|
})
|
|
84
83
|
}
|
|
85
84
|
updateApiClientParamsResInfo(opt = {}) {
|
|
86
85
|
this.resInfo.apiClientParams = {
|
|
87
86
|
...this.resInfo.apiClientParams,
|
|
88
87
|
...opt,
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
checkFunctionIdToReturnAppId(functionId) {
|
|
93
92
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
94
93
|
return APPID.JSHOPX_COLOR_APPID
|
|
95
94
|
} else if (
|
|
96
95
|
this.isPageDomain &&
|
|
97
96
|
PagesColorFunctionIdList.includes(functionId)
|
|
98
97
|
) {
|
|
99
98
|
return APPID.PAGES_COLOR_APPID
|
|
100
99
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
101
100
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
102
101
|
}else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
103
102
|
return APPID.B2B_COLOR_APPID
|
|
104
103
|
} else if (isPc) {
|
|
105
104
|
return APPID.MALL_COLOR_APPID
|
|
106
105
|
} else {
|
|
107
106
|
return APPID.SHOP_COLOR_APPID
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
gatewayReq(
|
|
112
111
|
functionId: string,
|
|
113
112
|
bodyParams = {},
|
|
114
113
|
clientParams = {},
|
|
115
114
|
): Promise<any> {
|
|
116
115
|
if (
|
|
117
116
|
functionId === 'receiveShopCoupon' &&
|
|
118
117
|
((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) || isWxMinAndWxapp)
|
|
119
118
|
) {
|
|
120
119
|
clientParams = Object.assign(
|
|
121
120
|
{},
|
|
122
121
|
{
|
|
123
122
|
loginType: '1',
|
|
124
123
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
125
124
|
},
|
|
126
125
|
clientParams,
|
|
127
126
|
)
|
|
128
127
|
}
|
|
129
128
|
const apiClientParams = Object.assign(
|
|
130
129
|
{},
|
|
131
130
|
this.resInfo.apiClientParams,
|
|
132
131
|
clientParams,
|
|
133
132
|
)
|
|
134
133
|
typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
135
134
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
136
135
|
const getReqData = {
|
|
137
136
|
functionId: functionId,
|
|
138
137
|
body: JSON.stringify(bodyParams),
|
|
139
138
|
t: Date.now(),
|
|
140
139
|
...apiClientParams,
|
|
141
140
|
}
|
|
142
141
|
return http
|
|
143
142
|
.request({
|
|
144
143
|
url: this.api.apiFunc,
|
|
145
144
|
data: getReqData,
|
|
146
145
|
isColorVerify,
|
|
147
146
|
})
|
|
148
147
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
149
148
|
const { statusCode, data } = res
|
|
150
149
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
151
150
|
ok: true,
|
|
152
151
|
}
|
|
153
152
|
if (statusCode === 200 && data) {
|
|
154
153
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
155
154
|
? Number(res.data.code)
|
|
156
155
|
: -1
|
|
157
156
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
158
157
|
res.data,
|
|
159
158
|
'subCode',
|
|
160
159
|
)
|
|
161
160
|
? Number(res.data.subCode)
|
|
162
161
|
: -1
|
|
163
162
|
if (
|
|
164
163
|
data.success === true ||
|
|
165
164
|
data.isSuccess ||
|
|
166
165
|
resCode === 0 ||
|
|
167
166
|
resCode === 200 ||
|
|
168
167
|
subCode === 0
|
|
169
168
|
) {
|
|
170
169
|
changeRes = {
|
|
171
170
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
172
171
|
? data.result
|
|
173
172
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
174
173
|
? data.data
|
|
175
174
|
: data,
|
|
176
175
|
code: data.code || 200,
|
|
177
176
|
ok: true,
|
|
178
177
|
source: data,
|
|
179
178
|
}
|
|
180
179
|
return changeRes
|
|
181
180
|
} else {
|
|
182
181
|
changeRes = {
|
|
183
182
|
...data,
|
|
184
183
|
ok: false,
|
|
185
184
|
statusCode: res.statusCode,
|
|
186
185
|
}
|
|
187
186
|
return changeRes
|
|
188
187
|
}
|
|
189
188
|
} else {
|
|
190
189
|
changeRes = {
|
|
191
190
|
...data,
|
|
192
191
|
ok: false,
|
|
193
192
|
statusCode: res.statusCode,
|
|
194
193
|
}
|
|
195
194
|
return changeRes
|
|
196
195
|
}
|
|
197
196
|
})
|
|
198
197
|
.catch((res) => {
|
|
199
198
|
return {
|
|
200
199
|
...res,
|
|
201
200
|
ok: false,
|
|
202
201
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
203
202
|
})
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
async receiveCoupon(param = {}, clientParams) {
|
|
207
206
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
208
207
|
return await this.gatewayReq(
|
|
209
208
|
'receiveShopCoupon',
|
|
210
209
|
{
|
|
211
210
|
operation: '3',
|
|
212
211
|
...param,
|
|
213
212
|
},
|
|
214
213
|
{ ...loginType, ...clientParams },
|
|
215
214
|
)
|
|
216
215
|
}
|
|
217
216
|
|
|
218
217
|
getCustomerCenterDispatch(params = {}) {
|
|
219
218
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
220
219
|
clientVersion: '9.2.0',
|
|
221
220
|
client: 'H5',
|
|
222
221
|
uuid: 88888,
|
|
223
222
|
appid: 'shopmember_m_jd_com',
|
|
224
223
|
})
|
|
225
224
|
}
|
|
226
225
|
bMallGetUserInfo = () => {
|
|
227
226
|
return getBMallUserInfo()
|
|
228
227
|
}
|
|
229
228
|
async bMallAddCart(params = {}) {
|
|
230
229
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
231
230
|
client: 'H5',
|
|
232
231
|
clientVersion: '5.5.0'
|
|
233
232
|
})
|
|
234
233
|
}
|
|
235
234
|
async bMallChangeCart(params = {}) {
|
|
236
235
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
237
236
|
client: 'H5',
|
|
238
237
|
clientVersion: '5.5.0'
|
|
239
238
|
})
|
|
240
239
|
}
|
|
241
240
|
async bMallRemoveCart(params = {}) {
|
|
242
241
|
return await this.gatewayReq(
|
|
243
242
|
'bmall_cartRemove',
|
|
244
243
|
params,
|
|
245
244
|
{
|
|
246
245
|
client: 'H5',
|
|
247
246
|
clientVersion: '5.5.0'
|
|
248
247
|
},
|
|
249
248
|
)
|
|
250
249
|
}
|
|
251
250
|
async bMallGetOmittedProduct(params = {}) {
|
|
252
251
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
253
252
|
client: 'H5',
|
|
254
253
|
clientVersion: '5.5.0'
|
|
255
254
|
})
|
|
256
255
|
}
|
|
257
256
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
258
257
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
259
258
|
return await this.bMallAddCart(params)
|
|
260
259
|
}
|
|
261
260
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
262
261
|
const params = await getParams({ bMallTag })
|
|
263
262
|
delete params.operations
|
|
264
263
|
return await this.bMallGetOmittedProduct(params)
|
|
265
264
|
}
|
|
266
265
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
267
266
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
268
267
|
return await this.bMallRemoveCart(params)
|
|
269
268
|
}
|
|
270
269
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
271
270
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
272
271
|
return await this.bMallChangeCart(params)
|
|
273
272
|
}
|
|
274
273
|
|
|
275
274
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
276
275
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
277
276
|
return window?.bMallCartData
|
|
278
277
|
}
|
|
279
278
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
280
279
|
let items
|
|
281
280
|
if (cartData.ok && cartData.result) {
|
|
282
281
|
items = cartData?.result?.items || {}
|
|
283
282
|
}
|
|
284
283
|
if (isH5) {
|
|
285
284
|
window.bMallCartData = items
|
|
286
285
|
}
|
|
287
286
|
return items
|
|
288
287
|
}
|
|
289
288
|
|
|
290
289
|
async bMallCartHandle(goodItem, num) {
|
|
291
290
|
try {
|
|
292
291
|
const {
|
|
293
292
|
skuUuid,
|
|
294
293
|
limitUpper,
|
|
295
294
|
limitLower,
|
|
296
295
|
} = goodItem
|
|
297
296
|
let cartNum = Number(num)
|
|
298
297
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
299
298
|
cartNum = limitLower
|
|
300
299
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
301
300
|
cartNum = limitUpper
|
|
302
301
|
}
|
|
303
302
|
if (skuUuid && cartNum > 0) {
|
|
304
303
|
return this.bMallChangeCartService({
|
|
305
304
|
...goodItem,
|
|
306
305
|
skuUuid,
|
|
307
306
|
num: cartNum,
|
|
308
307
|
})
|
|
309
308
|
} else if (!skuUuid && cartNum > 0) {
|
|
310
309
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
311
310
|
} else if (skuUuid && !cartNum) {
|
|
312
311
|
return this.bMallRemoveCartService({
|
|
313
312
|
...goodItem,
|
|
314
313
|
skuUuid,
|
|
315
314
|
num: cartNum,
|
|
316
315
|
})
|
|
317
316
|
} else {
|
|
318
317
|
console.error('参数不全')
|
|
319
318
|
return false
|
|
320
319
|
}
|
|
321
320
|
} catch (e) {
|
|
322
321
|
console.error(e)
|
|
323
322
|
}
|
|
324
323
|
}
|
|
324
|
+
import Taro from '@tarojs/taro'
|
|
325
325
|
APPID,
|
|
326
326
|
JshopxColorFunctionIdList,
|
|
327
327
|
PagesColorFunctionIdList,
|
|
328
328
|
PAGES_DOMAIN,
|
|
329
329
|
B2BColorFunctionIdList,
|
|
330
330
|
MobileVerifyColorList,
|
|
331
331
|
AppVerifyColorList,
|
|
332
332
|
JshopxVerifyColorList,
|
|
333
333
|
BMallVerifyColorList,
|
|
334
334
|
shopMemberColorFunctionIdList
|
|
335
335
|
callRouterIOS,
|
|
336
336
|
callRouterAndroid,
|
|
337
337
|
cookiesStr: '',
|
|
338
338
|
requestHeaderContentType: {
|
|
339
339
|
jsonHeader: {
|
|
340
340
|
'content-type': 'application/json;charset=utf-8',
|
|
341
341
|
},
|
|
342
342
|
formDataHeader: {
|
|
343
343
|
'content-type': 'application/x-www-form-urlencoded',
|
|
344
344
|
},
|
|
345
345
|
},
|
|
346
346
|
requestBaseParam: {
|
|
347
347
|
data: null,
|
|
348
348
|
header: {
|
|
349
349
|
'content-type': 'application/json;charset=utf-8',
|
|
350
350
|
},
|
|
351
351
|
},
|
|
352
352
|
timeOut: 7000,
|
|
353
353
|
apiClientParams: {
|
|
354
354
|
clientVersion:
|
|
355
355
|
isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
356
356
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
357
357
|
area: '1_72_2799_0',
|
|
358
358
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(window.screen?.height * devicePixelRatio)}`,
|
|
359
359
|
uuid: UUID,
|
|
360
360
|
},
|
|
361
361
|
public addressFetchInfo: {
|
|
362
362
|
reqState: boolean
|
|
363
363
|
promiseInstance: null | Promise<any>
|
|
364
364
|
}
|
|
365
365
|
public getPromotionConfig: {
|
|
366
366
|
projectId: null | string | number
|
|
367
367
|
pageId: null | string | number
|
|
368
368
|
}
|
|
369
369
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
370
370
|
public api: ServiceInterFace.HttpApi
|
|
371
371
|
public isPageDomain: boolean
|
|
372
372
|
public verifyColorList: string[]
|
|
373
373
|
constructor(opt) {
|
|
374
374
|
this._init()
|
|
375
375
|
this.addressFetchInfo = {
|
|
376
376
|
reqState: false,
|
|
377
377
|
promiseInstance: null,
|
|
378
378
|
}
|
|
379
379
|
this.getPromotionConfig = {
|
|
380
380
|
projectId: null,
|
|
381
381
|
pageId: null,
|
|
382
382
|
}
|
|
383
383
|
this._userAreaUpdateListen()
|
|
384
384
|
this.resInfo = this._getResConfig(opt)
|
|
385
385
|
this.api = api
|
|
386
386
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
|
|
387
387
|
this.verifyColorList = [
|
|
388
388
|
...MobileVerifyColorList,
|
|
389
389
|
...AppVerifyColorList,
|
|
390
390
|
...JshopxVerifyColorList,
|
|
391
391
|
...BMallVerifyColorList,
|
|
392
392
|
]
|
|
393
393
|
}
|
|
394
394
|
_init(): void {
|
|
395
395
|
httpInterceptors.forEach((item) => {
|
|
396
396
|
Taro.addInterceptor((chain) => item(chain))
|
|
397
397
|
})
|
|
398
398
|
}
|
|
399
399
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
400
400
|
return Object.assign({}, DefaultConfig, opt)
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
_userAreaUpdateListen() {
|
|
404
404
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
405
405
|
this.updateApiClientParamsResInfo({
|
|
406
406
|
area,
|
|
407
407
|
})
|
|
408
408
|
})
|
|
409
409
|
}
|
|
410
410
|
updateApiClientParamsResInfo(opt = {}) {
|
|
411
411
|
this.resInfo.apiClientParams = {
|
|
412
412
|
...this.resInfo.apiClientParams,
|
|
413
413
|
...opt,
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
|
|
417
417
|
checkFunctionIdToReturnAppId(functionId) {
|
|
418
418
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
419
419
|
return APPID.JSHOPX_COLOR_APPID
|
|
420
420
|
} else if (
|
|
421
421
|
this.isPageDomain &&
|
|
422
422
|
PagesColorFunctionIdList.includes(functionId)
|
|
423
423
|
) {
|
|
424
424
|
return APPID.PAGES_COLOR_APPID
|
|
425
425
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
426
426
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
427
427
|
}else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
428
428
|
return APPID.B2B_COLOR_APPID
|
|
429
429
|
} else if (isPc) {
|
|
430
430
|
return APPID.MALL_COLOR_APPID
|
|
431
431
|
} else {
|
|
432
432
|
return APPID.SHOP_COLOR_APPID
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
gatewayReq(
|
|
437
437
|
functionId: string,
|
|
438
438
|
bodyParams = {},
|
|
439
439
|
clientParams = {},
|
|
440
440
|
): Promise<any> {
|
|
441
441
|
if (
|
|
442
442
|
functionId === 'receiveShopCoupon' &&
|
|
443
443
|
((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) || isWxMinAndWxapp)
|
|
444
444
|
) {
|
|
445
445
|
clientParams = Object.assign(
|
|
446
446
|
{},
|
|
447
447
|
{
|
|
448
448
|
loginType: '1',
|
|
449
449
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
450
450
|
},
|
|
451
451
|
clientParams,
|
|
452
452
|
)
|
|
453
453
|
}
|
|
454
454
|
const apiClientParams = Object.assign(
|
|
455
455
|
{},
|
|
456
456
|
this.resInfo.apiClientParams,
|
|
457
457
|
clientParams,
|
|
458
458
|
)
|
|
459
459
|
typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
460
460
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
461
461
|
const getReqData = {
|
|
462
462
|
functionId: functionId,
|
|
463
463
|
body: JSON.stringify(bodyParams),
|
|
464
464
|
t: Date.now(),
|
|
465
465
|
...apiClientParams,
|
|
466
466
|
}
|
|
467
467
|
return http
|
|
468
468
|
.request({
|
|
469
469
|
url: this.api.apiFunc,
|
|
470
470
|
data: getReqData,
|
|
471
471
|
isColorVerify,
|
|
472
472
|
})
|
|
473
473
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
474
474
|
const { statusCode, data } = res
|
|
475
475
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
476
476
|
ok: true,
|
|
477
477
|
}
|
|
478
478
|
if (statusCode === 200 && data) {
|
|
479
479
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
480
480
|
? Number(res.data.code)
|
|
481
481
|
: -1
|
|
482
482
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
483
483
|
res.data,
|
|
484
484
|
'subCode',
|
|
485
485
|
)
|
|
486
486
|
? Number(res.data.subCode)
|
|
487
487
|
: -1
|
|
488
488
|
if (
|
|
489
489
|
data.success === true ||
|
|
490
490
|
data.isSuccess ||
|
|
491
491
|
resCode === 0 ||
|
|
492
492
|
resCode === 200 ||
|
|
493
493
|
subCode === 0
|
|
494
494
|
) {
|
|
495
495
|
changeRes = {
|
|
496
496
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
497
497
|
? data.result
|
|
498
498
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
499
499
|
? data.data
|
|
500
500
|
: data,
|
|
501
501
|
code: data.code || 200,
|
|
502
502
|
ok: true,
|
|
503
503
|
source: data,
|
|
504
504
|
}
|
|
505
505
|
return changeRes
|
|
506
506
|
} else {
|
|
507
507
|
changeRes = {
|
|
508
508
|
...data,
|
|
509
509
|
ok: false,
|
|
510
510
|
statusCode: res.statusCode,
|
|
511
511
|
}
|
|
512
512
|
return changeRes
|
|
513
513
|
}
|
|
514
514
|
} else {
|
|
515
515
|
changeRes = {
|
|
516
516
|
...data,
|
|
517
517
|
ok: false,
|
|
518
518
|
statusCode: res.statusCode,
|
|
519
519
|
}
|
|
520
520
|
return changeRes
|
|
521
521
|
}
|
|
522
522
|
})
|
|
523
523
|
.catch((res) => {
|
|
524
524
|
return {
|
|
525
525
|
...res,
|
|
526
526
|
ok: false,
|
|
527
527
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
528
528
|
})
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
async receiveCoupon(param = {}, clientParams) {
|
|
532
532
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
533
533
|
return await this.gatewayReq(
|
|
534
534
|
'receiveShopCoupon',
|
|
535
535
|
{
|
|
536
536
|
operation: '3',
|
|
537
537
|
...param,
|
|
538
538
|
},
|
|
539
539
|
{ ...loginType, ...clientParams },
|
|
540
540
|
)
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
getCustomerCenterDispatch(params = {}) {
|
|
544
544
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
545
545
|
clientVersion: '9.2.0',
|
|
546
546
|
client: 'H5',
|
|
547
547
|
uuid: 88888,
|
|
548
548
|
appid: 'shopmember_m_jd_com',
|
|
549
549
|
})
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
batchAddCart(skuIdsStr, num = 1, showToast = true) {
|
|
553
553
|
if (skuIdsStr) {
|
|
554
554
|
return this._addShopGoodCart(`${skuIdsStr}`, `${num}`)
|
|
555
555
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
556
556
|
if (res?.ok) {
|
|
557
557
|
showToast &&
|
|
558
558
|
showSuccessToast({
|
|
559
559
|
title: '已加入购物车!',
|
|
560
560
|
})
|
|
561
561
|
} else {
|
|
562
562
|
showToast &&
|
|
563
563
|
showFailToast({
|
|
564
564
|
title: res?.errMsg || '加购失败,请稍后再试',
|
|
565
565
|
})
|
|
566
566
|
}
|
|
567
567
|
return Promise.resolve(res)
|
|
568
568
|
})
|
|
569
569
|
.catch(e => {
|
|
570
570
|
console.log('调用加购方法异常=======>', e)
|
|
571
571
|
return Promise.resolve({
|
|
572
572
|
ok: false,
|
|
573
573
|
msg: '加购失败,请稍后重试',
|
|
574
574
|
})
|
|
575
575
|
})
|
|
576
576
|
} else {
|
|
577
577
|
return Promise.resolve({
|
|
578
578
|
ok: false,
|
|
579
579
|
msg: '加购失败,请稍后重试',
|
|
580
580
|
})
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
_addShopGoodCart(skuIdsStr, addCardNum = '1') {
|
|
585
585
|
return new Promise(resolve => {
|
|
586
586
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
587
587
|
if (productIdsArr.length > 0) {
|
|
588
588
|
if (isJdApp) {
|
|
589
589
|
console.log('==========>', '原生批量加车!')
|
|
590
590
|
const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`
|
|
591
591
|
if (!window[nativeAddCartCallBack]) {
|
|
592
592
|
window[nativeAddCartCallBack] = res => {
|
|
593
593
|
const getMessageJsonData =
|
|
594
594
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
595
595
|
console.info(
|
|
596
596
|
'获取批量加车原始数据',
|
|
597
597
|
res,
|
|
598
598
|
'====转换后的json数据为===',
|
|
599
599
|
getMessageJsonData,
|
|
600
600
|
)
|
|
601
601
|
try {
|
|
602
602
|
if (isAndroidDevice) {
|
|
603
603
|
getMessageJsonData?.status === '0'
|
|
604
604
|
? resolve({
|
|
605
605
|
ok: true,
|
|
606
606
|
msg: '已加入购物车!',
|
|
607
607
|
})
|
|
608
608
|
: resolve({
|
|
609
609
|
ok: false,
|
|
610
610
|
msg: '加购失败,请稍后重试',
|
|
611
611
|
})
|
|
612
612
|
} else if (isIosDevice) {
|
|
613
613
|
getMessageJsonData?.status === '0' &&
|
|
614
614
|
getMessageJsonData?.data?.code === 0
|
|
615
615
|
? resolve({
|
|
616
616
|
ok: true,
|
|
617
617
|
msg: '已加入购物车!',
|
|
618
618
|
})
|
|
619
619
|
: resolve({
|
|
620
620
|
ok: false,
|
|
621
621
|
msg: '批量加车失败,请稍后重试',
|
|
622
622
|
})
|
|
623
623
|
} else {
|
|
624
624
|
resolve({
|
|
625
625
|
ok: false,
|
|
626
626
|
msg: '加购失败,请稍后重试',
|
|
627
627
|
})
|
|
628
628
|
}
|
|
629
629
|
} catch (e) {
|
|
630
630
|
resolve({
|
|
631
631
|
ok: false,
|
|
632
632
|
msg: '加购失败,请稍后重试',
|
|
633
633
|
})
|
|
634
634
|
console.warn('批量加车转换数据异常', e)
|
|
635
635
|
}
|
|
636
636
|
window[nativeAddCartCallBack] = null
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
639
|
const productsAddCartList = productIdsArr.map(skuItem => {
|
|
640
640
|
return isAndroidDevice
|
|
641
641
|
? {
|
|
642
642
|
sku: skuItem,
|
|
643
643
|
num: addCardNum,
|
|
644
644
|
}
|
|
645
645
|
: {
|
|
646
646
|
productCode: skuItem,
|
|
647
647
|
buyCount: addCardNum,
|
|
648
648
|
}
|
|
649
649
|
})
|
|
650
650
|
if (isAndroidDevice) {
|
|
651
651
|
callRouterAndroid({
|
|
652
652
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${JSON.stringify(productsAddCartList)}&businessName=storeModel`,
|
|
653
653
|
routerParam: {
|
|
654
654
|
wareList: productsAddCartList,
|
|
655
655
|
},
|
|
656
656
|
callBackName: nativeAddCartCallBack,
|
|
657
657
|
})
|
|
658
658
|
} else if (isIosDevice) {
|
|
659
659
|
callRouterIOS({
|
|
660
660
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
661
661
|
routerParam: {
|
|
662
662
|
sourceType: 'h5',
|
|
663
663
|
sourceValue: '店铺批量加购',
|
|
664
664
|
businessName: 'storeModel',
|
|
665
665
|
isNewMode: '1',
|
|
666
666
|
NotPassWebview: '1',
|
|
667
667
|
products: productsAddCartList,
|
|
668
668
|
},
|
|
669
669
|
callBackName: nativeAddCartCallBack,
|
|
670
670
|
})
|
|
671
671
|
}
|
|
672
672
|
} else if (isMin) {
|
|
673
673
|
console.log('==========>', '京购批量加车!')
|
|
674
674
|
const productsAddCartList = productIdsArr.map(skuItem => {
|
|
675
675
|
return {
|
|
676
676
|
skuId: skuItem,
|
|
677
677
|
buyNum: addCardNum,
|
|
678
678
|
}
|
|
679
679
|
})
|
|
680
680
|
global.wxAppBizInstance
|
|
681
681
|
.addCart({ commAr: productsAddCartList })
|
|
682
682
|
.then(res => {
|
|
683
683
|
console.log('dealCartSuccess: ', res)
|
|
684
684
|
resolve({
|
|
685
685
|
ok: true,
|
|
686
686
|
msg: '已加入购物车!',
|
|
687
687
|
data: res,
|
|
688
688
|
})
|
|
689
689
|
})
|
|
690
690
|
.catch(e => {
|
|
691
691
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
692
692
|
resolve({
|
|
693
693
|
ok: false,
|
|
694
694
|
msg: '加购失败,请稍后重试',
|
|
695
695
|
})
|
|
696
696
|
})
|
|
697
697
|
} else {
|
|
698
698
|
console.log('==========>', 'M站批量加车!')
|
|
699
699
|
return this.productAddToCart(skuIdsStr, addCardNum).then(res =>
|
|
700
700
|
resolve(res),
|
|
701
701
|
)
|
|
702
702
|
}
|
|
703
703
|
} else {
|
|
704
704
|
resolve({
|
|
705
705
|
ok: false,
|
|
706
706
|
msg: '加购sku不能为空',
|
|
707
707
|
})
|
|
708
708
|
}
|
|
709
709
|
})
|
|
710
710
|
}
|
|
711
711
|
|
|
712
712
|
productAddToCart(skuIdsStr, num) {
|
|
713
713
|
return new Promise(resolve => {
|
|
714
714
|
if (window.AddcartToolObj) {
|
|
715
715
|
window.AddcartToolObj.addCart({
|
|
716
716
|
skuId: skuIdsStr,
|
|
717
717
|
num,
|
|
718
718
|
source: 'sjdpyw',
|
|
719
719
|
actId: '1',
|
|
720
720
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
721
721
|
sucFun(res) {
|
|
722
722
|
console.log(
|
|
723
723
|
'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
|
|
724
724
|
res,
|
|
725
725
|
)
|
|
726
726
|
if (res.errId === '0' && res.cartJson) {
|
|
727
727
|
resolve({
|
|
728
728
|
ok: true,
|
|
729
729
|
msg: '已加入购物车!',
|
|
730
730
|
...res,
|
|
731
731
|
})
|
|
732
732
|
} else {
|
|
733
733
|
if (res.errId === '13') {
|
|
734
734
|
global.doLogin()
|
|
735
735
|
} else {
|
|
736
736
|
resolve({
|
|
737
737
|
ok: false,
|
|
738
738
|
msg: '加购失败,请稍后重试',
|
|
739
739
|
...res,
|
|
740
740
|
})
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
743
|
},
|
|
744
744
|
failFun(err) {
|
|
745
745
|
console.log('fail', err)
|
|
746
746
|
resolve({
|
|
747
747
|
ok: false,
|
|
748
748
|
msg: '加购失败,请稍后重试',
|
|
749
749
|
...err,
|
|
750
750
|
})
|
|
751
751
|
},
|
|
752
752
|
})
|
|
753
753
|
} else {
|
|
754
754
|
resolve({
|
|
755
755
|
ok: false,
|
|
756
756
|
msg: '购物车方法检查异常',
|
|
757
757
|
})
|
|
758
758
|
}
|
|
759
759
|
})
|
|
760
760
|
}
|
|
761
761
|
bMallGetUserInfo = () => {
|
|
762
762
|
return getBMallUserInfo()
|
|
763
763
|
}
|
|
764
764
|
async bMallAddCart(params = {}) {
|
|
765
765
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
766
766
|
client: 'H5',
|
|
767
767
|
clientVersion: '5.5.0'
|
|
768
768
|
})
|
|
769
769
|
}
|
|
770
770
|
async bMallChangeCart(params = {}) {
|
|
771
771
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
772
772
|
client: 'H5',
|
|
773
773
|
clientVersion: '5.5.0'
|
|
774
774
|
})
|
|
775
775
|
}
|
|
776
776
|
async bMallRemoveCart(params = {}) {
|
|
777
777
|
return await this.gatewayReq(
|
|
778
778
|
'bmall_cartRemove',
|
|
779
779
|
params,
|
|
780
780
|
{
|
|
781
781
|
client: 'H5',
|
|
782
782
|
clientVersion: '5.5.0'
|
|
783
783
|
},
|
|
784
784
|
)
|
|
785
785
|
}
|
|
786
786
|
async bMallGetOmittedProduct(params = {}) {
|
|
787
787
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
788
788
|
client: 'H5',
|
|
789
789
|
clientVersion: '5.5.0'
|
|
790
790
|
})
|
|
791
791
|
}
|
|
792
792
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
793
793
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
794
794
|
return await this.bMallAddCart(params)
|
|
795
795
|
}
|
|
796
796
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
797
797
|
const params = await getParams({ bMallTag })
|
|
798
798
|
delete params.operations
|
|
799
799
|
return await this.bMallGetOmittedProduct(params)
|
|
800
800
|
}
|
|
801
801
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
802
802
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
803
803
|
return await this.bMallRemoveCart(params)
|
|
804
804
|
}
|
|
805
805
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
806
806
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
807
807
|
return await this.bMallChangeCart(params)
|
|
808
808
|
}
|
|
809
809
|
|
|
810
810
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
811
811
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
812
812
|
return window?.bMallCartData
|
|
813
813
|
}
|
|
814
814
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
815
815
|
let items
|
|
816
816
|
if (cartData.ok && cartData.result) {
|
|
817
817
|
items = cartData?.result?.items || {}
|
|
818
818
|
}
|
|
819
819
|
if (isH5) {
|
|
820
820
|
window.bMallCartData = items
|
|
821
821
|
}
|
|
822
822
|
return items
|
|
823
823
|
}
|
|
824
824
|
|
|
825
825
|
async bMallCartHandle(goodItem, num) {
|
|
826
826
|
try {
|
|
827
827
|
const {
|
|
828
828
|
skuUuid,
|
|
829
829
|
limitUpper,
|
|
830
830
|
limitLower,
|
|
831
831
|
} = goodItem
|
|
832
832
|
let cartNum = Number(num)
|
|
833
833
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
834
834
|
cartNum = limitLower
|
|
835
835
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
836
836
|
cartNum = limitUpper
|
|
837
837
|
}
|
|
838
838
|
if (skuUuid && cartNum > 0) {
|
|
839
839
|
return this.bMallChangeCartService({
|
|
840
840
|
...goodItem,
|
|
841
841
|
skuUuid,
|
|
842
842
|
num: cartNum,
|
|
843
843
|
})
|
|
844
844
|
} else if (!skuUuid && cartNum > 0) {
|
|
845
845
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
846
846
|
} else if (skuUuid && !cartNum) {
|
|
847
847
|
return this.bMallRemoveCartService({
|
|
848
848
|
...goodItem,
|
|
849
849
|
skuUuid,
|
|
850
850
|
num: cartNum,
|
|
851
851
|
})
|
|
852
852
|
} else {
|
|
853
853
|
console.error('参数不全')
|
|
854
854
|
return false
|
|
855
855
|
}
|
|
856
856
|
} catch (e) {
|
|
857
857
|
console.error(e)
|
|
858
858
|
}
|
|
859
859
|
}
|