@conecli/cone-render 0.9.1-shop2.3 → 0.9.1-shop2.30
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 +1 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
|
APPID,
|
|
1
3
|
JshopxColorFunctionIdList,
|
|
2
4
|
PagesColorFunctionIdList,
|
|
3
5
|
PAGES_DOMAIN,
|
|
4
6
|
B2BColorFunctionIdList,
|
|
5
7
|
MobileVerifyColorList,
|
|
6
8
|
AppVerifyColorList,
|
|
7
9
|
JshopxVerifyColorList,
|
|
8
10
|
BMallVerifyColorList,
|
|
9
11
|
shopMemberColorFunctionIdList,
|
|
10
12
|
isJdApp,
|
|
11
13
|
isIosDevice,
|
|
12
14
|
isAndroidDevice,
|
|
13
15
|
showSuccessToast,
|
|
14
16
|
showFailToast,
|
|
15
17
|
isH5,
|
|
16
18
|
isWxMinAndWxapp,
|
|
17
19
|
isMin,
|
|
18
20
|
isPc,
|
|
19
21
|
sgmCustomReport,
|
|
20
22
|
getSgmCustomCode,
|
|
21
23
|
draInterfaceCustomReport,
|
|
22
24
|
callRouterIOS,
|
|
23
25
|
callRouterAndroid,
|
|
24
26
|
cookiesStr: '',
|
|
25
27
|
requestHeaderContentType: {
|
|
26
28
|
jsonHeader: {
|
|
27
29
|
'content-type': 'application/json;charset=utf-8',
|
|
28
30
|
},
|
|
29
31
|
formDataHeader: {
|
|
30
32
|
'content-type': 'application/x-www-form-urlencoded',
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
requestBaseParam: {
|
|
34
36
|
data: null,
|
|
35
37
|
header: {
|
|
36
38
|
'content-type': 'application/json;charset=utf-8',
|
|
37
39
|
},
|
|
38
40
|
},
|
|
39
41
|
timeOut: 7000,
|
|
40
42
|
apiClientParams: {
|
|
41
43
|
clientVersion:
|
|
42
44
|
isJdApp && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
43
45
|
client: isJdApp ? (isIosDevice ? 'apple' : 'android') : isPc ? 'pc' : 'wh5',
|
|
44
46
|
area: '1_72_2799_0',
|
|
45
47
|
screen: `${Math.ceil(window.screen?.width * devicePixelRatio)}*${Math.ceil(
|
|
46
48
|
window.screen?.height * devicePixelRatio,
|
|
47
49
|
)}`,
|
|
48
50
|
uuid: UUID,
|
|
49
51
|
},
|
|
50
52
|
public addressFetchInfo: {
|
|
51
53
|
reqState: boolean
|
|
52
54
|
promiseInstance: null | Promise<any>
|
|
53
55
|
}
|
|
54
56
|
public getPromotionConfig: {
|
|
55
57
|
projectId: null | string | number
|
|
56
58
|
pageId: null | string | number
|
|
57
59
|
}
|
|
58
60
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
59
61
|
public api: ServiceInterFace.HttpApi
|
|
60
62
|
public isPageDomain: boolean
|
|
61
63
|
public verifyColorList: string[]
|
|
62
64
|
constructor(opt) {
|
|
63
65
|
this._init()
|
|
64
66
|
this.addressFetchInfo = {
|
|
65
67
|
reqState: false,
|
|
66
68
|
promiseInstance: null,
|
|
67
69
|
}
|
|
68
70
|
this.getPromotionConfig = {
|
|
69
71
|
projectId: null,
|
|
70
72
|
pageId: null,
|
|
71
73
|
}
|
|
72
74
|
this._userAreaUpdateListen()
|
|
73
75
|
this.resInfo = this._getResConfig(opt)
|
|
74
76
|
this.api = api
|
|
75
77
|
this.isPageDomain = isH5
|
|
76
78
|
? window?.location?.hostname === PAGES_DOMAIN
|
|
77
79
|
: false
|
|
78
80
|
this.verifyColorList = [
|
|
79
81
|
...MobileVerifyColorList,
|
|
80
82
|
...AppVerifyColorList,
|
|
81
83
|
...JshopxVerifyColorList,
|
|
82
84
|
...BMallVerifyColorList,
|
|
83
85
|
]
|
|
84
86
|
}
|
|
85
87
|
_init(): void {
|
|
86
88
|
httpInterceptors.forEach((item) => {
|
|
87
89
|
Taro.addInterceptor((chain) => item(chain))
|
|
88
90
|
})
|
|
89
91
|
}
|
|
90
92
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
91
93
|
return Object.assign({}, DefaultConfig, opt)
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
_userAreaUpdateListen() {
|
|
95
97
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
96
98
|
this.updateApiClientParamsResInfo({
|
|
97
99
|
area,
|
|
98
100
|
})
|
|
99
101
|
})
|
|
100
102
|
}
|
|
101
103
|
updateApiClientParamsResInfo(opt = {}) {
|
|
102
104
|
this.resInfo.apiClientParams = {
|
|
103
105
|
...this.resInfo.apiClientParams,
|
|
104
106
|
...opt,
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
checkFunctionIdToReturnAppId(functionId) {
|
|
109
111
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
110
112
|
return APPID.JSHOPX_COLOR_APPID
|
|
111
113
|
} else if (
|
|
112
114
|
this.isPageDomain &&
|
|
113
115
|
PagesColorFunctionIdList.includes(functionId)
|
|
114
116
|
) {
|
|
115
117
|
return APPID.PAGES_COLOR_APPID
|
|
116
118
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
117
119
|
return APPID.SHOP_MEMBER_COLOR_APPID
|
|
118
120
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
119
121
|
return APPID.B2B_COLOR_APPID
|
|
120
122
|
} else if (isPc) {
|
|
121
123
|
return APPID.MALL_COLOR_APPID
|
|
122
124
|
} else {
|
|
123
125
|
return APPID.SHOP_COLOR_APPID
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
gatewayReq(
|
|
128
130
|
functionId: string,
|
|
129
131
|
bodyParams = {},
|
|
130
132
|
clientParams = {},
|
|
131
133
|
): Promise<any> {
|
|
132
134
|
if (
|
|
133
135
|
functionId === 'receiveShopCoupon' &&
|
|
134
136
|
((isH5 &&
|
|
135
137
|
(window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
|
|
136
138
|
isWxMinAndWxapp)
|
|
137
139
|
) {
|
|
138
140
|
clientParams = Object.assign(
|
|
139
141
|
{},
|
|
140
142
|
{
|
|
141
143
|
loginType: '1',
|
|
142
144
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
143
145
|
},
|
|
144
146
|
clientParams,
|
|
145
147
|
)
|
|
146
148
|
}
|
|
147
149
|
const apiClientParams = Object.assign(
|
|
148
150
|
{},
|
|
149
151
|
this.resInfo.apiClientParams,
|
|
150
152
|
clientParams,
|
|
151
153
|
)
|
|
152
154
|
typeof apiClientParams.appid === 'undefined' &&
|
|
153
155
|
(apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId))
|
|
154
156
|
const isColorVerify = this.verifyColorList.includes(functionId)
|
|
155
157
|
const getReqData = {
|
|
156
158
|
functionId: functionId,
|
|
157
159
|
body: JSON.stringify(bodyParams),
|
|
158
160
|
t: Date.now(),
|
|
159
161
|
...apiClientParams,
|
|
160
162
|
}
|
|
161
163
|
const requestParams = {
|
|
162
164
|
functionId: getReqData?.functionId,
|
|
163
165
|
body: getReqData?.body,
|
|
164
166
|
appid: getReqData?.appid,
|
|
165
167
|
client: getReqData?.client,
|
|
166
168
|
clientVersion: getReqData?.clientVersion,
|
|
167
169
|
area: getReqData?.area,
|
|
168
170
|
requestTimeStamp: getReqData?.t,
|
|
169
171
|
}
|
|
170
172
|
return http
|
|
171
173
|
.request({
|
|
172
174
|
url: this.api.apiFunc,
|
|
173
175
|
data: getReqData,
|
|
174
176
|
isColorVerify,
|
|
175
177
|
})
|
|
176
178
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
177
179
|
const { statusCode, data, status, msg } = res
|
|
178
180
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
179
181
|
ok: true,
|
|
180
182
|
}
|
|
181
183
|
if ((statusCode === 200 || status === '0') && data) {
|
|
182
184
|
changeRes = this.dealResponseFormatRes(data)
|
|
183
185
|
return changeRes
|
|
184
186
|
} else {
|
|
185
187
|
changeRes = {
|
|
186
188
|
...data,
|
|
187
189
|
statusCode,
|
|
188
190
|
status,
|
|
189
191
|
msg,
|
|
190
192
|
ok: false,
|
|
191
193
|
}
|
|
192
194
|
return changeRes
|
|
193
195
|
}
|
|
194
196
|
})
|
|
195
197
|
.catch((res) => {
|
|
196
198
|
const propertyNames = Object.getOwnPropertyNames(res)
|
|
197
199
|
const resObject = {}
|
|
198
200
|
propertyNames.forEach((propertyName) => {
|
|
199
201
|
resObject[propertyName] = res[propertyName]
|
|
200
202
|
})
|
|
201
203
|
sgmCustomReport({
|
|
202
204
|
code: getSgmCustomCode('interface_data_error'),
|
|
203
205
|
msg: {
|
|
204
206
|
subMsg: '接口请求错误',
|
|
205
207
|
functionId,
|
|
206
208
|
source: 'remote',
|
|
207
209
|
requestParams,
|
|
208
210
|
catchError: resObject,
|
|
209
211
|
errorType: 'catchError',
|
|
210
212
|
},
|
|
211
213
|
})
|
|
212
214
|
draInterfaceCustomReport({
|
|
213
215
|
...getReqData,
|
|
214
216
|
...resObject,
|
|
215
217
|
source: 'remote',
|
|
216
218
|
errorType: 'catchError',
|
|
217
219
|
subMsg: '接口请求错误',
|
|
218
220
|
})
|
|
219
221
|
return {
|
|
220
222
|
...resObject,
|
|
221
223
|
ok: false,
|
|
222
224
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
223
225
|
})
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
dealResponseFormatRes(data) {
|
|
227
229
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
228
230
|
ok: true,
|
|
229
231
|
}
|
|
230
232
|
const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
|
|
231
233
|
? Number(data.code)
|
|
232
234
|
: -1
|
|
233
235
|
const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
|
|
234
236
|
? Number(data.subCode)
|
|
235
237
|
: -1
|
|
236
238
|
if (
|
|
237
239
|
data.success === true ||
|
|
238
240
|
data.isSuccess ||
|
|
239
241
|
resCode === 0 ||
|
|
240
242
|
resCode === 200 ||
|
|
241
243
|
subCode === 0
|
|
242
244
|
) {
|
|
243
245
|
changeRes = {
|
|
244
246
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
245
247
|
? data.result
|
|
246
248
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
247
249
|
? data.data
|
|
248
250
|
: data,
|
|
249
251
|
code: data.code ?? 200,
|
|
250
252
|
ok: true,
|
|
251
253
|
source: data,
|
|
252
254
|
}
|
|
253
255
|
return changeRes
|
|
254
256
|
} else {
|
|
255
257
|
changeRes = {
|
|
256
258
|
...data,
|
|
257
259
|
ok: false,
|
|
258
260
|
}
|
|
259
261
|
return changeRes
|
|
260
262
|
}
|
|
261
263
|
}
|
|
262
264
|
|
|
263
265
|
async receiveCoupon(param = {}, clientParams) {
|
|
264
266
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
265
267
|
return await this.gatewayReq(
|
|
266
268
|
'receiveShopCoupon',
|
|
267
269
|
{
|
|
268
270
|
operation: '3',
|
|
269
271
|
...param,
|
|
270
272
|
},
|
|
271
273
|
{ ...loginType, ...clientParams },
|
|
272
274
|
)
|
|
273
275
|
}
|
|
274
276
|
|
|
275
277
|
getCustomerCenterDispatch(params = {}) {
|
|
276
278
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
277
279
|
clientVersion: '9.2.0',
|
|
278
280
|
client: 'H5',
|
|
279
281
|
uuid: 88888,
|
|
280
282
|
appid: 'shopmember_m_jd_com',
|
|
281
283
|
})
|
|
282
284
|
}
|
|
283
285
|
|
|
284
286
|
batchAddCart(skuIdsStr, num = 1, showToast = true) {
|
|
285
287
|
if (skuIdsStr) {
|
|
286
288
|
return this._addShopGoodCart(`${skuIdsStr}`, `${num}`)
|
|
287
289
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
288
290
|
if (res?.ok) {
|
|
289
291
|
if (showToast && !res?.isOpenApp)
|
|
290
292
|
showSuccessToast({
|
|
291
293
|
title: '加入购物车成功',
|
|
292
294
|
})
|
|
293
295
|
} else {
|
|
294
296
|
showToast &&
|
|
295
297
|
showFailToast({
|
|
296
298
|
title: res?.errMsg || '加入购物车失败,请稍后重试!',
|
|
297
299
|
})
|
|
298
300
|
}
|
|
299
301
|
return Promise.resolve(res)
|
|
300
302
|
})
|
|
301
303
|
.catch((e) => {
|
|
302
304
|
console.log('调用加购方法异常=======>', e)
|
|
303
305
|
return Promise.resolve({
|
|
304
306
|
ok: false,
|
|
305
307
|
msg: '加入购物车失败,请稍后重试!',
|
|
306
308
|
})
|
|
307
309
|
})
|
|
308
310
|
} else {
|
|
309
311
|
return Promise.resolve({
|
|
310
312
|
ok: false,
|
|
311
313
|
msg: '加入购物车失败,请稍后重试!',
|
|
312
314
|
})
|
|
313
315
|
}
|
|
314
316
|
}
|
|
315
317
|
|
|
316
318
|
_addShopGoodCart(skuIdsStr, addCardNum = '1') {
|
|
317
319
|
return new Promise((resolve) => {
|
|
318
320
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
319
321
|
if (productIdsArr.length > 0) {
|
|
320
322
|
if (isJdApp) {
|
|
321
323
|
console.log('==========>', '原生批量加车!')
|
|
322
324
|
const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`
|
|
323
325
|
if (!window[nativeAddCartCallBack]) {
|
|
324
326
|
window[nativeAddCartCallBack] = (res) => {
|
|
325
327
|
const getMessageJsonData =
|
|
326
328
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
327
329
|
console.info(
|
|
328
330
|
'获取批量加车原始数据',
|
|
329
331
|
res,
|
|
330
332
|
'====转换后的json数据为===',
|
|
331
333
|
getMessageJsonData,
|
|
332
334
|
)
|
|
333
335
|
try {
|
|
334
336
|
if (isAndroidDevice) {
|
|
335
337
|
getMessageJsonData?.status === '0'
|
|
336
338
|
? resolve({
|
|
337
339
|
ok: true,
|
|
338
340
|
msg: '已加入购物车!',
|
|
339
341
|
})
|
|
340
342
|
: resolve({
|
|
341
343
|
ok: false,
|
|
342
344
|
msg: '加购失败,请稍后重试',
|
|
343
345
|
})
|
|
344
346
|
} else if (isIosDevice) {
|
|
345
347
|
getMessageJsonData?.status === '0' &&
|
|
346
348
|
getMessageJsonData?.data?.code === 0
|
|
347
349
|
? resolve({
|
|
348
350
|
ok: true,
|
|
349
351
|
msg: '已加入购物车!',
|
|
350
352
|
})
|
|
351
353
|
: resolve({
|
|
352
354
|
ok: false,
|
|
353
355
|
msg: '批量加车失败,请稍后重试',
|
|
354
356
|
})
|
|
355
357
|
} else {
|
|
356
358
|
resolve({
|
|
357
359
|
ok: false,
|
|
358
360
|
msg: '加购失败,请稍后重试',
|
|
359
361
|
})
|
|
360
362
|
}
|
|
361
363
|
} catch (e) {
|
|
362
364
|
resolve({
|
|
363
365
|
ok: false,
|
|
364
366
|
msg: '加购失败,请稍后重试',
|
|
365
367
|
})
|
|
366
368
|
console.warn('批量加车转换数据异常', e)
|
|
367
369
|
}
|
|
368
370
|
window[nativeAddCartCallBack] = null
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
372
374
|
return isAndroidDevice
|
|
373
375
|
? {
|
|
374
376
|
sku: skuItem,
|
|
375
377
|
num: addCardNum,
|
|
376
378
|
}
|
|
377
379
|
: {
|
|
378
380
|
productCode: skuItem,
|
|
379
381
|
buyCount: addCardNum,
|
|
380
382
|
}
|
|
381
383
|
})
|
|
382
384
|
if (isAndroidDevice) {
|
|
383
385
|
const androidProductsStr = JSON.stringify(productsAddCartList)
|
|
384
386
|
callRouterAndroid({
|
|
385
387
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
|
|
386
388
|
routerParam: {
|
|
387
389
|
wareList: productsAddCartList,
|
|
388
390
|
},
|
|
389
391
|
callBackName: nativeAddCartCallBack,
|
|
390
392
|
})
|
|
391
393
|
} else if (isIosDevice) {
|
|
392
394
|
if (isLowAppVer) {
|
|
393
395
|
const lowVersionAppList = productIdsArr.map((skuItem) => {
|
|
394
396
|
return {
|
|
395
397
|
sku: skuItem,
|
|
396
398
|
num: addCardNum,
|
|
397
399
|
}
|
|
398
400
|
})
|
|
399
401
|
const lowVersionAppListStr = JSON.stringify(lowVersionAppList)
|
|
400
402
|
const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`
|
|
401
403
|
jump.side.jdJumpToWeb(url, {})
|
|
402
404
|
resolve({
|
|
403
405
|
ok: true,
|
|
404
406
|
isOpenApp: true,
|
|
405
407
|
msg: '加购完成, 加购结果请点击购物车确认',
|
|
406
408
|
})
|
|
407
409
|
} else {
|
|
408
410
|
callRouterIOS({
|
|
409
411
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
410
412
|
routerParam: {
|
|
411
413
|
sourceType: 'h5',
|
|
412
414
|
sourceValue: '店铺批量加购',
|
|
413
415
|
businessName: 'storeModel',
|
|
414
416
|
isNewMode: '1',
|
|
415
417
|
NotPassWebview: '1',
|
|
416
418
|
products: productsAddCartList,
|
|
417
419
|
},
|
|
418
420
|
callBackName: nativeAddCartCallBack,
|
|
419
421
|
})
|
|
420
422
|
}
|
|
421
423
|
}
|
|
422
424
|
} else if (isMin) {
|
|
423
425
|
console.log('==========>', '京购批量加车!')
|
|
424
426
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
425
427
|
return {
|
|
426
428
|
skuId: skuItem,
|
|
427
429
|
buyNum: addCardNum,
|
|
428
430
|
}
|
|
429
431
|
})
|
|
430
432
|
global.wxAppBizInstance
|
|
431
433
|
.addCart({ commArr: productsAddCartList })
|
|
432
434
|
.then((res) => {
|
|
433
435
|
console.log('dealCartSuccess: ', res)
|
|
434
436
|
resolve({
|
|
435
437
|
ok: true,
|
|
436
438
|
msg: '已加入购物车!',
|
|
437
439
|
data: res,
|
|
438
440
|
})
|
|
439
441
|
})
|
|
440
442
|
.catch((e) => {
|
|
441
443
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
442
444
|
resolve({
|
|
443
445
|
ok: false,
|
|
444
446
|
msg: '加购失败,请稍后重试',
|
|
445
447
|
})
|
|
446
448
|
})
|
|
447
449
|
} else {
|
|
448
450
|
console.log('==========>', 'M站批量加车!')
|
|
449
451
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) =>
|
|
450
452
|
resolve(res),
|
|
451
453
|
)
|
|
452
454
|
}
|
|
453
455
|
} else {
|
|
454
456
|
resolve({
|
|
455
457
|
ok: false,
|
|
456
458
|
msg: '加购sku不能为空',
|
|
457
459
|
})
|
|
458
460
|
}
|
|
459
461
|
})
|
|
460
462
|
}
|
|
461
463
|
|
|
462
464
|
productAddToCart(skuIdsStr, num) {
|
|
463
465
|
return new Promise((resolve) => {
|
|
464
466
|
if (window.AddcartToolObj) {
|
|
465
467
|
window.AddcartToolObj.addCart({
|
|
466
468
|
skuId: skuIdsStr,
|
|
467
469
|
num,
|
|
468
470
|
source: 'sjdpyw',
|
|
469
471
|
actId: '1',
|
|
470
472
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
471
473
|
sucFun(res) {
|
|
472
474
|
console.log(
|
|
473
475
|
'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
|
|
474
476
|
res,
|
|
475
477
|
)
|
|
476
478
|
if (res.errId === '0' && res.cartJson) {
|
|
477
479
|
resolve({
|
|
478
480
|
ok: true,
|
|
479
481
|
msg: '已加入购物车!',
|
|
480
482
|
...res,
|
|
481
483
|
})
|
|
482
484
|
} else {
|
|
483
485
|
if (res.errId === '13') {
|
|
484
486
|
global.doLogin()
|
|
485
487
|
} else {
|
|
486
488
|
resolve({
|
|
487
489
|
ok: false,
|
|
488
490
|
msg: '加购失败,请稍后重试',
|
|
489
491
|
...res,
|
|
490
492
|
})
|
|
491
493
|
}
|
|
492
494
|
}
|
|
493
495
|
},
|
|
494
496
|
failFun(err) {
|
|
495
497
|
console.log('fail', err)
|
|
496
498
|
resolve({
|
|
497
499
|
ok: false,
|
|
498
500
|
msg: '加购失败,请稍后重试',
|
|
499
501
|
...err,
|
|
500
502
|
})
|
|
501
503
|
},
|
|
502
504
|
})
|
|
503
505
|
} else {
|
|
504
506
|
resolve({
|
|
505
507
|
ok: false,
|
|
506
508
|
msg: '购物车方法检查异常',
|
|
507
509
|
})
|
|
508
510
|
}
|
|
509
511
|
})
|
|
510
512
|
}
|
|
511
513
|
bMallGetUserInfo = () => {
|
|
512
514
|
return getBMallUserInfo()
|
|
513
515
|
}
|
|
514
516
|
async bMallAddCart(params = {}) {
|
|
515
517
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
516
518
|
client: 'H5',
|
|
517
519
|
clientVersion: '5.5.0',
|
|
518
520
|
})
|
|
519
521
|
}
|
|
520
522
|
async bMallChangeCart(params = {}) {
|
|
521
523
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
522
524
|
client: 'H5',
|
|
523
525
|
clientVersion: '5.5.0',
|
|
524
526
|
})
|
|
525
527
|
}
|
|
526
528
|
async bMallRemoveCart(params = {}) {
|
|
527
529
|
return await this.gatewayReq(
|
|
528
530
|
'bmall_cartRemove',
|
|
529
531
|
params,
|
|
530
532
|
{
|
|
531
533
|
client: 'H5',
|
|
532
534
|
clientVersion: '5.5.0',
|
|
533
535
|
},
|
|
534
536
|
)
|
|
535
537
|
}
|
|
536
538
|
async bMallGetOmittedProduct(params = {}) {
|
|
537
539
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
538
540
|
client: 'H5',
|
|
539
541
|
clientVersion: '5.5.0',
|
|
540
542
|
})
|
|
541
543
|
}
|
|
542
544
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
543
545
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
544
546
|
return await this.bMallAddCart(params)
|
|
545
547
|
}
|
|
546
548
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
547
549
|
const params = await getParams({ bMallTag })
|
|
548
550
|
delete params.operations
|
|
549
551
|
return await this.bMallGetOmittedProduct(params)
|
|
550
552
|
}
|
|
551
553
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
552
554
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
553
555
|
return await this.bMallRemoveCart(params)
|
|
554
556
|
}
|
|
555
557
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
556
558
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
557
559
|
return await this.bMallChangeCart(params)
|
|
558
560
|
}
|
|
559
561
|
|
|
560
562
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
561
563
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
562
564
|
return window?.bMallCartData
|
|
563
565
|
}
|
|
564
566
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
565
567
|
let items
|
|
566
568
|
if (cartData.ok && cartData.result) {
|
|
567
569
|
items = cartData?.result?.items || {}
|
|
568
570
|
}
|
|
569
571
|
if (isH5) {
|
|
570
572
|
window.bMallCartData = items
|
|
571
573
|
}
|
|
572
574
|
return items
|
|
573
575
|
}
|
|
574
576
|
|
|
575
577
|
async bMallCartHandle(goodItem, num) {
|
|
576
578
|
try {
|
|
577
579
|
const {
|
|
578
580
|
skuUuid,
|
|
579
581
|
limitUpper,
|
|
580
582
|
limitLower,
|
|
581
583
|
} = goodItem
|
|
582
584
|
let cartNum = Number(num)
|
|
583
585
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
584
586
|
cartNum = limitLower
|
|
585
587
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
586
588
|
cartNum = limitUpper
|
|
587
589
|
}
|
|
588
590
|
if (skuUuid && cartNum > 0) {
|
|
589
591
|
return this.bMallChangeCartService({
|
|
590
592
|
...goodItem,
|
|
591
593
|
skuUuid,
|
|
592
594
|
num: cartNum,
|
|
593
595
|
})
|
|
594
596
|
} else if (!skuUuid && cartNum > 0) {
|
|
595
597
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
596
598
|
} else if (skuUuid && !cartNum) {
|
|
597
599
|
return this.bMallRemoveCartService({
|
|
598
600
|
...goodItem,
|
|
599
601
|
skuUuid,
|
|
600
602
|
num: cartNum,
|
|
601
603
|
})
|
|
602
604
|
} else {
|
|
603
605
|
console.error('参数不全')
|
|
604
606
|
return false
|
|
605
607
|
}
|
|
606
608
|
} catch (e) {
|
|
607
609
|
console.error(e)
|
|
608
610
|
}
|
|
609
611
|
}
|