@conecli/cone-render 0.9.1-shop2.0 → 0.9.1-shop2.10
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/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/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/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 +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/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/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 +39 -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/taroRenderUtil.ts +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
|
isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
350
350
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
351
351
|
area: '1_72_2799_0',
|
|
352
352
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(window.screen?.height * devicePixelRatio)}`,
|
|
353
353
|
uuid: UUID,
|
|
354
354
|
},
|
|
355
355
|
public addressFetchInfo: {
|
|
356
356
|
reqState: boolean
|
|
357
357
|
promiseInstance: null | Promise<any>
|
|
358
358
|
}
|
|
359
359
|
public getPromotionConfig: {
|
|
360
360
|
projectId: null | string | number
|
|
361
361
|
pageId: null | string | number
|
|
362
362
|
}
|
|
363
363
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
364
364
|
public api: ServiceInterFace.HttpApi
|
|
365
365
|
public isPageDomain: boolean
|
|
366
366
|
public verifyColorList: string[]
|
|
367
367
|
constructor(opt) {
|
|
368
368
|
this._init()
|
|
369
369
|
this.addressFetchInfo = {
|
|
370
370
|
reqState: false,
|
|
371
371
|
promiseInstance: null,
|
|
372
372
|
}
|
|
373
373
|
this.getPromotionConfig = {
|
|
374
374
|
projectId: null,
|
|
375
375
|
pageId: null,
|
|
376
376
|
}
|
|
377
377
|
this._userAreaUpdateListen()
|
|
378
378
|
this.resInfo = this._getResConfig(opt)
|
|
379
379
|
this.api = api
|
|
380
380
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false
|
|
381
381
|
this.verifyColorList = [
|
|
382
382
|
...MobileVerifyColorList,
|
|
383
383
|
...AppVerifyColorList,
|
|
384
384
|
...JshopxVerifyColorList,
|
|
385
385
|
...BMallVerifyColorList,
|
|
386
386
|
]
|
|
387
387
|
}
|
|
388
388
|
_init(): void {
|
|
389
389
|
httpInterceptors.forEach((item) => {
|
|
390
390
|
Taro.addInterceptor((chain) => item(chain))
|
|
391
391
|
})
|
|
392
392
|
}
|
|
393
393
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
394
394
|
return Object.assign({}, DefaultConfig, opt)
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
_userAreaUpdateListen() {
|
|
398
398
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
399
399
|
this.updateApiClientParamsResInfo({
|
|
400
400
|
area,
|
|
401
401
|
})
|
|
402
402
|
})
|
|
403
403
|
}
|
|
404
404
|
updateApiClientParamsResInfo(opt = {}) {
|
|
405
405
|
this.resInfo.apiClientParams = {
|
|
406
406
|
...this.resInfo.apiClientParams,
|
|
407
407
|
...opt,
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
checkFunctionIdToReturnAppId(functionId) {
|
|
412
412
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
413
413
|
return APPID.JSHOPX_COLOR_APPID
|
|
414
414
|
} else if (
|
|
415
415
|
this.isPageDomain &&
|
|
416
416
|
PagesColorFunctionIdList.includes(functionId)
|
|
417
417
|
) {
|
|
418
418
|
return APPID.PAGES_COLOR_APPID
|
|
419
419
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
420
420
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
421
421
|
}else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
422
422
|
return APPID.B2B_COLOR_APPID
|
|
423
423
|
} else if (isPc) {
|
|
424
424
|
return APPID.MALL_COLOR_APPID
|
|
425
425
|
} else {
|
|
426
426
|
return APPID.SHOP_COLOR_APPID
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
gatewayReq(
|
|
431
431
|
functionId: string,
|
|
432
432
|
bodyParams = {},
|
|
433
433
|
clientParams = {},
|
|
434
434
|
): Promise<any> {
|
|
435
435
|
if (
|
|
436
436
|
functionId === 'receiveShopCoupon' &&
|
|
437
437
|
((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) || isWxMinAndWxapp)
|
|
438
438
|
) {
|
|
439
439
|
clientParams = Object.assign(
|
|
440
440
|
{},
|
|
441
441
|
{
|
|
442
442
|
loginType: '1',
|
|
443
443
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
444
444
|
},
|
|
445
445
|
clientParams,
|
|
446
446
|
)
|
|
447
447
|
}
|
|
448
448
|
const apiClientParams = Object.assign(
|
|
449
449
|
{},
|
|
450
450
|
this.resInfo.apiClientParams,
|
|
451
451
|
clientParams,
|
|
452
452
|
)
|
|
453
453
|
typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
454
454
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
455
455
|
const getReqData = {
|
|
456
456
|
functionId: functionId,
|
|
457
457
|
body: JSON.stringify(bodyParams),
|
|
458
458
|
t: Date.now(),
|
|
459
459
|
...apiClientParams,
|
|
460
460
|
}
|
|
461
461
|
return http
|
|
462
462
|
.request({
|
|
463
463
|
url: this.api.apiFunc,
|
|
464
464
|
data: getReqData,
|
|
465
465
|
isColorVerify,
|
|
466
466
|
})
|
|
467
467
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
468
468
|
const { statusCode, data } = res
|
|
469
469
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
470
470
|
ok: true,
|
|
471
471
|
}
|
|
472
472
|
if (statusCode === 200 && data) {
|
|
473
473
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
474
474
|
? Number(res.data.code)
|
|
475
475
|
: -1
|
|
476
476
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
477
477
|
res.data,
|
|
478
478
|
'subCode',
|
|
479
479
|
)
|
|
480
480
|
? Number(res.data.subCode)
|
|
481
481
|
: -1
|
|
482
482
|
if (
|
|
483
483
|
data.success === true ||
|
|
484
484
|
data.isSuccess ||
|
|
485
485
|
resCode === 0 ||
|
|
486
486
|
resCode === 200 ||
|
|
487
487
|
subCode === 0
|
|
488
488
|
) {
|
|
489
489
|
changeRes = {
|
|
490
490
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
491
491
|
? data.result
|
|
492
492
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
493
493
|
? data.data
|
|
494
494
|
: data,
|
|
495
495
|
code: data.code || 200,
|
|
496
496
|
ok: true,
|
|
497
497
|
source: data,
|
|
498
498
|
}
|
|
499
499
|
return changeRes
|
|
500
500
|
} else {
|
|
501
501
|
changeRes = {
|
|
502
502
|
...data,
|
|
503
503
|
ok: false,
|
|
504
504
|
statusCode: res.statusCode,
|
|
505
505
|
}
|
|
506
506
|
return changeRes
|
|
507
507
|
}
|
|
508
508
|
} else {
|
|
509
509
|
changeRes = {
|
|
510
510
|
...data,
|
|
511
511
|
ok: false,
|
|
512
512
|
statusCode: res.statusCode,
|
|
513
513
|
}
|
|
514
514
|
return changeRes
|
|
515
515
|
}
|
|
516
516
|
})
|
|
517
517
|
.catch((res) => {
|
|
518
518
|
return {
|
|
519
519
|
...res,
|
|
520
520
|
ok: false,
|
|
521
521
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
522
522
|
})
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
async receiveCoupon(param = {}, clientParams) {
|
|
526
526
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
527
527
|
return await this.gatewayReq(
|
|
528
528
|
'receiveShopCoupon',
|
|
529
529
|
{
|
|
530
530
|
operation: '3',
|
|
531
531
|
...param,
|
|
532
532
|
},
|
|
533
533
|
{ ...loginType, ...clientParams },
|
|
534
534
|
)
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
getCustomerCenterDispatch(params = {}) {
|
|
538
538
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
539
539
|
clientVersion: '9.2.0',
|
|
540
540
|
client: 'H5',
|
|
541
541
|
uuid: 88888,
|
|
542
542
|
appid: 'shopmember_m_jd_com',
|
|
543
543
|
})
|
|
544
544
|
}
|
|
545
545
|
bMallGetUserInfo = () => {
|
|
546
546
|
return getBMallUserInfo()
|
|
547
547
|
}
|
|
548
548
|
async bMallAddCart(params = {}) {
|
|
549
549
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
550
550
|
client: 'H5',
|
|
551
551
|
clientVersion: '5.5.0'
|
|
552
552
|
})
|
|
553
553
|
}
|
|
554
554
|
async bMallChangeCart(params = {}) {
|
|
555
555
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
556
556
|
client: 'H5',
|
|
557
557
|
clientVersion: '5.5.0'
|
|
558
558
|
})
|
|
559
559
|
}
|
|
560
560
|
async bMallRemoveCart(params = {}) {
|
|
561
561
|
return await this.gatewayReq(
|
|
562
562
|
'bmall_cartRemove',
|
|
563
563
|
params,
|
|
564
564
|
{
|
|
565
565
|
client: 'H5',
|
|
566
566
|
clientVersion: '5.5.0'
|
|
567
567
|
},
|
|
568
568
|
)
|
|
569
569
|
}
|
|
570
570
|
async bMallGetOmittedProduct(params = {}) {
|
|
571
571
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
572
572
|
client: 'H5',
|
|
573
573
|
clientVersion: '5.5.0'
|
|
574
574
|
})
|
|
575
575
|
}
|
|
576
576
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
577
577
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
578
578
|
return await this.bMallAddCart(params)
|
|
579
579
|
}
|
|
580
580
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
581
581
|
const params = await getParams({ bMallTag })
|
|
582
582
|
delete params.operations
|
|
583
583
|
return await this.bMallGetOmittedProduct(params)
|
|
584
584
|
}
|
|
585
585
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
586
586
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
587
587
|
return await this.bMallRemoveCart(params)
|
|
588
588
|
}
|
|
589
589
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
590
590
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
591
591
|
return await this.bMallChangeCart(params)
|
|
592
592
|
}
|
|
593
593
|
|
|
594
594
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
595
595
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
596
596
|
return window?.bMallCartData
|
|
597
597
|
}
|
|
598
598
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
599
599
|
let items
|
|
600
600
|
if (cartData.ok && cartData.result) {
|
|
601
601
|
items = cartData?.result?.items || {}
|
|
602
602
|
}
|
|
603
603
|
if (isH5) {
|
|
604
604
|
window.bMallCartData = items
|
|
605
605
|
}
|
|
606
606
|
return items
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
async bMallCartHandle(goodItem, num) {
|
|
610
610
|
try {
|
|
611
611
|
const {
|
|
612
612
|
skuUuid,
|
|
613
613
|
limitUpper,
|
|
614
614
|
limitLower,
|
|
615
615
|
} = goodItem
|
|
616
616
|
let cartNum = Number(num)
|
|
617
617
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
618
618
|
cartNum = limitLower
|
|
619
619
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
620
620
|
cartNum = limitUpper
|
|
621
621
|
}
|
|
622
622
|
if (skuUuid && cartNum > 0) {
|
|
623
623
|
return this.bMallChangeCartService({
|
|
624
624
|
...goodItem,
|
|
625
625
|
skuUuid,
|
|
626
626
|
num: cartNum,
|
|
627
627
|
})
|
|
628
628
|
} else if (!skuUuid && cartNum > 0) {
|
|
629
629
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
630
630
|
} else if (skuUuid && !cartNum) {
|
|
631
631
|
return this.bMallRemoveCartService({
|
|
632
632
|
...goodItem,
|
|
633
633
|
skuUuid,
|
|
634
634
|
num: cartNum,
|
|
635
635
|
})
|
|
636
636
|
} else {
|
|
637
637
|
console.error('参数不全')
|
|
638
638
|
return false
|
|
639
639
|
}
|
|
640
640
|
} catch (e) {
|
|
641
641
|
console.error(e)
|
|
642
642
|
}
|
|
643
643
|
}
|