@conecli/cone-render 0.9.1-isv2.0 → 0.9.1-isv2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.ts +1 -0
- 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.ts +1 -0
- package/dist/common/jssdk.ts +1 -0
- package/dist/common/pageType.ts +1 -0
- package/dist/common/sgmCustomCode.ts +1 -0
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/common/token/token.ts +1 -1
- package/dist/common/wxappApi.jd.ts +1 -0
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
- package/dist/components/base/CustomScrollView/index.module.scss +7 -0
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +5 -0
- package/dist/components/base/Dialog/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/InOrOutViewObserver/index.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/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/const.ts +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +20 -20
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.module.scss +17 -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/floorItem.jd.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/floorItem.weapp.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/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/interface/utils.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.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.jxwxapp.ts +1 -0
- package/dist/jumpEventReport/web.pc.ts +1 -0
- package/dist/jumpEventReport/web.tjapp.ts +1 -0
- package/dist/jumpEventReport/web.tjm.ts +1 -0
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/modules/ContainerFloorList/index.h5.module.scss +17 -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/jump copy.ts +1 -1
- package/dist/open/api/request.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/track.ts +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/sass/app.h5.scss +44 -3
- package/dist/sass/base.scss +12 -0
- 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/draExceptionAndProfile.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/sgmCodeUtils.ts +1 -0
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +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
|
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
|
callRouterIOS,
|
|
332
332
|
callRouterAndroid,
|
|
333
333
|
cookiesStr: '',
|
|
334
334
|
requestHeaderContentType: {
|
|
335
335
|
jsonHeader: {
|
|
336
336
|
'content-type': 'application/json;charset=utf-8',
|
|
337
337
|
},
|
|
338
338
|
formDataHeader: {
|
|
339
339
|
'content-type': 'application/x-www-form-urlencoded',
|
|
340
340
|
},
|
|
341
341
|
},
|
|
342
342
|
requestBaseParam: {
|
|
343
343
|
data: null,
|
|
344
344
|
header: {
|
|
345
345
|
'content-type': 'application/json;charset=utf-8',
|
|
346
346
|
},
|
|
347
347
|
},
|
|
348
348
|
timeOut: 7000,
|
|
349
349
|
apiClientParams: {
|
|
350
350
|
clientVersion:
|
|
351
351
|
isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
352
352
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
353
353
|
area: '1_72_2799_0',
|
|
354
354
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(window.screen?.height * devicePixelRatio)}`,
|
|
355
355
|
uuid: UUID,
|
|
356
356
|
},
|
|
357
357
|
public addressFetchInfo: {
|
|
358
358
|
reqState: boolean
|
|
359
359
|
promiseInstance: null | Promise<any>
|
|
360
360
|
}
|
|
361
361
|
public getPromotionConfig: {
|
|
362
362
|
projectId: null | string | number
|
|
363
363
|
pageId: null | string | number
|
|
364
364
|
}
|
|
365
365
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
366
366
|
public api: ServiceInterFace.HttpApi
|
|
367
367
|
public isPageDomain: boolean
|
|
368
368
|
public verifyColorList: string[]
|
|
369
369
|
constructor(opt) {
|
|
370
370
|
this._init()
|
|
371
371
|
this.addressFetchInfo = {
|
|
372
372
|
reqState: false,
|
|
373
373
|
promiseInstance: null,
|
|
374
374
|
}
|
|
375
375
|
this.getPromotionConfig = {
|
|
376
376
|
projectId: null,
|
|
377
377
|
pageId: null,
|
|
378
378
|
}
|
|
379
379
|
this._userAreaUpdateListen()
|
|
380
380
|
this.resInfo = this._getResConfig(opt)
|
|
381
381
|
this.api = api
|
|
382
382
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
|
|
383
383
|
this.verifyColorList = [
|
|
384
384
|
...MobileVerifyColorList,
|
|
385
385
|
...AppVerifyColorList,
|
|
386
386
|
...JshopxVerifyColorList,
|
|
387
387
|
...BMallVerifyColorList,
|
|
388
388
|
]
|
|
389
389
|
}
|
|
390
390
|
_init(): void {
|
|
391
391
|
httpInterceptors.forEach((item) => {
|
|
392
392
|
Taro.addInterceptor((chain) => item(chain))
|
|
393
393
|
})
|
|
394
394
|
}
|
|
395
395
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
396
396
|
return Object.assign({}, DefaultConfig, opt)
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
_userAreaUpdateListen() {
|
|
400
400
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
401
401
|
this.updateApiClientParamsResInfo({
|
|
402
402
|
area,
|
|
403
403
|
})
|
|
404
404
|
})
|
|
405
405
|
}
|
|
406
406
|
updateApiClientParamsResInfo(opt = {}) {
|
|
407
407
|
this.resInfo.apiClientParams = {
|
|
408
408
|
...this.resInfo.apiClientParams,
|
|
409
409
|
...opt,
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
checkFunctionIdToReturnAppId(functionId) {
|
|
414
414
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
415
415
|
return APPID.JSHOPX_COLOR_APPID
|
|
416
416
|
} else if (
|
|
417
417
|
this.isPageDomain &&
|
|
418
418
|
PagesColorFunctionIdList.includes(functionId)
|
|
419
419
|
) {
|
|
420
420
|
return APPID.PAGES_COLOR_APPID
|
|
421
421
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
422
422
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
423
423
|
}else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
424
424
|
return APPID.B2B_COLOR_APPID
|
|
425
425
|
} else if (isPc) {
|
|
426
426
|
return APPID.MALL_COLOR_APPID
|
|
427
427
|
} else {
|
|
428
428
|
return APPID.SHOP_COLOR_APPID
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
gatewayReq(
|
|
433
433
|
functionId: string,
|
|
434
434
|
bodyParams = {},
|
|
435
435
|
clientParams = {},
|
|
436
436
|
): Promise<any> {
|
|
437
437
|
if (
|
|
438
438
|
functionId === 'receiveShopCoupon' &&
|
|
439
439
|
((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) || isWxMinAndWxapp)
|
|
440
440
|
) {
|
|
441
441
|
clientParams = Object.assign(
|
|
442
442
|
{},
|
|
443
443
|
{
|
|
444
444
|
loginType: '1',
|
|
445
445
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
446
446
|
},
|
|
447
447
|
clientParams,
|
|
448
448
|
)
|
|
449
449
|
}
|
|
450
450
|
const apiClientParams = Object.assign(
|
|
451
451
|
{},
|
|
452
452
|
this.resInfo.apiClientParams,
|
|
453
453
|
clientParams,
|
|
454
454
|
)
|
|
455
455
|
typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
456
456
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
457
457
|
const getReqData = {
|
|
458
458
|
functionId: functionId,
|
|
459
459
|
body: JSON.stringify(bodyParams),
|
|
460
460
|
t: Date.now(),
|
|
461
461
|
...apiClientParams,
|
|
462
462
|
}
|
|
463
463
|
return http
|
|
464
464
|
.request({
|
|
465
465
|
url: this.api.apiFunc,
|
|
466
466
|
data: getReqData,
|
|
467
467
|
isColorVerify,
|
|
468
468
|
})
|
|
469
469
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
470
470
|
const { statusCode, data } = res
|
|
471
471
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
472
472
|
ok: true,
|
|
473
473
|
}
|
|
474
474
|
if (statusCode === 200 && data) {
|
|
475
475
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
476
476
|
? Number(res.data.code)
|
|
477
477
|
: -1
|
|
478
478
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
479
479
|
res.data,
|
|
480
480
|
'subCode',
|
|
481
481
|
)
|
|
482
482
|
? Number(res.data.subCode)
|
|
483
483
|
: -1
|
|
484
484
|
if (
|
|
485
485
|
data.success === true ||
|
|
486
486
|
data.isSuccess ||
|
|
487
487
|
resCode === 0 ||
|
|
488
488
|
resCode === 200 ||
|
|
489
489
|
subCode === 0
|
|
490
490
|
) {
|
|
491
491
|
changeRes = {
|
|
492
492
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
493
493
|
? data.result
|
|
494
494
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
495
495
|
? data.data
|
|
496
496
|
: data,
|
|
497
497
|
code: data.code || 200,
|
|
498
498
|
ok: true,
|
|
499
499
|
source: data,
|
|
500
500
|
}
|
|
501
501
|
return changeRes
|
|
502
502
|
} else {
|
|
503
503
|
changeRes = {
|
|
504
504
|
...data,
|
|
505
505
|
ok: false,
|
|
506
506
|
statusCode: res.statusCode,
|
|
507
507
|
}
|
|
508
508
|
return changeRes
|
|
509
509
|
}
|
|
510
510
|
} else {
|
|
511
511
|
changeRes = {
|
|
512
512
|
...data,
|
|
513
513
|
ok: false,
|
|
514
514
|
statusCode: res.statusCode,
|
|
515
515
|
}
|
|
516
516
|
return changeRes
|
|
517
517
|
}
|
|
518
518
|
})
|
|
519
519
|
.catch((res) => {
|
|
520
520
|
return {
|
|
521
521
|
...res,
|
|
522
522
|
ok: false,
|
|
523
523
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
524
524
|
})
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
async receiveCoupon(param = {}, clientParams) {
|
|
528
528
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
529
529
|
return await this.gatewayReq(
|
|
530
530
|
'receiveShopCoupon',
|
|
531
531
|
{
|
|
532
532
|
operation: '3',
|
|
533
533
|
...param,
|
|
534
534
|
},
|
|
535
535
|
{ ...loginType, ...clientParams },
|
|
536
536
|
)
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
getCustomerCenterDispatch(params = {}) {
|
|
540
540
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
541
541
|
clientVersion: '9.2.0',
|
|
542
542
|
client: 'H5',
|
|
543
543
|
uuid: 88888,
|
|
544
544
|
appid: 'shopmember_m_jd_com',
|
|
545
545
|
})
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
batchAddCart(skuIdsStr, num = 1, showToast = true) {
|
|
549
549
|
if (skuIdsStr) {
|
|
550
550
|
return this._addShopGoodCart(`${skuIdsStr}`, `${num}`)
|
|
551
551
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
552
552
|
if (res?.ok) {
|
|
553
553
|
showToast &&
|
|
554
554
|
showSuccessToast({
|
|
555
555
|
title: '已加入购物车!',
|
|
556
556
|
})
|
|
557
557
|
} else {
|
|
558
558
|
showToast &&
|
|
559
559
|
showFailToast({
|
|
560
560
|
title: res?.errMsg || '加购失败,请稍后再试',
|
|
561
561
|
})
|
|
562
562
|
}
|
|
563
563
|
return Promise.resolve(res)
|
|
564
564
|
})
|
|
565
565
|
.catch(e => {
|
|
566
566
|
console.log('调用加购方法异常=======>', e)
|
|
567
567
|
return Promise.resolve({
|
|
568
568
|
ok: false,
|
|
569
569
|
msg: '加购失败,请稍后重试',
|
|
570
570
|
})
|
|
571
571
|
})
|
|
572
572
|
} else {
|
|
573
573
|
return Promise.resolve({
|
|
574
574
|
ok: false,
|
|
575
575
|
msg: '加购失败,请稍后重试',
|
|
576
576
|
})
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
_addShopGoodCart(skuIdsStr, addCardNum = '1') {
|
|
581
581
|
return new Promise(resolve => {
|
|
582
582
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
583
583
|
if (productIdsArr.length > 0) {
|
|
584
584
|
if (isJdApp) {
|
|
585
585
|
console.log('==========>', '原生批量加车!')
|
|
586
586
|
const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`
|
|
587
587
|
if (!window[nativeAddCartCallBack]) {
|
|
588
588
|
window[nativeAddCartCallBack] = res => {
|
|
589
589
|
const getMessageJsonData =
|
|
590
590
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
591
591
|
console.info(
|
|
592
592
|
'获取批量加车原始数据',
|
|
593
593
|
res,
|
|
594
594
|
'====转换后的json数据为===',
|
|
595
595
|
getMessageJsonData,
|
|
596
596
|
)
|
|
597
597
|
try {
|
|
598
598
|
if (isAndroidDevice) {
|
|
599
599
|
getMessageJsonData?.status === '0'
|
|
600
600
|
? resolve({
|
|
601
601
|
ok: true,
|
|
602
602
|
msg: '已加入购物车!',
|
|
603
603
|
})
|
|
604
604
|
: resolve({
|
|
605
605
|
ok: false,
|
|
606
606
|
msg: '加购失败,请稍后重试',
|
|
607
607
|
})
|
|
608
608
|
} else if (isIosDevice) {
|
|
609
609
|
getMessageJsonData?.status === '0' &&
|
|
610
610
|
getMessageJsonData?.data?.code === 0
|
|
611
611
|
? resolve({
|
|
612
612
|
ok: true,
|
|
613
613
|
msg: '已加入购物车!',
|
|
614
614
|
})
|
|
615
615
|
: resolve({
|
|
616
616
|
ok: false,
|
|
617
617
|
msg: '批量加车失败,请稍后重试',
|
|
618
618
|
})
|
|
619
619
|
} else {
|
|
620
620
|
resolve({
|
|
621
621
|
ok: false,
|
|
622
622
|
msg: '加购失败,请稍后重试',
|
|
623
623
|
})
|
|
624
624
|
}
|
|
625
625
|
} catch (e) {
|
|
626
626
|
resolve({
|
|
627
627
|
ok: false,
|
|
628
628
|
msg: '加购失败,请稍后重试',
|
|
629
629
|
})
|
|
630
630
|
console.warn('批量加车转换数据异常', e)
|
|
631
631
|
}
|
|
632
632
|
window[nativeAddCartCallBack] = null
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
635
|
const productsAddCartList = productIdsArr.map(skuItem => {
|
|
636
636
|
return isAndroidDevice
|
|
637
637
|
? {
|
|
638
638
|
sku: skuItem,
|
|
639
639
|
num: addCardNum,
|
|
640
640
|
}
|
|
641
641
|
: {
|
|
642
642
|
productCode: skuItem,
|
|
643
643
|
buyCount: addCardNum,
|
|
644
644
|
}
|
|
645
645
|
})
|
|
646
646
|
if (isAndroidDevice) {
|
|
647
647
|
callRouterAndroid({
|
|
648
648
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${JSON.stringify(productsAddCartList)}&businessName=storeModel`,
|
|
649
649
|
routerParam: {
|
|
650
650
|
wareList: productsAddCartList,
|
|
651
651
|
},
|
|
652
652
|
callBackName: nativeAddCartCallBack,
|
|
653
653
|
})
|
|
654
654
|
} else if (isIosDevice) {
|
|
655
655
|
callRouterIOS({
|
|
656
656
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
657
657
|
routerParam: {
|
|
658
658
|
sourceType: 'h5',
|
|
659
659
|
sourceValue: '店铺批量加购',
|
|
660
660
|
businessName: 'storeModel',
|
|
661
661
|
isNewMode: '1',
|
|
662
662
|
NotPassWebview: '1',
|
|
663
663
|
products: productsAddCartList,
|
|
664
664
|
},
|
|
665
665
|
callBackName: nativeAddCartCallBack,
|
|
666
666
|
})
|
|
667
667
|
}
|
|
668
668
|
} else if (isMin) {
|
|
669
669
|
console.log('==========>', '京购批量加车!')
|
|
670
670
|
const productsAddCartList = productIdsArr.map(skuItem => {
|
|
671
671
|
return {
|
|
672
672
|
skuId: skuItem,
|
|
673
673
|
buyNum: addCardNum,
|
|
674
674
|
}
|
|
675
675
|
})
|
|
676
676
|
global.wxAppBizInstance
|
|
677
677
|
.addCart({ commAr: productsAddCartList })
|
|
678
678
|
.then(res => {
|
|
679
679
|
console.log('dealCartSuccess: ', res)
|
|
680
680
|
resolve({
|
|
681
681
|
ok: true,
|
|
682
682
|
msg: '已加入购物车!',
|
|
683
683
|
data: res,
|
|
684
684
|
})
|
|
685
685
|
})
|
|
686
686
|
.catch(e => {
|
|
687
687
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
688
688
|
resolve({
|
|
689
689
|
ok: false,
|
|
690
690
|
msg: '加购失败,请稍后重试',
|
|
691
691
|
})
|
|
692
692
|
})
|
|
693
693
|
} else {
|
|
694
694
|
console.log('==========>', 'M站批量加车!')
|
|
695
695
|
return this.productAddToCart(skuIdsStr, addCardNum).then(res =>
|
|
696
696
|
resolve(res),
|
|
697
697
|
)
|
|
698
698
|
}
|
|
699
699
|
} else {
|
|
700
700
|
resolve({
|
|
701
701
|
ok: false,
|
|
702
702
|
msg: '加购sku不能为空',
|
|
703
703
|
})
|
|
704
704
|
}
|
|
705
705
|
})
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
productAddToCart(skuIdsStr, num) {
|
|
709
709
|
return new Promise(resolve => {
|
|
710
710
|
if (window.AddcartToolObj) {
|
|
711
711
|
window.AddcartToolObj.addCart({
|
|
712
712
|
skuId: skuIdsStr,
|
|
713
713
|
num,
|
|
714
714
|
source: 'sjdpyw',
|
|
715
715
|
actId: '1',
|
|
716
716
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
717
717
|
sucFun(res) {
|
|
718
718
|
console.log(
|
|
719
719
|
'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
|
|
720
720
|
res,
|
|
721
721
|
)
|
|
722
722
|
if (res.errId === '0' && res.cartJson) {
|
|
723
723
|
resolve({
|
|
724
724
|
ok: true,
|
|
725
725
|
msg: '已加入购物车!',
|
|
726
726
|
...res,
|
|
727
727
|
})
|
|
728
728
|
} else {
|
|
729
729
|
if (res.errId === '13') {
|
|
730
730
|
global.doLogin()
|
|
731
731
|
} else {
|
|
732
732
|
resolve({
|
|
733
733
|
ok: false,
|
|
734
734
|
msg: '加购失败,请稍后重试',
|
|
735
735
|
...res,
|
|
736
736
|
})
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
},
|
|
740
740
|
failFun(err) {
|
|
741
741
|
console.log('fail', err)
|
|
742
742
|
resolve({
|
|
743
743
|
ok: false,
|
|
744
744
|
msg: '加购失败,请稍后重试',
|
|
745
745
|
...err,
|
|
746
746
|
})
|
|
747
747
|
},
|
|
748
748
|
})
|
|
749
749
|
} else {
|
|
750
750
|
resolve({
|
|
751
751
|
ok: false,
|
|
752
752
|
msg: '购物车方法检查异常',
|
|
753
753
|
})
|
|
754
754
|
}
|
|
755
755
|
})
|
|
756
756
|
}
|
|
757
757
|
bMallGetUserInfo = () => {
|
|
758
758
|
return getBMallUserInfo()
|
|
759
759
|
}
|
|
760
760
|
async bMallAddCart(params = {}) {
|
|
761
761
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
762
762
|
client: 'H5',
|
|
763
763
|
clientVersion: '5.5.0'
|
|
764
764
|
})
|
|
765
765
|
}
|
|
766
766
|
async bMallChangeCart(params = {}) {
|
|
767
767
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
768
768
|
client: 'H5',
|
|
769
769
|
clientVersion: '5.5.0'
|
|
770
770
|
})
|
|
771
771
|
}
|
|
772
772
|
async bMallRemoveCart(params = {}) {
|
|
773
773
|
return await this.gatewayReq(
|
|
774
774
|
'bmall_cartRemove',
|
|
775
775
|
params,
|
|
776
776
|
{
|
|
777
777
|
client: 'H5',
|
|
778
778
|
clientVersion: '5.5.0'
|
|
779
779
|
},
|
|
780
780
|
)
|
|
781
781
|
}
|
|
782
782
|
async bMallGetOmittedProduct(params = {}) {
|
|
783
783
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
784
784
|
client: 'H5',
|
|
785
785
|
clientVersion: '5.5.0'
|
|
786
786
|
})
|
|
787
787
|
}
|
|
788
788
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
789
789
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
790
790
|
return await this.bMallAddCart(params)
|
|
791
791
|
}
|
|
792
792
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
793
793
|
const params = await getParams({ bMallTag })
|
|
794
794
|
delete params.operations
|
|
795
795
|
return await this.bMallGetOmittedProduct(params)
|
|
796
796
|
}
|
|
797
797
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
798
798
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
799
799
|
return await this.bMallRemoveCart(params)
|
|
800
800
|
}
|
|
801
801
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
802
802
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
803
803
|
return await this.bMallChangeCart(params)
|
|
804
804
|
}
|
|
805
805
|
|
|
806
806
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
807
807
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
808
808
|
return window?.bMallCartData
|
|
809
809
|
}
|
|
810
810
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
811
811
|
let items
|
|
812
812
|
if (cartData.ok && cartData.result) {
|
|
813
813
|
items = cartData?.result?.items || {}
|
|
814
814
|
}
|
|
815
815
|
if (isH5) {
|
|
816
816
|
window.bMallCartData = items
|
|
817
817
|
}
|
|
818
818
|
return items
|
|
819
819
|
}
|
|
820
820
|
|
|
821
821
|
async bMallCartHandle(goodItem, num) {
|
|
822
822
|
try {
|
|
823
823
|
const {
|
|
824
824
|
skuUuid,
|
|
825
825
|
limitUpper,
|
|
826
826
|
limitLower,
|
|
827
827
|
} = goodItem
|
|
828
828
|
let cartNum = Number(num)
|
|
829
829
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
830
830
|
cartNum = limitLower
|
|
831
831
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
832
832
|
cartNum = limitUpper
|
|
833
833
|
}
|
|
834
834
|
if (skuUuid && cartNum > 0) {
|
|
835
835
|
return this.bMallChangeCartService({
|
|
836
836
|
...goodItem,
|
|
837
837
|
skuUuid,
|
|
838
838
|
num: cartNum,
|
|
839
839
|
})
|
|
840
840
|
} else if (!skuUuid && cartNum > 0) {
|
|
841
841
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
842
842
|
} else if (skuUuid && !cartNum) {
|
|
843
843
|
return this.bMallRemoveCartService({
|
|
844
844
|
...goodItem,
|
|
845
845
|
skuUuid,
|
|
846
846
|
num: cartNum,
|
|
847
847
|
})
|
|
848
848
|
} else {
|
|
849
849
|
console.error('参数不全')
|
|
850
850
|
return false
|
|
851
851
|
}
|
|
852
852
|
} catch (e) {
|
|
853
853
|
console.error(e)
|
|
854
854
|
}
|
|
855
855
|
}
|