@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
|
@@ -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
|
return http
|
|
162
164
|
.request({
|
|
163
165
|
url: this.api.apiFunc,
|
|
164
166
|
data: getReqData,
|
|
165
167
|
isColorVerify,
|
|
166
168
|
})
|
|
167
169
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
168
170
|
const { statusCode, data, status, msg } = res
|
|
169
171
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
170
172
|
ok: true,
|
|
171
173
|
}
|
|
172
174
|
if ((statusCode === 200 || status === '0') && data) {
|
|
173
175
|
changeRes = this.dealResponseFormatRes(data)
|
|
174
176
|
return changeRes
|
|
175
177
|
} else {
|
|
176
178
|
changeRes = {
|
|
177
179
|
...data,
|
|
178
180
|
statusCode,
|
|
179
181
|
status,
|
|
180
182
|
msg,
|
|
181
183
|
ok: false,
|
|
182
184
|
}
|
|
183
185
|
return changeRes
|
|
184
186
|
}
|
|
185
187
|
})
|
|
186
188
|
.catch((res) => {
|
|
187
189
|
const propertyNames = Object.getOwnPropertyNames(res)
|
|
188
190
|
const resObject = {}
|
|
189
191
|
propertyNames.forEach((propertyName) => {
|
|
190
192
|
resObject[propertyName] = res[propertyName]
|
|
191
193
|
})
|
|
192
194
|
draInterfaceCustomReport({
|
|
193
195
|
subMsg: '接口请求错误',
|
|
194
196
|
url: this.api.apiFunc,
|
|
195
197
|
source: 'remote',
|
|
196
198
|
requestType: res?.requestType,
|
|
197
199
|
errorType: 'catchError',
|
|
198
200
|
body: getReqData?.body,
|
|
199
201
|
appid: getReqData?.appid,
|
|
200
202
|
t: getReqData?.t,
|
|
201
203
|
client: getReqData?.client,
|
|
202
204
|
clientVersion: getReqData?.clientVersion,
|
|
203
205
|
...resObject,
|
|
204
206
|
});
|
|
205
207
|
return {
|
|
206
208
|
...resObject,
|
|
207
209
|
ok: false,
|
|
208
210
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
209
211
|
})
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
dealResponseFormatRes(data) {
|
|
213
215
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
214
216
|
ok: true,
|
|
215
217
|
}
|
|
216
218
|
const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
|
|
217
219
|
? Number(data.code)
|
|
218
220
|
: -1
|
|
219
221
|
const subCode = Object.prototype.hasOwnProperty.call(data, 'subCode')
|
|
220
222
|
? Number(data.subCode)
|
|
221
223
|
: -1
|
|
222
224
|
if (
|
|
223
225
|
data.success === true ||
|
|
224
226
|
data.isSuccess ||
|
|
225
227
|
resCode === 0 ||
|
|
226
228
|
resCode === 200 ||
|
|
227
229
|
subCode === 0
|
|
228
230
|
) {
|
|
229
231
|
changeRes = {
|
|
230
232
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
231
233
|
? data.result
|
|
232
234
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
233
235
|
? data.data
|
|
234
236
|
: data,
|
|
235
237
|
code: data.code ?? 200,
|
|
236
238
|
ok: true,
|
|
237
239
|
source: data,
|
|
238
240
|
}
|
|
239
241
|
return changeRes
|
|
240
242
|
} else {
|
|
241
243
|
changeRes = {
|
|
242
244
|
...data,
|
|
243
245
|
ok: false,
|
|
244
246
|
}
|
|
245
247
|
return changeRes
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
async receiveCoupon(param = {}, clientParams) {
|
|
250
252
|
const loginType = isPc ? { loginType: 3 } : {}
|
|
251
253
|
return await this.gatewayReq(
|
|
252
254
|
'receiveShopCoupon',
|
|
253
255
|
{
|
|
254
256
|
operation: '3',
|
|
255
257
|
...param,
|
|
256
258
|
},
|
|
257
259
|
{ ...loginType, ...clientParams },
|
|
258
260
|
)
|
|
259
261
|
}
|
|
260
262
|
|
|
261
263
|
getCustomerCenterDispatch(params = {}) {
|
|
262
264
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
263
265
|
clientVersion: '9.2.0',
|
|
264
266
|
client: 'H5',
|
|
265
267
|
uuid: 88888,
|
|
266
268
|
appid: 'shopmember_m_jd_com',
|
|
267
269
|
})
|
|
268
270
|
}
|
|
269
271
|
|
|
270
272
|
batchAddCart(skuIdsStr, num = 1, showToast = true) {
|
|
271
273
|
if (skuIdsStr) {
|
|
272
274
|
return this._addShopGoodCart(`${skuIdsStr}`, `${num}`)
|
|
273
275
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
274
276
|
if (res?.ok) {
|
|
275
277
|
if (showToast && !res?.isOpenApp)
|
|
276
278
|
showSuccessToast({
|
|
277
279
|
title: '加入购物车成功',
|
|
278
280
|
})
|
|
279
281
|
} else {
|
|
280
282
|
showToast &&
|
|
281
283
|
showFailToast({
|
|
282
284
|
title: res?.errMsg || '加入购物车失败,请稍后重试!',
|
|
283
285
|
})
|
|
284
286
|
}
|
|
285
287
|
return Promise.resolve(res)
|
|
286
288
|
})
|
|
287
289
|
.catch((e) => {
|
|
288
290
|
console.log('调用加购方法异常=======>', e)
|
|
289
291
|
return Promise.resolve({
|
|
290
292
|
ok: false,
|
|
291
293
|
msg: '加入购物车失败,请稍后重试!',
|
|
292
294
|
})
|
|
293
295
|
})
|
|
294
296
|
} else {
|
|
295
297
|
return Promise.resolve({
|
|
296
298
|
ok: false,
|
|
297
299
|
msg: '加入购物车失败,请稍后重试!',
|
|
298
300
|
})
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
303
|
|
|
302
304
|
_addShopGoodCart(skuIdsStr, addCardNum = '1') {
|
|
303
305
|
return new Promise((resolve) => {
|
|
304
306
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : []
|
|
305
307
|
if (productIdsArr.length > 0) {
|
|
306
308
|
if (isJdApp) {
|
|
307
309
|
console.log('==========>', '原生批量加车!')
|
|
308
310
|
const nativeAddCartCallBack = `nativeBatchAddCart${Date.now()}`
|
|
309
311
|
if (!window[nativeAddCartCallBack]) {
|
|
310
312
|
window[nativeAddCartCallBack] = (res) => {
|
|
311
313
|
const getMessageJsonData =
|
|
312
314
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
313
315
|
console.info(
|
|
314
316
|
'获取批量加车原始数据',
|
|
315
317
|
res,
|
|
316
318
|
'====转换后的json数据为===',
|
|
317
319
|
getMessageJsonData,
|
|
318
320
|
)
|
|
319
321
|
try {
|
|
320
322
|
if (isAndroidDevice) {
|
|
321
323
|
getMessageJsonData?.status === '0'
|
|
322
324
|
? resolve({
|
|
323
325
|
ok: true,
|
|
324
326
|
msg: '已加入购物车!',
|
|
325
327
|
})
|
|
326
328
|
: resolve({
|
|
327
329
|
ok: false,
|
|
328
330
|
msg: '加购失败,请稍后重试',
|
|
329
331
|
})
|
|
330
332
|
} else if (isIosDevice) {
|
|
331
333
|
getMessageJsonData?.status === '0' &&
|
|
332
334
|
getMessageJsonData?.data?.code === 0
|
|
333
335
|
? resolve({
|
|
334
336
|
ok: true,
|
|
335
337
|
msg: '已加入购物车!',
|
|
336
338
|
})
|
|
337
339
|
: resolve({
|
|
338
340
|
ok: false,
|
|
339
341
|
msg: '批量加车失败,请稍后重试',
|
|
340
342
|
})
|
|
341
343
|
} else {
|
|
342
344
|
resolve({
|
|
343
345
|
ok: false,
|
|
344
346
|
msg: '加购失败,请稍后重试',
|
|
345
347
|
})
|
|
346
348
|
}
|
|
347
349
|
} catch (e) {
|
|
348
350
|
resolve({
|
|
349
351
|
ok: false,
|
|
350
352
|
msg: '加购失败,请稍后重试',
|
|
351
353
|
})
|
|
352
354
|
console.warn('批量加车转换数据异常', e)
|
|
353
355
|
}
|
|
354
356
|
window[nativeAddCartCallBack] = null
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
359
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
358
360
|
return isAndroidDevice
|
|
359
361
|
? {
|
|
360
362
|
sku: skuItem,
|
|
361
363
|
num: addCardNum,
|
|
362
364
|
}
|
|
363
365
|
: {
|
|
364
366
|
productCode: skuItem,
|
|
365
367
|
buyCount: addCardNum,
|
|
366
368
|
}
|
|
367
369
|
})
|
|
368
370
|
if (isAndroidDevice) {
|
|
369
371
|
const androidProductsStr = JSON.stringify(productsAddCartList)
|
|
370
372
|
callRouterAndroid({
|
|
371
373
|
routerURL: `router://JDCartModule/addCartUniformWithUrl?wareList=${androidProductsStr}&businessName=storeModel`,
|
|
372
374
|
routerParam: {
|
|
373
375
|
wareList: productsAddCartList,
|
|
374
376
|
},
|
|
375
377
|
callBackName: nativeAddCartCallBack,
|
|
376
378
|
})
|
|
377
379
|
} else if (isIosDevice) {
|
|
378
380
|
if (isLowAppVer) {
|
|
379
381
|
const lowVersionAppList = productIdsArr.map((skuItem) => {
|
|
380
382
|
return {
|
|
381
383
|
sku: skuItem,
|
|
382
384
|
num: addCardNum,
|
|
383
385
|
}
|
|
384
386
|
})
|
|
385
387
|
const lowVersionAppListStr = JSON.stringify(lowVersionAppList)
|
|
386
388
|
const url = `openApp.jdMobile://virtual?params={"category":"jump","des":"updateCartNum","sourceValue":"店铺批量加购","sourceType":"h5","businessName":"storeModel","wareList":${lowVersionAppListStr}}`
|
|
387
389
|
jump.side.jdJumpToWeb(url, {})
|
|
388
390
|
resolve({
|
|
389
391
|
ok: true,
|
|
390
392
|
isOpenApp: true,
|
|
391
393
|
msg: '加购完成, 加购结果请点击购物车确认',
|
|
392
394
|
})
|
|
393
395
|
} else {
|
|
394
396
|
callRouterIOS({
|
|
395
397
|
routerURL: 'router://JDCartModule/batchAddService',
|
|
396
398
|
routerParam: {
|
|
397
399
|
sourceType: 'h5',
|
|
398
400
|
sourceValue: '店铺批量加购',
|
|
399
401
|
businessName: 'storeModel',
|
|
400
402
|
isNewMode: '1',
|
|
401
403
|
NotPassWebview: '1',
|
|
402
404
|
products: productsAddCartList,
|
|
403
405
|
},
|
|
404
406
|
callBackName: nativeAddCartCallBack,
|
|
405
407
|
})
|
|
406
408
|
}
|
|
407
409
|
}
|
|
408
410
|
} else if (isMin) {
|
|
409
411
|
console.log('==========>', '京购批量加车!')
|
|
410
412
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
411
413
|
return {
|
|
412
414
|
skuId: skuItem,
|
|
413
415
|
buyNum: addCardNum,
|
|
414
416
|
}
|
|
415
417
|
})
|
|
416
418
|
global.wxAppBizInstance
|
|
417
419
|
.addCart({ commArr: productsAddCartList })
|
|
418
420
|
.then((res) => {
|
|
419
421
|
console.log('dealCartSuccess: ', res)
|
|
420
422
|
resolve({
|
|
421
423
|
ok: true,
|
|
422
424
|
msg: '已加入购物车!',
|
|
423
425
|
data: res,
|
|
424
426
|
})
|
|
425
427
|
})
|
|
426
428
|
.catch((e) => {
|
|
427
429
|
console.log('京购小程序批量加车失败dealCartFail: ', e)
|
|
428
430
|
resolve({
|
|
429
431
|
ok: false,
|
|
430
432
|
msg: '加购失败,请稍后重试',
|
|
431
433
|
})
|
|
432
434
|
})
|
|
433
435
|
} else {
|
|
434
436
|
console.log('==========>', 'M站批量加车!')
|
|
435
437
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) =>
|
|
436
438
|
resolve(res),
|
|
437
439
|
)
|
|
438
440
|
}
|
|
439
441
|
} else {
|
|
440
442
|
resolve({
|
|
441
443
|
ok: false,
|
|
442
444
|
msg: '加购sku不能为空',
|
|
443
445
|
})
|
|
444
446
|
}
|
|
445
447
|
})
|
|
446
448
|
}
|
|
447
449
|
|
|
448
450
|
productAddToCart(skuIdsStr, num) {
|
|
449
451
|
return new Promise((resolve) => {
|
|
450
452
|
if (window.AddcartToolObj) {
|
|
451
453
|
window.AddcartToolObj.addCart({
|
|
452
454
|
skuId: skuIdsStr,
|
|
453
455
|
num,
|
|
454
456
|
source: 'sjdpyw',
|
|
455
457
|
actId: '1',
|
|
456
458
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
457
459
|
sucFun(res) {
|
|
458
460
|
console.log(
|
|
459
461
|
'ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0',
|
|
460
462
|
res,
|
|
461
463
|
)
|
|
462
464
|
if (res.errId === '0' && res.cartJson) {
|
|
463
465
|
resolve({
|
|
464
466
|
ok: true,
|
|
465
467
|
msg: '已加入购物车!',
|
|
466
468
|
...res,
|
|
467
469
|
})
|
|
468
470
|
} else {
|
|
469
471
|
if (res.errId === '13') {
|
|
470
472
|
global.doLogin()
|
|
471
473
|
} else {
|
|
472
474
|
resolve({
|
|
473
475
|
ok: false,
|
|
474
476
|
msg: '加购失败,请稍后重试',
|
|
475
477
|
...res,
|
|
476
478
|
})
|
|
477
479
|
}
|
|
478
480
|
}
|
|
479
481
|
},
|
|
480
482
|
failFun(err) {
|
|
481
483
|
console.log('fail', err)
|
|
482
484
|
resolve({
|
|
483
485
|
ok: false,
|
|
484
486
|
msg: '加购失败,请稍后重试',
|
|
485
487
|
...err,
|
|
486
488
|
})
|
|
487
489
|
},
|
|
488
490
|
})
|
|
489
491
|
} else {
|
|
490
492
|
resolve({
|
|
491
493
|
ok: false,
|
|
492
494
|
msg: '购物车方法检查异常',
|
|
493
495
|
})
|
|
494
496
|
}
|
|
495
497
|
})
|
|
496
498
|
}
|
|
497
499
|
bMallGetUserInfo = () => {
|
|
498
500
|
return getBMallUserInfo()
|
|
499
501
|
}
|
|
500
502
|
async bMallAddCart(params = {}) {
|
|
501
503
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
502
504
|
client: 'H5',
|
|
503
505
|
clientVersion: '5.5.0',
|
|
504
506
|
})
|
|
505
507
|
}
|
|
506
508
|
async bMallChangeCart(params = {}) {
|
|
507
509
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
508
510
|
client: 'H5',
|
|
509
511
|
clientVersion: '5.5.0',
|
|
510
512
|
})
|
|
511
513
|
}
|
|
512
514
|
async bMallRemoveCart(params = {}) {
|
|
513
515
|
return await this.gatewayReq(
|
|
514
516
|
'bmall_cartRemove',
|
|
515
517
|
params,
|
|
516
518
|
{
|
|
517
519
|
client: 'H5',
|
|
518
520
|
clientVersion: '5.5.0',
|
|
519
521
|
},
|
|
520
522
|
)
|
|
521
523
|
}
|
|
522
524
|
async bMallGetOmittedProduct(params = {}) {
|
|
523
525
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
524
526
|
client: 'H5',
|
|
525
527
|
clientVersion: '5.5.0',
|
|
526
528
|
})
|
|
527
529
|
}
|
|
528
530
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
529
531
|
const params = await getParams({ ...data, skuId, bMallTag, num })
|
|
530
532
|
return await this.bMallAddCart(params)
|
|
531
533
|
}
|
|
532
534
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
533
535
|
const params = await getParams({ bMallTag })
|
|
534
536
|
delete params.operations
|
|
535
537
|
return await this.bMallGetOmittedProduct(params)
|
|
536
538
|
}
|
|
537
539
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
538
540
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
539
541
|
return await this.bMallRemoveCart(params)
|
|
540
542
|
}
|
|
541
543
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
542
544
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid })
|
|
543
545
|
return await this.bMallChangeCart(params)
|
|
544
546
|
}
|
|
545
547
|
|
|
546
548
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
547
549
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
548
550
|
return window?.bMallCartData
|
|
549
551
|
}
|
|
550
552
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
551
553
|
let items
|
|
552
554
|
if (cartData.ok && cartData.result) {
|
|
553
555
|
items = cartData?.result?.items || {}
|
|
554
556
|
}
|
|
555
557
|
if (isH5) {
|
|
556
558
|
window.bMallCartData = items
|
|
557
559
|
}
|
|
558
560
|
return items
|
|
559
561
|
}
|
|
560
562
|
|
|
561
563
|
async bMallCartHandle(goodItem, num) {
|
|
562
564
|
try {
|
|
563
565
|
const {
|
|
564
566
|
skuUuid,
|
|
565
567
|
limitUpper,
|
|
566
568
|
limitLower,
|
|
567
569
|
} = goodItem
|
|
568
570
|
let cartNum = Number(num)
|
|
569
571
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
570
572
|
cartNum = limitLower
|
|
571
573
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
572
574
|
cartNum = limitUpper
|
|
573
575
|
}
|
|
574
576
|
if (skuUuid && cartNum > 0) {
|
|
575
577
|
return this.bMallChangeCartService({
|
|
576
578
|
...goodItem,
|
|
577
579
|
skuUuid,
|
|
578
580
|
num: cartNum,
|
|
579
581
|
})
|
|
580
582
|
} else if (!skuUuid && cartNum > 0) {
|
|
581
583
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
582
584
|
} else if (skuUuid && !cartNum) {
|
|
583
585
|
return this.bMallRemoveCartService({
|
|
584
586
|
...goodItem,
|
|
585
587
|
skuUuid,
|
|
586
588
|
num: cartNum,
|
|
587
589
|
})
|
|
588
590
|
} else {
|
|
589
591
|
console.error('参数不全')
|
|
590
592
|
return false
|
|
591
593
|
}
|
|
592
594
|
} catch (e) {
|
|
593
595
|
console.error(e)
|
|
594
596
|
}
|
|
595
597
|
}
|