@conecli/cone-render 0.9.1-shop2.2 → 0.9.1-shop2.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/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 -0
- package/dist/common/pageType.ts +1 -0
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/Exposure/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.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.tsx +1 -1
- package/dist/components/base/LazyLoadImage/const.ts +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.module.scss +9 -0
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -0
- package/dist/components/base/NetworkDataError/const.ts +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +4 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/base/Price/index.tsx +1 -1
- package/dist/components/decorate/DecorateFloorModule/index.module.scss +21 -2
- package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/isv/Floor/index.tsx +1 -1
- package/dist/components/remoteFloorItem.tsx +1 -1
- package/dist/interface/common.ts +1 -1
- package/dist/interface/component.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.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.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.jdb.ts +1 -1
- package/dist/jumpEventReport/web.jdjch.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/index.ts +1 -1
- package/dist/open/api/track.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/jm-common.js +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
APPID,
|
|
3
2
|
JshopxColorFunctionIdList,
|
|
4
3
|
PagesColorFunctionIdList,
|
|
5
4
|
PAGES_DOMAIN,
|
|
6
5
|
B2BColorFunctionIdList,
|
|
7
6
|
MobileVerifyColorList,
|
|
8
7
|
AppVerifyColorList,
|
|
9
8
|
JshopxVerifyColorList,
|
|
10
9
|
BMallVerifyColorList,
|
|
11
10
|
shopMemberColorFunctionIdList
|
|
12
11
|
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
|
isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
31
30
|
client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
|
|
32
31
|
area: '1_72_2799_0',
|
|
33
32
|
uuid: UUID,
|
|
34
33
|
},
|
|
35
34
|
public addressFetchInfo: {
|
|
36
35
|
reqState: boolean
|
|
37
36
|
promiseInstance: null | Promise<any>
|
|
38
37
|
}
|
|
39
38
|
public getPromotionConfig: {
|
|
40
39
|
projectId: null | string | number
|
|
41
40
|
pageId: null | string | number
|
|
42
41
|
}
|
|
43
42
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
44
43
|
public api: ServiceInterFace.HttpApi
|
|
45
44
|
public isPageDomain: boolean
|
|
46
45
|
public verifyColorList: string[]
|
|
47
46
|
constructor(opt) {
|
|
48
47
|
this._init()
|
|
49
48
|
this.addressFetchInfo = {
|
|
50
49
|
reqState: false,
|
|
51
50
|
promiseInstance: null,
|
|
52
51
|
}
|
|
53
52
|
this.getPromotionConfig = {
|
|
54
53
|
projectId: null,
|
|
55
54
|
pageId: null,
|
|
56
55
|
}
|
|
57
56
|
this._userAreaUpdateListen()
|
|
58
57
|
this.resInfo = this._getResConfig(opt)
|
|
59
58
|
this.api = api
|
|
60
59
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
|
|
61
60
|
this.verifyColorList = [
|
|
62
61
|
...MobileVerifyColorList,
|
|
63
62
|
...AppVerifyColorList,
|
|
64
63
|
...JshopxVerifyColorList,
|
|
65
64
|
...BMallVerifyColorList,
|
|
66
65
|
]
|
|
67
66
|
}
|
|
68
67
|
_init(): void {
|
|
69
68
|
httpInterceptors.forEach((item) => {
|
|
70
69
|
Taro.addInterceptor((chain) => item(chain))
|
|
71
70
|
})
|
|
72
71
|
}
|
|
73
72
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
74
73
|
return Object.assign({}, DefaultConfig, opt)
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
_userAreaUpdateListen() {
|
|
78
77
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
79
78
|
this.updateApiClientParamsResInfo({
|
|
80
79
|
area,
|
|
81
80
|
})
|
|
82
81
|
})
|
|
83
82
|
}
|
|
84
83
|
updateApiClientParamsResInfo(opt = {}) {
|
|
85
84
|
this.resInfo.apiClientParams = {
|
|
86
85
|
...this.resInfo.apiClientParams,
|
|
87
86
|
...opt,
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
checkFunctionIdToReturnAppId(functionId) {
|
|
92
91
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
93
92
|
return APPID.JSHOPX_COLOR_APPID
|
|
94
93
|
} else if (
|
|
95
94
|
this.isPageDomain &&
|
|
96
95
|
PagesColorFunctionIdList.includes(functionId)
|
|
97
96
|
) {
|
|
98
97
|
return APPID.PAGES_COLOR_APPID
|
|
99
98
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
100
99
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
101
100
|
}else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
102
101
|
return APPID.B2B_COLOR_APPID
|
|
103
102
|
} else {
|
|
104
103
|
return APPID.SHOP_COLOR_APPID
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
gatewayReq(
|
|
109
108
|
functionId: string,
|
|
110
109
|
bodyParams = {},
|
|
111
110
|
clientParams = {},
|
|
112
111
|
): Promise<any> {
|
|
113
112
|
if (
|
|
114
113
|
functionId === 'receiveShopCoupon' &&
|
|
115
114
|
((isH5 && window?.isJingGouMiniViewState) || isWxMinAndWxapp)
|
|
116
115
|
) {
|
|
117
116
|
clientParams = Object.assign(
|
|
118
117
|
{},
|
|
119
118
|
{
|
|
120
119
|
loginType: '1',
|
|
121
120
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
122
121
|
},
|
|
123
122
|
clientParams,
|
|
124
123
|
)
|
|
125
124
|
}
|
|
126
125
|
const apiClientParams = Object.assign(
|
|
127
126
|
{},
|
|
128
127
|
this.resInfo.apiClientParams,
|
|
129
128
|
clientParams,
|
|
130
129
|
)
|
|
131
130
|
typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
132
131
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
133
132
|
const getReqData = {
|
|
134
133
|
functionId: functionId,
|
|
135
134
|
body: JSON.stringify(bodyParams),
|
|
136
135
|
t: Date.now(),
|
|
137
136
|
...apiClientParams,
|
|
138
137
|
}
|
|
139
138
|
return http
|
|
140
139
|
.request({
|
|
141
140
|
url: this.api.apiFunc,
|
|
142
141
|
data: getReqData,
|
|
143
142
|
isColorVerify,
|
|
144
143
|
})
|
|
145
144
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
146
145
|
const { statusCode, data } = res
|
|
147
146
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
148
147
|
ok: true,
|
|
149
148
|
}
|
|
150
149
|
if (statusCode === 200 && data) {
|
|
151
150
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
152
151
|
? Number(res.data.code)
|
|
153
152
|
: -1
|
|
154
153
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
155
154
|
res.data,
|
|
156
155
|
'subCode',
|
|
157
156
|
)
|
|
158
157
|
? Number(res.data.subCode)
|
|
159
158
|
: -1
|
|
160
159
|
if (
|
|
161
160
|
data.success === true ||
|
|
162
161
|
data.isSuccess ||
|
|
163
162
|
resCode === 0 ||
|
|
164
163
|
resCode === 200 ||
|
|
165
164
|
subCode === 0
|
|
166
165
|
) {
|
|
167
166
|
changeRes = {
|
|
168
167
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
169
168
|
? data.result
|
|
170
169
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
171
170
|
? data.data
|
|
172
171
|
: data,
|
|
173
172
|
code: data.code || 200,
|
|
174
173
|
ok: true,
|
|
175
174
|
source: data,
|
|
176
175
|
}
|
|
177
176
|
return changeRes
|
|
178
177
|
} else {
|
|
179
178
|
changeRes = {
|
|
180
179
|
...data,
|
|
181
180
|
ok: false,
|
|
182
181
|
statusCode: res.statusCode,
|
|
183
182
|
}
|
|
184
183
|
return changeRes
|
|
185
184
|
}
|
|
186
185
|
} else {
|
|
187
186
|
changeRes = {
|
|
188
187
|
...data,
|
|
189
188
|
ok: false,
|
|
190
189
|
statusCode: res.statusCode,
|
|
191
190
|
}
|
|
192
191
|
return changeRes
|
|
193
192
|
}
|
|
194
193
|
})
|
|
195
194
|
.catch((res) => {
|
|
196
195
|
return {
|
|
197
196
|
...res,
|
|
198
197
|
ok: false,
|
|
199
198
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
200
199
|
})
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
async receiveCoupon(param = {}, clientParams) {
|
|
204
203
|
return await this.gatewayReq(
|
|
205
204
|
'receiveShopCoupon',
|
|
206
205
|
{
|
|
207
206
|
operation: '3',
|
|
208
207
|
...param,
|
|
209
208
|
},
|
|
210
209
|
clientParams,
|
|
211
210
|
)
|
|
212
211
|
}
|
|
213
212
|
|
|
214
213
|
getCustomerCenterDispatch(params = {}) {
|
|
215
214
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
216
215
|
clientVersion: '9.2.0',
|
|
217
216
|
client: 'H5',
|
|
218
217
|
uuid: 88888,
|
|
219
218
|
appid: 'shopmember_m_jd_com',
|
|
220
219
|
})
|
|
221
220
|
}
|
|
222
221
|
bMallGetUserInfo = () => {
|
|
223
222
|
return getBMallUserInfo()
|
|
224
223
|
}
|
|
225
224
|
async bMallAddCart(params = {}) {
|
|
226
225
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
227
226
|
client: 'H5',
|
|
228
227
|
clientVersion: '5.5.0'
|
|
229
228
|
})
|
|
230
229
|
}
|
|
231
230
|
async bMallChangeCart(params = {}) {
|
|
232
231
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
233
232
|
client: 'H5',
|
|
234
233
|
clientVersion: '5.5.0'
|
|
235
234
|
})
|
|
236
235
|
}
|
|
237
236
|
async bMallRemoveCart(params = {}) {
|
|
238
237
|
return await this.gatewayReq(
|
|
239
238
|
'bmall_cartRemove',
|
|
240
239
|
params,
|
|
241
240
|
{
|
|
242
241
|
client: 'H5',
|
|
243
242
|
clientVersion: '5.5.0'
|
|
244
243
|
},
|
|
245
244
|
)
|
|
246
245
|
}
|
|
247
246
|
async bMallGetOmittedProduct(params = {}) {
|
|
248
247
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
249
248
|
client: 'H5',
|
|
250
249
|
clientVersion: '5.5.0'
|
|
251
250
|
})
|
|
252
251
|
}
|
|
253
252
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
254
253
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
255
254
|
return await this.bMallAddCart(params)
|
|
256
255
|
}
|
|
257
256
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
258
257
|
const params = await getParams({ bMallTag })
|
|
259
258
|
delete params.operations
|
|
260
259
|
return await this.bMallGetOmittedProduct(params)
|
|
261
260
|
}
|
|
262
261
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
263
262
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
264
263
|
return await this.bMallRemoveCart(params)
|
|
265
264
|
}
|
|
266
265
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
267
266
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
268
267
|
return await this.bMallChangeCart(params)
|
|
269
268
|
}
|
|
270
269
|
|
|
271
270
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
272
271
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
273
272
|
return window?.bMallCartData
|
|
274
273
|
}
|
|
275
274
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
276
275
|
let items
|
|
277
276
|
if (cartData.ok && cartData.result) {
|
|
278
277
|
items = cartData?.result?.items || {}
|
|
279
278
|
}
|
|
280
279
|
if (isH5) {
|
|
281
280
|
window.bMallCartData = items
|
|
282
281
|
}
|
|
283
282
|
return items
|
|
284
283
|
}
|
|
285
284
|
|
|
286
285
|
async bMallCartHandle(goodItem, num) {
|
|
287
286
|
try {
|
|
288
287
|
const {
|
|
289
288
|
skuUuid,
|
|
290
289
|
limitUpper,
|
|
291
290
|
limitLower,
|
|
292
291
|
} = goodItem
|
|
293
292
|
let cartNum = Number(num)
|
|
294
293
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
295
294
|
cartNum = limitLower
|
|
296
295
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
297
296
|
cartNum = limitUpper
|
|
298
297
|
}
|
|
299
298
|
if (skuUuid && cartNum > 0) {
|
|
300
299
|
return this.bMallChangeCartService({
|
|
301
300
|
...goodItem,
|
|
302
301
|
skuUuid,
|
|
303
302
|
num: cartNum,
|
|
304
303
|
})
|
|
305
304
|
} else if (!skuUuid && cartNum > 0) {
|
|
306
305
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
307
306
|
} else if (skuUuid && !cartNum) {
|
|
308
307
|
return this.bMallRemoveCartService({
|
|
309
308
|
...goodItem,
|
|
310
309
|
skuUuid,
|
|
311
310
|
num: cartNum,
|
|
312
311
|
})
|
|
313
312
|
} else {
|
|
314
313
|
console.error('参数不全')
|
|
315
314
|
return false
|
|
316
315
|
}
|
|
317
316
|
} catch (e) {
|
|
318
317
|
console.error(e)
|
|
319
318
|
}
|
|
320
319
|
}
|
|
320
|
+
import Taro from '@tarojs/taro'
|
|
321
321
|
APPID,
|
|
322
322
|
JshopxColorFunctionIdList,
|
|
323
323
|
PagesColorFunctionIdList,
|
|
324
324
|
PAGES_DOMAIN,
|
|
325
325
|
B2BColorFunctionIdList,
|
|
326
326
|
MobileVerifyColorList,
|
|
327
327
|
AppVerifyColorList,
|
|
328
328
|
JshopxVerifyColorList,
|
|
329
329
|
BMallVerifyColorList,
|
|
330
330
|
shopMemberColorFunctionIdList
|
|
331
331
|
cookiesStr: '',
|
|
332
332
|
requestHeaderContentType: {
|
|
333
333
|
jsonHeader: {
|
|
334
334
|
'content-type': 'application/json;charset=utf-8',
|
|
335
335
|
},
|
|
336
336
|
formDataHeader: {
|
|
337
337
|
'content-type': 'application/x-www-form-urlencoded',
|
|
338
338
|
},
|
|
339
339
|
},
|
|
340
340
|
requestBaseParam: {
|
|
341
341
|
data: null,
|
|
342
342
|
header: {
|
|
343
343
|
'content-type': 'application/json;charset=utf-8',
|
|
344
344
|
},
|
|
345
345
|
},
|
|
346
346
|
timeOut: 7000,
|
|
347
347
|
apiClientParams: {
|
|
348
348
|
clientVersion:
|
|
349
349
|
isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
350
350
|
client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
351
351
|
area: '1_72_2799_0',
|
|
352
352
|
uuid: UUID,
|
|
353
353
|
},
|
|
354
354
|
public addressFetchInfo: {
|
|
355
355
|
reqState: boolean
|
|
356
356
|
promiseInstance: null | Promise<any>
|
|
357
357
|
}
|
|
358
358
|
public getPromotionConfig: {
|
|
359
359
|
projectId: null | string | number
|
|
360
360
|
pageId: null | string | number
|
|
361
361
|
}
|
|
362
362
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
363
363
|
public api: ServiceInterFace.HttpApi
|
|
364
364
|
public isPageDomain: boolean
|
|
365
365
|
public verifyColorList: string[]
|
|
366
366
|
constructor(opt) {
|
|
367
367
|
this._init()
|
|
368
368
|
this.addressFetchInfo = {
|
|
369
369
|
reqState: false,
|
|
370
370
|
promiseInstance: null,
|
|
371
371
|
}
|
|
372
372
|
this.getPromotionConfig = {
|
|
373
373
|
projectId: null,
|
|
374
374
|
pageId: null,
|
|
375
375
|
}
|
|
376
376
|
this._userAreaUpdateListen()
|
|
377
377
|
this.resInfo = this._getResConfig(opt)
|
|
378
378
|
this.api = api
|
|
379
379
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
|
|
380
380
|
this.verifyColorList = [
|
|
381
381
|
...MobileVerifyColorList,
|
|
382
382
|
...AppVerifyColorList,
|
|
383
383
|
...JshopxVerifyColorList,
|
|
384
384
|
...BMallVerifyColorList,
|
|
385
385
|
]
|
|
386
386
|
}
|
|
387
387
|
_init(): void {
|
|
388
388
|
httpInterceptors.forEach((item) => {
|
|
389
389
|
Taro.addInterceptor((chain) => item(chain))
|
|
390
390
|
})
|
|
391
391
|
}
|
|
392
392
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
393
393
|
return Object.assign({}, DefaultConfig, opt)
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
_userAreaUpdateListen() {
|
|
397
397
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
398
398
|
this.updateApiClientParamsResInfo({
|
|
399
399
|
area,
|
|
400
400
|
})
|
|
401
401
|
})
|
|
402
402
|
}
|
|
403
403
|
updateApiClientParamsResInfo(opt = {}) {
|
|
404
404
|
this.resInfo.apiClientParams = {
|
|
405
405
|
...this.resInfo.apiClientParams,
|
|
406
406
|
...opt,
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
checkFunctionIdToReturnAppId(functionId) {
|
|
411
411
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
412
412
|
return APPID.JSHOPX_COLOR_APPID
|
|
413
413
|
} else if (
|
|
414
414
|
this.isPageDomain &&
|
|
415
415
|
PagesColorFunctionIdList.includes(functionId)
|
|
416
416
|
) {
|
|
417
417
|
return APPID.PAGES_COLOR_APPID
|
|
418
418
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
419
419
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
420
420
|
}else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
421
421
|
return APPID.B2B_COLOR_APPID
|
|
422
422
|
} else if (isPc) {
|
|
423
423
|
return APPID.MALL_COLOR_APPID
|
|
424
424
|
} else {
|
|
425
425
|
return APPID.SHOP_COLOR_APPID
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
|
|
429
429
|
gatewayReq(
|
|
430
430
|
functionId: string,
|
|
431
431
|
bodyParams = {},
|
|
432
432
|
clientParams = {},
|
|
433
433
|
): Promise<any> {
|
|
434
434
|
if (
|
|
435
435
|
functionId === 'receiveShopCoupon' &&
|
|
436
436
|
((isH5 && window?.isJingGouMiniViewState) || isWxMinAndWxapp)
|
|
437
437
|
) {
|
|
438
438
|
clientParams = Object.assign(
|
|
439
439
|
{},
|
|
440
440
|
{
|
|
441
441
|
loginType: '1',
|
|
442
442
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
443
443
|
},
|
|
444
444
|
clientParams,
|
|
445
445
|
)
|
|
446
446
|
}
|
|
447
447
|
const apiClientParams = Object.assign(
|
|
448
448
|
{},
|
|
449
449
|
this.resInfo.apiClientParams,
|
|
450
450
|
clientParams,
|
|
451
451
|
)
|
|
452
452
|
typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
453
453
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
454
454
|
const getReqData = {
|
|
455
455
|
functionId: functionId,
|
|
456
456
|
body: JSON.stringify(bodyParams),
|
|
457
457
|
t: Date.now(),
|
|
458
458
|
...apiClientParams,
|
|
459
459
|
}
|
|
460
460
|
return http
|
|
461
461
|
.request({
|
|
462
462
|
url: this.api.apiFunc,
|
|
463
463
|
data: getReqData,
|
|
464
464
|
isColorVerify,
|
|
465
465
|
})
|
|
466
466
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
467
467
|
const { statusCode, data } = res
|
|
468
468
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
469
469
|
ok: true,
|
|
470
470
|
}
|
|
471
471
|
if (statusCode === 200 && data) {
|
|
472
472
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
473
473
|
? Number(res.data.code)
|
|
474
474
|
: -1
|
|
475
475
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
476
476
|
res.data,
|
|
477
477
|
'subCode',
|
|
478
478
|
)
|
|
479
479
|
? Number(res.data.subCode)
|
|
480
480
|
: -1
|
|
481
481
|
if (
|
|
482
482
|
data.success === true ||
|
|
483
483
|
data.isSuccess ||
|
|
484
484
|
resCode === 0 ||
|
|
485
485
|
resCode === 200 ||
|
|
486
486
|
subCode === 0
|
|
487
487
|
) {
|
|
488
488
|
changeRes = {
|
|
489
489
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
490
490
|
? data.result
|
|
491
491
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
492
492
|
? data.data
|
|
493
493
|
: data,
|
|
494
494
|
code: data.code || 200,
|
|
495
495
|
ok: true,
|
|
496
496
|
source: data,
|
|
497
497
|
}
|
|
498
498
|
return changeRes
|
|
499
499
|
} else {
|
|
500
500
|
changeRes = {
|
|
501
501
|
...data,
|
|
502
502
|
ok: false,
|
|
503
503
|
statusCode: res.statusCode,
|
|
504
504
|
}
|
|
505
505
|
return changeRes
|
|
506
506
|
}
|
|
507
507
|
} else {
|
|
508
508
|
changeRes = {
|
|
509
509
|
...data,
|
|
510
510
|
ok: false,
|
|
511
511
|
statusCode: res.statusCode,
|
|
512
512
|
}
|
|
513
513
|
return changeRes
|
|
514
514
|
}
|
|
515
515
|
})
|
|
516
516
|
.catch((res) => {
|
|
517
517
|
return {
|
|
518
518
|
...res,
|
|
519
519
|
ok: false,
|
|
520
520
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
521
521
|
})
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
async receiveCoupon(param = {}, clientParams) {
|
|
525
525
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
526
526
|
return await this.gatewayReq(
|
|
527
527
|
'receiveShopCoupon',
|
|
528
528
|
{
|
|
529
529
|
operation: '3',
|
|
530
530
|
...param,
|
|
531
531
|
},
|
|
532
532
|
{ ...loginType, ...clientParams },
|
|
533
533
|
)
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
getCustomerCenterDispatch(params = {}) {
|
|
537
537
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
538
538
|
clientVersion: '9.2.0',
|
|
539
539
|
client: 'H5',
|
|
540
540
|
uuid: 88888,
|
|
541
541
|
appid: 'shopmember_m_jd_com',
|
|
542
542
|
})
|
|
543
543
|
}
|
|
544
544
|
bMallGetUserInfo = () => {
|
|
545
545
|
return getBMallUserInfo()
|
|
546
546
|
}
|
|
547
547
|
async bMallAddCart(params = {}) {
|
|
548
548
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
549
549
|
client: 'H5',
|
|
550
550
|
clientVersion: '5.5.0'
|
|
551
551
|
})
|
|
552
552
|
}
|
|
553
553
|
async bMallChangeCart(params = {}) {
|
|
554
554
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
555
555
|
client: 'H5',
|
|
556
556
|
clientVersion: '5.5.0'
|
|
557
557
|
})
|
|
558
558
|
}
|
|
559
559
|
async bMallRemoveCart(params = {}) {
|
|
560
560
|
return await this.gatewayReq(
|
|
561
561
|
'bmall_cartRemove',
|
|
562
562
|
params,
|
|
563
563
|
{
|
|
564
564
|
client: 'H5',
|
|
565
565
|
clientVersion: '5.5.0'
|
|
566
566
|
},
|
|
567
567
|
)
|
|
568
568
|
}
|
|
569
569
|
async bMallGetOmittedProduct(params = {}) {
|
|
570
570
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
571
571
|
client: 'H5',
|
|
572
572
|
clientVersion: '5.5.0'
|
|
573
573
|
})
|
|
574
574
|
}
|
|
575
575
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
576
576
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
577
577
|
return await this.bMallAddCart(params)
|
|
578
578
|
}
|
|
579
579
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
580
580
|
const params = await getParams({ bMallTag })
|
|
581
581
|
delete params.operations
|
|
582
582
|
return await this.bMallGetOmittedProduct(params)
|
|
583
583
|
}
|
|
584
584
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
585
585
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
586
586
|
return await this.bMallRemoveCart(params)
|
|
587
587
|
}
|
|
588
588
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
589
589
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
590
590
|
return await this.bMallChangeCart(params)
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
594
594
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
595
595
|
return window?.bMallCartData
|
|
596
596
|
}
|
|
597
597
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
598
598
|
let items
|
|
599
599
|
if (cartData.ok && cartData.result) {
|
|
600
600
|
items = cartData?.result?.items || {}
|
|
601
601
|
}
|
|
602
602
|
if (isH5) {
|
|
603
603
|
window.bMallCartData = items
|
|
604
604
|
}
|
|
605
605
|
return items
|
|
606
606
|
}
|
|
607
607
|
|
|
608
608
|
async bMallCartHandle(goodItem, num) {
|
|
609
609
|
try {
|
|
610
610
|
const {
|
|
611
611
|
skuUuid,
|
|
612
612
|
limitUpper,
|
|
613
613
|
limitLower,
|
|
614
614
|
} = goodItem
|
|
615
615
|
let cartNum = Number(num)
|
|
616
616
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
617
617
|
cartNum = limitLower
|
|
618
618
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
619
619
|
cartNum = limitUpper
|
|
620
620
|
}
|
|
621
621
|
if (skuUuid && cartNum > 0) {
|
|
622
622
|
return this.bMallChangeCartService({
|
|
623
623
|
...goodItem,
|
|
624
624
|
skuUuid,
|
|
625
625
|
num: cartNum,
|
|
626
626
|
})
|
|
627
627
|
} else if (!skuUuid && cartNum > 0) {
|
|
628
628
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
629
629
|
} else if (skuUuid && !cartNum) {
|
|
630
630
|
return this.bMallRemoveCartService({
|
|
631
631
|
...goodItem,
|
|
632
632
|
skuUuid,
|
|
633
633
|
num: cartNum,
|
|
634
634
|
})
|
|
635
635
|
} else {
|
|
636
636
|
console.error('参数不全')
|
|
637
637
|
return false
|
|
638
638
|
}
|
|
639
639
|
} catch (e) {
|
|
640
640
|
console.error(e)
|
|
641
641
|
}
|
|
642
642
|
}
|