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