@conecli/cone-render 0.9.1-shop2.4 → 0.9.1-shop2.40
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/assets/icon_blue_info.svg +1 -0
- 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/pageType.ts +1 -1
- package/dist/common/sgmCustomCode.ts +1 -0
- 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.module.scss +126 -111
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CountDown/index.module.scss +49 -44
- 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/common.ts +1 -0
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +16 -0
- package/dist/components/base/Dialog/index.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
- 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.module.scss +2 -2
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +23 -20
- 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/components/base/NetworkDataError/index.module.scss +3 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.module.scss +8 -0
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +67 -0
- package/dist/components/debug/DebugLayout/index.tsx +1 -0
- package/dist/components/debug/DebugLayout/utils.ts +1 -0
- package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
- package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/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 -1
- 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 +30 -1
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/device.ts +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 +274 -212
- package/dist/sass/base.scss +195 -137
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- 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/jumpExtMapUtil.js +1 -0
- package/dist/utils/sColor.js +1 -0
- package/dist/utils/sgmCodeUtils.ts +1 -0
- package/dist/utils/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +26 -3
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
- package/dist/utils/memberFormatUtils.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
APPID,
|
|
3
2
|
JshopxColorFunctionIdList,
|
|
4
3
|
PagesColorFunctionIdList,
|
|
5
4
|
PAGES_DOMAIN,
|
|
6
5
|
B2BColorFunctionIdList,
|
|
7
6
|
MobileVerifyColorList,
|
|
8
7
|
AppVerifyColorList,
|
|
9
8
|
JshopxVerifyColorList,
|
|
10
9
|
BMallVerifyColorList,
|
|
11
10
|
shopMemberColorFunctionIdList
|
|
12
11
|
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') : isPc ? 'pc' : '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 if (isPc) {
|
|
104
103
|
return APPID.MALL_COLOR_APPID
|
|
105
104
|
} else {
|
|
106
105
|
return APPID.SHOP_COLOR_APPID
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
gatewayReq(
|
|
111
110
|
functionId: string,
|
|
112
111
|
bodyParams = {},
|
|
113
112
|
clientParams = {},
|
|
114
113
|
): Promise<any> {
|
|
115
114
|
if (
|
|
116
115
|
functionId === 'receiveShopCoupon' &&
|
|
117
116
|
((isH5 && window?.isJingGouMiniViewState) || isWxMinAndWxapp)
|
|
118
117
|
) {
|
|
119
118
|
clientParams = Object.assign(
|
|
120
119
|
{},
|
|
121
120
|
{
|
|
122
121
|
loginType: '1',
|
|
123
122
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
124
123
|
},
|
|
125
124
|
clientParams,
|
|
126
125
|
)
|
|
127
126
|
}
|
|
128
127
|
const apiClientParams = Object.assign(
|
|
129
128
|
{},
|
|
130
129
|
this.resInfo.apiClientParams,
|
|
131
130
|
clientParams,
|
|
132
131
|
)
|
|
133
132
|
typeof apiClientParams.appid === 'undefined' && (apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
134
133
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
135
134
|
const getReqData = {
|
|
136
135
|
functionId: functionId,
|
|
137
136
|
body: JSON.stringify(bodyParams),
|
|
138
137
|
t: Date.now(),
|
|
139
138
|
...apiClientParams,
|
|
140
139
|
}
|
|
141
140
|
return http
|
|
142
141
|
.request({
|
|
143
142
|
url: this.api.apiFunc,
|
|
144
143
|
data: getReqData,
|
|
145
144
|
isColorVerify,
|
|
146
145
|
})
|
|
147
146
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
148
147
|
const { statusCode, data } = res
|
|
149
148
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
150
149
|
ok: true,
|
|
151
150
|
}
|
|
152
151
|
if (statusCode === 200 && data) {
|
|
153
152
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
154
153
|
? Number(res.data.code)
|
|
155
154
|
: -1
|
|
156
155
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
157
156
|
res.data,
|
|
158
157
|
'subCode',
|
|
159
158
|
)
|
|
160
159
|
? Number(res.data.subCode)
|
|
161
160
|
: -1
|
|
162
161
|
if (
|
|
163
162
|
data.success === true ||
|
|
164
163
|
data.isSuccess ||
|
|
165
164
|
resCode === 0 ||
|
|
166
165
|
resCode === 200 ||
|
|
167
166
|
subCode === 0
|
|
168
167
|
) {
|
|
169
168
|
changeRes = {
|
|
170
169
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
171
170
|
? data.result
|
|
172
171
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
173
172
|
? data.data
|
|
174
173
|
: data,
|
|
175
174
|
code: data.code || 200,
|
|
176
175
|
ok: true,
|
|
177
176
|
source: data,
|
|
178
177
|
}
|
|
179
178
|
return changeRes
|
|
180
179
|
} else {
|
|
181
180
|
changeRes = {
|
|
182
181
|
...data,
|
|
183
182
|
ok: false,
|
|
184
183
|
statusCode: res.statusCode,
|
|
185
184
|
}
|
|
186
185
|
return changeRes
|
|
187
186
|
}
|
|
188
187
|
} else {
|
|
189
188
|
changeRes = {
|
|
190
189
|
...data,
|
|
191
190
|
ok: false,
|
|
192
191
|
statusCode: res.statusCode,
|
|
193
192
|
}
|
|
194
193
|
return changeRes
|
|
195
194
|
}
|
|
196
195
|
})
|
|
197
196
|
.catch((res) => {
|
|
198
197
|
return {
|
|
199
198
|
...res,
|
|
200
199
|
ok: false,
|
|
201
200
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
202
201
|
})
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
async receiveCoupon(param = {}, clientParams) {
|
|
206
205
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
207
206
|
return await this.gatewayReq(
|
|
208
207
|
'receiveShopCoupon',
|
|
209
208
|
{
|
|
210
209
|
operation: '3',
|
|
211
210
|
...param,
|
|
212
211
|
},
|
|
213
212
|
{ ...loginType, ...clientParams },
|
|
214
213
|
)
|
|
215
214
|
}
|
|
216
215
|
|
|
217
216
|
getCustomerCenterDispatch(params = {}) {
|
|
218
217
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
219
218
|
clientVersion: '9.2.0',
|
|
220
219
|
client: 'H5',
|
|
221
220
|
uuid: 88888,
|
|
222
221
|
appid: 'shopmember_m_jd_com',
|
|
223
222
|
})
|
|
224
223
|
}
|
|
225
224
|
bMallGetUserInfo = () => {
|
|
226
225
|
return getBMallUserInfo()
|
|
227
226
|
}
|
|
228
227
|
async bMallAddCart(params = {}) {
|
|
229
228
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
230
229
|
client: 'H5',
|
|
231
230
|
clientVersion: '5.5.0'
|
|
232
231
|
})
|
|
233
232
|
}
|
|
234
233
|
async bMallChangeCart(params = {}) {
|
|
235
234
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
236
235
|
client: 'H5',
|
|
237
236
|
clientVersion: '5.5.0'
|
|
238
237
|
})
|
|
239
238
|
}
|
|
240
239
|
async bMallRemoveCart(params = {}) {
|
|
241
240
|
return await this.gatewayReq(
|
|
242
241
|
'bmall_cartRemove',
|
|
243
242
|
params,
|
|
244
243
|
{
|
|
245
244
|
client: 'H5',
|
|
246
245
|
clientVersion: '5.5.0'
|
|
247
246
|
},
|
|
248
247
|
)
|
|
249
248
|
}
|
|
250
249
|
async bMallGetOmittedProduct(params = {}) {
|
|
251
250
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
252
251
|
client: 'H5',
|
|
253
252
|
clientVersion: '5.5.0'
|
|
254
253
|
})
|
|
255
254
|
}
|
|
256
255
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
257
256
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
258
257
|
return await this.bMallAddCart(params)
|
|
259
258
|
}
|
|
260
259
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
261
260
|
const params = await getParams({ bMallTag })
|
|
262
261
|
delete params.operations
|
|
263
262
|
return await this.bMallGetOmittedProduct(params)
|
|
264
263
|
}
|
|
265
264
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
266
265
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
267
266
|
return await this.bMallRemoveCart(params)
|
|
268
267
|
}
|
|
269
268
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
270
269
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
271
270
|
return await this.bMallChangeCart(params)
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
275
274
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
276
275
|
return window?.bMallCartData
|
|
277
276
|
}
|
|
278
277
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
279
278
|
let items
|
|
280
279
|
if (cartData.ok && cartData.result) {
|
|
281
280
|
items = cartData?.result?.items || {}
|
|
282
281
|
}
|
|
283
282
|
if (isH5) {
|
|
284
283
|
window.bMallCartData = items
|
|
285
284
|
}
|
|
286
285
|
return items
|
|
287
286
|
}
|
|
288
287
|
|
|
289
288
|
async bMallCartHandle(goodItem, num) {
|
|
290
289
|
try {
|
|
291
290
|
const {
|
|
292
291
|
skuUuid,
|
|
293
292
|
limitUpper,
|
|
294
293
|
limitLower,
|
|
295
294
|
} = goodItem
|
|
296
295
|
let cartNum = Number(num)
|
|
297
296
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
298
297
|
cartNum = limitLower
|
|
299
298
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
300
299
|
cartNum = limitUpper
|
|
301
300
|
}
|
|
302
301
|
if (skuUuid && cartNum > 0) {
|
|
303
302
|
return this.bMallChangeCartService({
|
|
304
303
|
...goodItem,
|
|
305
304
|
skuUuid,
|
|
306
305
|
num: cartNum,
|
|
307
306
|
})
|
|
308
307
|
} else if (!skuUuid && cartNum > 0) {
|
|
309
308
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
310
309
|
} else if (skuUuid && !cartNum) {
|
|
311
310
|
return this.bMallRemoveCartService({
|
|
312
311
|
...goodItem,
|
|
313
312
|
skuUuid,
|
|
314
313
|
num: cartNum,
|
|
315
314
|
})
|
|
316
315
|
} else {
|
|
317
316
|
console.error('参数不全')
|
|
318
317
|
return false
|
|
319
318
|
}
|
|
320
319
|
} catch (e) {
|
|
321
320
|
console.error(e)
|
|
322
321
|
}
|
|
323
322
|
}
|
|
323
|
+
import Taro from '@tarojs/taro';
|
|
324
324
|
APPID,
|
|
325
325
|
JshopxColorFunctionIdList,
|
|
326
326
|
PagesColorFunctionIdList,
|
|
327
327
|
PAGES_DOMAIN,
|
|
328
328
|
B2BColorFunctionIdList,
|
|
329
329
|
MobileVerifyColorList,
|
|
330
330
|
AppVerifyColorList,
|
|
331
331
|
JshopxVerifyColorList,
|
|
332
332
|
BMallVerifyColorList,
|
|
333
333
|
shopMemberColorFunctionIdList,
|
|
334
334
|
isLanguageForEn,
|
|
335
335
|
isJdApp,
|
|
336
336
|
isIosDevice,
|
|
337
337
|
isAndroidDevice,
|
|
338
338
|
showSuccessToast,
|
|
339
339
|
showFailToast,
|
|
340
340
|
isH5,
|
|
341
341
|
isWxMinAndWxapp,
|
|
342
342
|
isMin,
|
|
343
343
|
isPc,
|
|
344
344
|
cookiesStr: '',
|
|
345
345
|
requestHeaderContentType: {
|
|
346
346
|
jsonHeader: {
|
|
347
347
|
'content-type': 'application/json;charset=utf-8',
|
|
348
348
|
},
|
|
349
349
|
formDataHeader: {
|
|
350
350
|
'content-type': 'application/x-www-form-urlencoded',
|
|
351
351
|
},
|
|
352
352
|
},
|
|
353
353
|
requestBaseParam: {
|
|
354
354
|
data: null,
|
|
355
355
|
header: {
|
|
356
356
|
'content-type': 'application/json;charset=utf-8',
|
|
357
357
|
},
|
|
358
358
|
},
|
|
359
359
|
timeOut: 7000,
|
|
360
360
|
apiClientParams: {
|
|
361
361
|
clientVersion: isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
362
362
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
363
363
|
area: '1_72_2799_0',
|
|
364
364
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
|
|
365
365
|
window.screen?.height * devicePixelRatio,
|
|
366
366
|
)}`,
|
|
367
367
|
uuid: UUID,
|
|
368
368
|
},
|
|
369
369
|
public addressFetchInfo: {
|
|
370
370
|
reqState: boolean;
|
|
371
371
|
promiseInstance: null | Promise<any>;
|
|
372
372
|
};
|
|
373
373
|
public getPromotionConfig: {
|
|
374
374
|
projectId: null | string | number;
|
|
375
375
|
pageId: null | string | number;
|
|
376
376
|
};
|
|
377
377
|
public resInfo: ServiceInterFace.HttpRequestInfo;
|
|
378
378
|
public api: ServiceInterFace.HttpApi;
|
|
379
379
|
public isPageDomain: boolean;
|
|
380
380
|
public verifyColorList: string[];
|
|
381
381
|
constructor(opt) {
|
|
382
382
|
this._init();
|
|
383
383
|
this.addressFetchInfo = {
|
|
384
384
|
reqState: false,
|
|
385
385
|
promiseInstance: null,
|
|
386
386
|
};
|
|
387
387
|
this.getPromotionConfig = {
|
|
388
388
|
projectId: null,
|
|
389
389
|
pageId: null,
|
|
390
390
|
};
|
|
391
391
|
this._userAreaUpdateListen();
|
|
392
392
|
this.resInfo = this._getResConfig(opt);
|
|
393
393
|
this.api = api;
|
|
394
394
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
|
|
395
395
|
this.verifyColorList = [
|
|
396
396
|
...MobileVerifyColorList,
|
|
397
397
|
...AppVerifyColorList,
|
|
398
398
|
...JshopxVerifyColorList,
|
|
399
399
|
...BMallVerifyColorList,
|
|
400
400
|
];
|
|
401
401
|
}
|
|
402
402
|
_init(): void {
|
|
403
403
|
httpInterceptors.forEach((item) => {
|
|
404
404
|
Taro.addInterceptor((chain) => item(chain));
|
|
405
405
|
});
|
|
406
406
|
}
|
|
407
407
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
408
408
|
return Object.assign({}, DefaultConfig, opt);
|
|
409
409
|
}
|
|
410
410
|
|
|
411
411
|
_userAreaUpdateListen() {
|
|
412
412
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
413
413
|
this.updateApiClientParamsResInfo({
|
|
414
414
|
area,
|
|
415
415
|
});
|
|
416
416
|
});
|
|
417
417
|
}
|
|
418
418
|
updateApiClientParamsResInfo(opt = {}) {
|
|
419
419
|
this.resInfo.apiClientParams = {
|
|
420
420
|
...this.resInfo.apiClientParams,
|
|
421
421
|
...opt,
|
|
422
422
|
};
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
checkFunctionIdToReturnAppId(functionId) {
|
|
426
426
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
427
427
|
return APPID.JSHOPX_COLOR_APPID;
|
|
428
428
|
} else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
|
|
429
429
|
return APPID.PAGES_COLOR_APPID;
|
|
430
430
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
431
431
|
return APPID.SHOP_MEMBER_COLOR_APPID;
|
|
432
432
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
433
433
|
return APPID.B2B_COLOR_APPID;
|
|
434
434
|
} else if (isPc) {
|
|
435
435
|
return APPID.MALL_COLOR_APPID;
|
|
436
436
|
} else {
|
|
437
437
|
return APPID.SHOP_COLOR_APPID;
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
|
|
442
442
|
if (
|
|
443
443
|
functionId === 'receiveShopCoupon' &&
|
|
444
444
|
((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
|
|
445
445
|
isWxMinAndWxapp)
|
|
446
446
|
) {
|
|
447
447
|
clientParams = Object.assign(
|
|
448
448
|
{},
|
|
449
449
|
{
|
|
450
450
|
loginType: '1',
|
|
451
451
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
452
452
|
},
|
|
453
453
|
clientParams,
|
|
454
454
|
);
|
|
455
455
|
}
|
|
456
456
|
const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
|
|
457
457
|
typeof apiClientParams.appid === 'undefined' &&
|
|
458
458
|
(apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
|
|
459
459
|
const isColorVerify = this.verifyColorList.includes(functionId);
|
|
460
460
|
const getReqData = {
|
|
461
461
|
functionId: functionId,
|
|
462
462
|
body: JSON.stringify(bodyParams),
|
|
463
463
|
t: Date.now(),
|
|
464
464
|
...apiClientParams,
|
|
465
465
|
};
|
|
466
466
|
return http
|
|
467
467
|
.request({
|
|
468
468
|
url: this.api.apiFunc,
|
|
469
469
|
data: getReqData,
|
|
470
470
|
isColorVerify,
|
|
471
471
|
})
|
|
472
472
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
473
473
|
const { statusCode, data } = res;
|
|
474
474
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
475
475
|
ok: true,
|
|
476
476
|
};
|
|
477
477
|
if (statusCode === 200 && data) {
|
|
478
478
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
479
479
|
? Number(res.data.code)
|
|
480
480
|
: -1;
|
|
481
481
|
const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
|
|
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(...args) {
|
|
549
549
|
let skuIds, num, showToast, giftCard;
|
|
550
550
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
551
551
|
[skuIds, num = 1, showToast = true, giftCard = false] = args;
|
|
552
552
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
553
553
|
const params = args[0];
|
|
554
554
|
skuIds = params.skuIds;
|
|
555
555
|
num = params.num || 1;
|
|
556
556
|
showToast = params.showToast !== undefined ? params.showToast : true;
|
|
557
557
|
giftCard = params.giftCard !== undefined ? params.giftCard : false;
|
|
558
558
|
} else {
|
|
559
559
|
console.error('batchAddCart() Invalid arguments!', args);
|
|
560
560
|
const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
|
|
561
561
|
showFailToast({
|
|
562
562
|
title: msg,
|
|
563
563
|
});
|
|
564
564
|
return Promise.resolve({
|
|
565
565
|
ok: false,
|
|
566
566
|
msg,
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
569
|
const addToWhereText = giftCard ? '购物清单' : '购物车';
|
|
570
570
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
|
|
571
571
|
const failMsg = isLanguageForEn
|
|
572
572
|
? 'Please retry later'
|
|
573
573
|
: `加入${addToWhereText}失败,请稍后重试!`;
|
|
574
574
|
if (skuIds) {
|
|
575
575
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
576
576
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
577
577
|
if (res?.ok) {
|
|
578
578
|
if (showToast && !res?.isOpenApp)
|
|
579
579
|
showSuccessToast({
|
|
580
580
|
title: successMsg,
|
|
581
581
|
});
|
|
582
582
|
} else {
|
|
583
583
|
showToast &&
|
|
584
584
|
showFailToast({
|
|
585
585
|
title: res?.errMsg || failMsg,
|
|
586
586
|
});
|
|
587
587
|
}
|
|
588
588
|
return Promise.resolve(res);
|
|
589
589
|
})
|
|
590
590
|
.catch((e) => {
|
|
591
591
|
console.log('调用加购方法异常=======>', e);
|
|
592
592
|
return Promise.resolve({
|
|
593
593
|
ok: false,
|
|
594
594
|
msg: failMsg,
|
|
595
595
|
});
|
|
596
596
|
});
|
|
597
597
|
} else {
|
|
598
598
|
return Promise.resolve({
|
|
599
599
|
ok: false,
|
|
600
600
|
msg: failMsg,
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
|
|
605
605
|
async giftCardAddCart(skuList, num) {
|
|
606
606
|
const loginType = isPc ? { loginType: 3 } : {};
|
|
607
607
|
return this.gatewayReq(
|
|
608
608
|
'giftCardAddCart',
|
|
609
609
|
{
|
|
610
610
|
skuList,
|
|
611
611
|
num: Number(num),
|
|
612
612
|
},
|
|
613
613
|
{ ...loginType },
|
|
614
614
|
);
|
|
615
615
|
}
|
|
616
616
|
|
|
617
617
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
618
618
|
return new Promise((resolve) => {
|
|
619
619
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
|
|
620
620
|
if (productIdsArr.length > 0) {
|
|
621
621
|
if (giftCard) {
|
|
622
622
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
623
623
|
.then((res) => {
|
|
624
624
|
if (res?.code === '0' && res?.result?.value) {
|
|
625
625
|
resolve({
|
|
626
626
|
ok: true,
|
|
627
627
|
});
|
|
628
628
|
} else {
|
|
629
629
|
resolve({
|
|
630
630
|
ok: false,
|
|
631
631
|
msg: '加购失败,请稍后重试',
|
|
632
632
|
});
|
|
633
633
|
}
|
|
634
634
|
})
|
|
635
635
|
.catch((e) => {
|
|
636
636
|
console.error('礼品卡加车失败: ', e);
|
|
637
637
|
resolve({
|
|
638
638
|
ok: false,
|
|
639
639
|
msg: '加购失败,请稍后重试',
|
|
640
640
|
});
|
|
641
641
|
});
|
|
642
642
|
} else if (isJdApp) {
|
|
643
643
|
const nativeAddCartCallBack = `nativeBatchAddCart${
|
|
644
644
|
Date.now() + Number(productIdsArr[0]) + Number(addCardNum)
|
|
645
645
|
}`;
|
|
646
646
|
console.log(
|
|
647
647
|
'==========>',
|
|
648
648
|
'原生批量加车, 回调方法保证唯一添加skuid和数量,nativeAddCartCallBack',
|
|
649
649
|
nativeAddCartCallBack,
|
|
650
650
|
);
|
|
651
651
|
if (!window[nativeAddCartCallBack]) {
|
|
652
652
|
window[nativeAddCartCallBack] = (res) => {
|
|
653
653
|
const getMessageJsonData = typeof res === 'string' ? JSON.parse(res) : res;
|
|
654
654
|
console.info(
|
|
655
655
|
'获取批量加车原始数据',
|
|
656
656
|
res,
|
|
657
657
|
'====转换后的json数据为===',
|
|
658
658
|
getMessageJsonData,
|
|
659
659
|
);
|
|
660
660
|
try {
|
|
661
661
|
if (isAndroidDevice) {
|
|
662
662
|
getMessageJsonData?.status === '0'
|
|
663
663
|
? resolve({
|
|
664
664
|
ok: true,
|
|
665
665
|
msg: '已加入购物车!',
|
|
666
666
|
})
|
|
667
667
|
: resolve({
|
|
668
668
|
ok: false,
|
|
669
669
|
msg: '加购失败,请稍后重试',
|
|
670
670
|
});
|
|
671
671
|
} else if (isIosDevice) {
|
|
672
672
|
getMessageJsonData?.status === '0' && getMessageJsonData?.data?.code === 0
|
|
673
673
|
? resolve({
|
|
674
674
|
ok: true,
|
|
675
675
|
msg: '已加入购物车!',
|
|
676
676
|
})
|
|
677
677
|
: resolve({
|
|
678
678
|
ok: false,
|
|
679
679
|
msg: '批量加车失败,请稍后重试',
|
|
680
680
|
});
|
|
681
681
|
} else {
|
|
682
682
|
resolve({
|
|
683
683
|
ok: false,
|
|
684
684
|
msg: '加购失败,请稍后重试',
|
|
685
685
|
});
|
|
686
686
|
}
|
|
687
687
|
} catch (e) {
|
|
688
688
|
resolve({
|
|
689
689
|
ok: false,
|
|
690
690
|
msg: '加购失败,请稍后重试',
|
|
691
691
|
});
|
|
692
692
|
console.warn('批量加车转换数据异常', e);
|
|
693
693
|
}
|
|
694
694
|
window[nativeAddCartCallBack] = null;
|
|
695
695
|
};
|
|
696
696
|
}
|
|
697
697
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
698
698
|
return isAndroidDevice
|
|
699
699
|
? {
|
|
700
700
|
sku: skuItem,
|
|
701
701
|
num: addCardNum,
|
|
702
702
|
}
|
|
703
703
|
: {
|
|
704
704
|
productCode: skuItem,
|
|
705
705
|
buyCount: addCardNum,
|
|
706
706
|
};
|
|
707
707
|
});
|
|
708
708
|
if (isAndroidDevice) {
|
|
709
709
|
const androidProductsStr = JSON.stringify(productsAddCartList);
|
|
710
710
|
callRouterAndroid({
|
|
711
711
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
|
|
712
712
|
routerParam: {
|
|
713
713
|
wareList: productsAddCartList,
|
|
714
714
|
},
|
|
715
715
|
callBackName: nativeAddCartCallBack,
|
|
716
716
|
});
|
|
717
717
|
} else if (isIosDevice) {
|
|
718
718
|
if (isLowAppVer) {
|
|
719
719
|
const lowVersionAppList = productIdsArr.map((skuItem) => {
|
|
720
720
|
return {
|
|
721
721
|
sku: skuItem,
|
|
722
722
|
num: addCardNum,
|
|
723
723
|
};
|
|
724
724
|
});
|
|
725
725
|
const lowVersionAppListStr = JSON.stringify(lowVersionAppList);
|
|
726
726
|
const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`;
|
|
727
727
|
jump.side.jdJumpToWeb(url, {});
|
|
728
728
|
resolve({
|
|
729
729
|
ok: true,
|
|
730
730
|
isOpenApp: true,
|
|
731
731
|
msg: '加购完成, 加购结果请点击购物车确认',
|
|
732
732
|
});
|
|
733
733
|
} else {
|
|
734
734
|
callRouterIOS({
|
|
735
735
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
736
736
|
routerParam: {
|
|
737
737
|
sourceType: 'h5',
|
|
738
738
|
sourceValue: '店铺批量加购',
|
|
739
739
|
businessName: 'storeModel',
|
|
740
740
|
isNewMode: '1',
|
|
741
741
|
NotPassWebview: '1',
|
|
742
742
|
products: productsAddCartList,
|
|
743
743
|
},
|
|
744
744
|
callBackName: nativeAddCartCallBack,
|
|
745
745
|
});
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
} else if (isMin) {
|
|
749
749
|
console.log('==========>', '京购批量加车!');
|
|
750
750
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
751
751
|
return {
|
|
752
752
|
skuId: skuItem,
|
|
753
753
|
buyNum: addCardNum,
|
|
754
754
|
};
|
|
755
755
|
});
|
|
756
756
|
global.wxAppBizInstance
|
|
757
757
|
.addCart({ commArr: productsAddCartList })
|
|
758
758
|
.then((res) => {
|
|
759
759
|
console.log('dealCartSuccess: ', res);
|
|
760
760
|
resolve({
|
|
761
761
|
ok: true,
|
|
762
762
|
msg: '已加入购物车!',
|
|
763
763
|
data: res,
|
|
764
764
|
});
|
|
765
765
|
})
|
|
766
766
|
.catch((e) => {
|
|
767
767
|
console.log('京购小程序批量加车失败dealCartFail: ', e);
|
|
768
768
|
resolve({
|
|
769
769
|
ok: false,
|
|
770
770
|
msg: '加购失败,请稍后重试',
|
|
771
771
|
});
|
|
772
772
|
});
|
|
773
773
|
} else {
|
|
774
774
|
console.log('==========>', 'M站批量加车!');
|
|
775
775
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
|
|
776
776
|
}
|
|
777
777
|
} else {
|
|
778
778
|
resolve({
|
|
779
779
|
ok: false,
|
|
780
780
|
msg: '加购sku不能为空',
|
|
781
781
|
});
|
|
782
782
|
}
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
785
|
|
|
786
786
|
productAddToCart(skuIdsStr, num) {
|
|
787
787
|
return new Promise((resolve) => {
|
|
788
788
|
if (window.AddcartToolObj) {
|
|
789
789
|
window.AddcartToolObj.addCart({
|
|
790
790
|
skuId: skuIdsStr,
|
|
791
791
|
num,
|
|
792
792
|
source: 'sjdpyw',
|
|
793
793
|
actId: '1',
|
|
794
794
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
795
795
|
sucFun(res) {
|
|
796
796
|
console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
|
|
797
797
|
if (res.errId === '0' && res.cartJson) {
|
|
798
798
|
resolve({
|
|
799
799
|
ok: true,
|
|
800
800
|
msg: '已加入购物车!',
|
|
801
801
|
...res,
|
|
802
802
|
});
|
|
803
803
|
} else {
|
|
804
804
|
if (res.errId === '13') {
|
|
805
805
|
global.doLogin();
|
|
806
806
|
} else {
|
|
807
807
|
resolve({
|
|
808
808
|
ok: false,
|
|
809
809
|
msg: '加购失败,请稍后重试',
|
|
810
810
|
...res,
|
|
811
811
|
});
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
},
|
|
815
815
|
failFun(err) {
|
|
816
816
|
console.log('fail', err);
|
|
817
817
|
resolve({
|
|
818
818
|
ok: false,
|
|
819
819
|
msg: '加购失败,请稍后重试',
|
|
820
820
|
...err,
|
|
821
821
|
});
|
|
822
822
|
},
|
|
823
823
|
});
|
|
824
824
|
} else {
|
|
825
825
|
resolve({
|
|
826
826
|
ok: false,
|
|
827
827
|
msg: '购物车方法检查异常',
|
|
828
828
|
});
|
|
829
829
|
}
|
|
830
830
|
});
|
|
831
831
|
}
|
|
832
832
|
bMallGetUserInfo = () => {
|
|
833
833
|
return getBMallUserInfo();
|
|
834
834
|
};
|
|
835
835
|
async bMallAddCart(params = {}) {
|
|
836
836
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
837
837
|
client: 'H5',
|
|
838
838
|
clientVersion: '5.5.0',
|
|
839
839
|
});
|
|
840
840
|
}
|
|
841
841
|
async bMallChangeCart(params = {}) {
|
|
842
842
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
843
843
|
client: 'H5',
|
|
844
844
|
clientVersion: '5.5.0',
|
|
845
845
|
});
|
|
846
846
|
}
|
|
847
847
|
async bMallRemoveCart(params = {}) {
|
|
848
848
|
return await this.gatewayReq(
|
|
849
849
|
'bmall_cartRemove',
|
|
850
850
|
params,
|
|
851
851
|
{
|
|
852
852
|
client: 'H5',
|
|
853
853
|
clientVersion: '5.5.0',
|
|
854
854
|
},
|
|
855
855
|
);
|
|
856
856
|
}
|
|
857
857
|
async bMallGetOmittedProduct(params = {}) {
|
|
858
858
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
859
859
|
client: 'H5',
|
|
860
860
|
clientVersion: '5.5.0',
|
|
861
861
|
});
|
|
862
862
|
}
|
|
863
863
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
864
864
|
const params = await getParams({ ...data, skuId, bMallTag, num });
|
|
865
865
|
return await this.bMallAddCart(params);
|
|
866
866
|
}
|
|
867
867
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
868
868
|
const params = await getParams({ bMallTag });
|
|
869
869
|
delete params.operations;
|
|
870
870
|
return await this.bMallGetOmittedProduct(params);
|
|
871
871
|
}
|
|
872
872
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
873
873
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
874
874
|
return await this.bMallRemoveCart(params);
|
|
875
875
|
}
|
|
876
876
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
877
877
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
878
878
|
return await this.bMallChangeCart(params);
|
|
879
879
|
}
|
|
880
880
|
|
|
881
881
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
882
882
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
883
883
|
return window?.bMallCartData;
|
|
884
884
|
}
|
|
885
885
|
const cartData = await this.bMallGetSkuNumService(bMallTag);
|
|
886
886
|
let items;
|
|
887
887
|
if (cartData.ok && cartData.result) {
|
|
888
888
|
items = cartData?.result?.items || {};
|
|
889
889
|
}
|
|
890
890
|
if (isH5) {
|
|
891
891
|
window.bMallCartData = items;
|
|
892
892
|
}
|
|
893
893
|
return items;
|
|
894
894
|
}
|
|
895
895
|
|
|
896
896
|
async bMallCartHandle(goodItem, num) {
|
|
897
897
|
try {
|
|
898
898
|
const {
|
|
899
899
|
skuUuid,
|
|
900
900
|
limitUpper,
|
|
901
901
|
limitLower,
|
|
902
902
|
} = goodItem;
|
|
903
903
|
let cartNum = Number(num);
|
|
904
904
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
905
905
|
cartNum = limitLower;
|
|
906
906
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
907
907
|
cartNum = limitUpper;
|
|
908
908
|
}
|
|
909
909
|
if (skuUuid && cartNum > 0) {
|
|
910
910
|
return this.bMallChangeCartService({
|
|
911
911
|
...goodItem,
|
|
912
912
|
skuUuid,
|
|
913
913
|
num: cartNum,
|
|
914
914
|
});
|
|
915
915
|
} else if (!skuUuid && cartNum > 0) {
|
|
916
916
|
return this.bMallAddCartService({ ...goodItem, num: cartNum });
|
|
917
917
|
} else if (skuUuid && !cartNum) {
|
|
918
918
|
return this.bMallRemoveCartService({
|
|
919
919
|
...goodItem,
|
|
920
920
|
skuUuid,
|
|
921
921
|
num: cartNum,
|
|
922
922
|
});
|
|
923
923
|
} else {
|
|
924
924
|
console.error('参数不全');
|
|
925
925
|
return false;
|
|
926
926
|
}
|
|
927
927
|
} catch (e) {
|
|
928
928
|
console.error(e);
|
|
929
929
|
}
|
|
930
930
|
}
|