@conecli/cone-render 0.8.20-beta.0 → 0.8.20-beta.2
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/README.md +7 -1
- 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/common/wxappApi.ts +1 -1
- 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/Exposure/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/const.ts +1 -0
- package/dist/components/base/ExposureSmart/index.h5.module.scss +30 -6
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.module.scss +20 -9
- 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/InViewRender/index.weapp.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.module.scss +8 -0
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -0
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
- package/dist/components/base/LazyLoadImage/const.ts +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +24 -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 +125 -69
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Base/index.module.scss +12 -0
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.module.scss +32 -0
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/base/Price/index.tsx +1 -1
- package/dist/components/base/ShopLeGaoTag/index.h5.module.scss +35 -0
- package/dist/components/base/ShopLeGaoTag/index.h5.tsx +1 -0
- package/dist/components/base/ShopLeGaoTag/index.module.scss +33 -0
- package/dist/components/base/ShopLeGaoTag/index.tsx +1 -0
- package/dist/components/base/Skeleton/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 -0
- 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.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 -0
- package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
- package/dist/jumpEventReport/web.pc.ts +1 -0
- package/dist/jumpEventReport/web.tjapp.ts +1 -0
- package/dist/jumpEventReport/web.tjm.ts +1 -0
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/language/en_US.json +231 -0
- package/dist/language/zh_CN.json +231 -0
- package/dist/language/zh_HK.json +231 -0
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -27
- 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 +294 -212
- package/dist/sass/base.scss +195 -137
- package/dist/service/bMallConst.ts +1 -1
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -0
- 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/service/requestServer.weapp.ts +1 -0
- 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/intersectionObserver.ts +1 -1
- package/dist/utils/jm-common.js +1 -1
- package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
- package/dist/utils/jumpExtMapUtil.ts +1 -0
- package/dist/utils/sColor.js +1 -0
- package/dist/utils/sgmCodeUtils.ts +1 -0
- package/dist/utils/taroRenderUtil.ts +1 -0
- package/dist/utils/utils.ts +1 -1
- package/dist/wxapp/api/helper.js +1 -0
- package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
- package/dist/wxapp/common/user_info.js +1 -1
- package/dist/wxapp/components/launch-app/index.js +1 -0
- package/dist/wxapp/components/launch-app/index.json +5 -0
- package/dist/wxapp/components/launch-app/index.wxml +0 -0
- package/dist/wxapp/components/launch-app/index.wxss +0 -0
- package/dist/wxapp/components/subscribe-guider/helper.js +1 -0
- package/dist/wxapp/components/subscribe-guider/index.js +1 -0
- package/dist/wxapp/components/subscribe-guider/index.json +5 -0
- package/dist/wxapp/components/subscribe-guider/index.wxml +0 -0
- package/dist/wxapp/components/subscribe-guider/index.wxss +0 -0
- package/package.json +145 -115
- package/dist/components/base/Skeleton/old.tsx +0 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
- package/dist/utils/memberFormatUtils.js +0 -1
- /package/dist/service/{bMallConst.wxapp.ts → bMallConst.weapp.ts} +0 -0
- /package/dist/service/http/{colorSign.wxapp.ts → colorSign.weapp.ts} +0 -0
|
@@ -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
|
isLanguageForEn,
|
|
332
332
|
isJdApp,
|
|
333
333
|
showSuccessToast,
|
|
334
334
|
showFailToast,
|
|
335
335
|
isH5,
|
|
336
336
|
isWxMinAndWxapp,
|
|
337
337
|
isMin,
|
|
338
338
|
isPc,
|
|
339
339
|
cookiesStr: '',
|
|
340
340
|
requestHeaderContentType: {
|
|
341
341
|
jsonHeader: {
|
|
342
342
|
'content-type': 'application/json;charset=utf-8',
|
|
343
343
|
},
|
|
344
344
|
formDataHeader: {
|
|
345
345
|
'content-type': 'application/x-www-form-urlencoded',
|
|
346
346
|
},
|
|
347
347
|
},
|
|
348
348
|
requestBaseParam: {
|
|
349
349
|
data: null,
|
|
350
350
|
header: {
|
|
351
351
|
'content-type': 'application/json;charset=utf-8',
|
|
352
352
|
},
|
|
353
353
|
},
|
|
354
354
|
timeOut: 7000,
|
|
355
355
|
apiClientParams: {
|
|
356
356
|
clientVersion: '11.0.0',
|
|
357
357
|
client: 'wh5',
|
|
358
358
|
area: '1_72_2799_0',
|
|
359
359
|
screen: `${Math.ceil(getSystemInfo?.screenWidth * devicePixelRatio)}*${Math.ceil(
|
|
360
360
|
getSystemInfo?.screenHeight * devicePixelRatio,
|
|
361
361
|
)}`,
|
|
362
362
|
uuid: UUID,
|
|
363
363
|
},
|
|
364
364
|
public addressFetchInfo: {
|
|
365
365
|
reqState: boolean;
|
|
366
366
|
promiseInstance: null | Promise<any>;
|
|
367
367
|
};
|
|
368
368
|
public getPromotionConfig: {
|
|
369
369
|
projectId: null | string | number;
|
|
370
370
|
pageId: null | string | number;
|
|
371
371
|
};
|
|
372
372
|
public resInfo: ServiceInterFace.HttpRequestInfo;
|
|
373
373
|
public api: ServiceInterFace.HttpApi;
|
|
374
374
|
public isPageDomain: boolean;
|
|
375
375
|
public verifyColorList: string[];
|
|
376
376
|
constructor(opt) {
|
|
377
377
|
this._init();
|
|
378
378
|
this.addressFetchInfo = {
|
|
379
379
|
reqState: false,
|
|
380
380
|
promiseInstance: null,
|
|
381
381
|
};
|
|
382
382
|
this.getPromotionConfig = {
|
|
383
383
|
projectId: null,
|
|
384
384
|
pageId: null,
|
|
385
385
|
};
|
|
386
386
|
this._userAreaUpdateListen();
|
|
387
387
|
this.resInfo = this._getResConfig(opt);
|
|
388
388
|
this.api = api;
|
|
389
389
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
|
|
390
390
|
this.verifyColorList = [
|
|
391
391
|
...MobileVerifyColorList,
|
|
392
392
|
...AppVerifyColorList,
|
|
393
393
|
...JshopxVerifyColorList,
|
|
394
394
|
...BMallVerifyColorList,
|
|
395
395
|
];
|
|
396
396
|
}
|
|
397
397
|
_init(): void {
|
|
398
398
|
httpInterceptors.forEach((item) => {
|
|
399
399
|
Taro.addInterceptor((chain) => item(chain));
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
402
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
403
403
|
return Object.assign({}, DefaultConfig, opt);
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
_userAreaUpdateListen() {
|
|
407
407
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
|
|
408
408
|
this.updateApiClientParamsResInfo(areaInfo);
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
411
|
updateApiClientParamsResInfo(opt = {}) {
|
|
412
412
|
const { area, realTimeArea, ...others } = opt;
|
|
413
413
|
this.resInfo.apiClientParams = {
|
|
414
414
|
...this.resInfo.apiClientParams,
|
|
415
415
|
...others,
|
|
416
416
|
};
|
|
417
417
|
area && area !== '' && (this.resInfo.apiClientParams.area = area);
|
|
418
418
|
realTimeArea &&
|
|
419
419
|
realTimeArea !== '' &&
|
|
420
420
|
(this.resInfo.apiClientParams.realTimeArea = realTimeArea);
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
checkFunctionIdToReturnAppId(functionId) {
|
|
424
424
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
425
425
|
return APPID.JSHOPX_COLOR_APPID;
|
|
426
426
|
} else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
|
|
427
427
|
return APPID.PAGES_COLOR_APPID;
|
|
428
428
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
429
429
|
return APPID.SHOP_MEMBER_COLOR_APPID;
|
|
430
430
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
431
431
|
return APPID.B2B_COLOR_APPID;
|
|
432
432
|
} else if (isPc) {
|
|
433
433
|
return APPID.MALL_COLOR_APPID;
|
|
434
434
|
} else {
|
|
435
435
|
return APPID.SHOP_COLOR_APPID;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
|
|
440
440
|
if (
|
|
441
441
|
functionId === 'receiveShopCoupon' &&
|
|
442
442
|
((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
|
|
443
443
|
isWxMinAndWxapp)
|
|
444
444
|
) {
|
|
445
445
|
clientParams = Object.assign(
|
|
446
446
|
{},
|
|
447
447
|
{
|
|
448
448
|
loginType: '1',
|
|
449
449
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
450
450
|
},
|
|
451
451
|
clientParams,
|
|
452
452
|
);
|
|
453
453
|
}
|
|
454
454
|
const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
|
|
455
455
|
typeof apiClientParams.appid === 'undefined' &&
|
|
456
456
|
(apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
|
|
457
457
|
const isColorVerify = this.verifyColorList.includes(functionId);
|
|
458
458
|
const getReqData = {
|
|
459
459
|
functionId: functionId,
|
|
460
460
|
body: JSON.stringify(bodyParams),
|
|
461
461
|
t: Date.now(),
|
|
462
462
|
...apiClientParams,
|
|
463
463
|
};
|
|
464
464
|
return http
|
|
465
465
|
.request({
|
|
466
466
|
url: this.api.apiFunc,
|
|
467
467
|
data: getReqData,
|
|
468
468
|
isColorVerify,
|
|
469
469
|
})
|
|
470
470
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
471
471
|
const { statusCode, data } = res;
|
|
472
472
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
473
473
|
ok: true,
|
|
474
474
|
};
|
|
475
475
|
if (statusCode === 200 && data) {
|
|
476
476
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
477
477
|
? Number(res.data.code)
|
|
478
478
|
: -1;
|
|
479
479
|
const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
|
|
480
480
|
? Number(res.data.subCode)
|
|
481
481
|
: -1;
|
|
482
482
|
if (
|
|
483
483
|
data.success === true ||
|
|
484
484
|
data.isSuccess ||
|
|
485
485
|
resCode === 0 ||
|
|
486
486
|
resCode === 200 ||
|
|
487
487
|
subCode === 0
|
|
488
488
|
) {
|
|
489
489
|
changeRes = {
|
|
490
490
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
491
491
|
? data.result
|
|
492
492
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
493
493
|
? data.data
|
|
494
494
|
: data,
|
|
495
495
|
code: data.code || 200,
|
|
496
496
|
ok: true,
|
|
497
497
|
source: data,
|
|
498
498
|
};
|
|
499
499
|
return changeRes;
|
|
500
500
|
} else {
|
|
501
501
|
changeRes = {
|
|
502
502
|
...data,
|
|
503
503
|
ok: false,
|
|
504
504
|
statusCode: res.statusCode,
|
|
505
505
|
};
|
|
506
506
|
return changeRes;
|
|
507
507
|
}
|
|
508
508
|
} else {
|
|
509
509
|
changeRes = {
|
|
510
510
|
...data,
|
|
511
511
|
ok: false,
|
|
512
512
|
statusCode: res.statusCode,
|
|
513
513
|
};
|
|
514
514
|
return changeRes;
|
|
515
515
|
}
|
|
516
516
|
})
|
|
517
517
|
.catch((res) => {
|
|
518
518
|
return {
|
|
519
519
|
...res,
|
|
520
520
|
ok: false,
|
|
521
521
|
} as ServiceInterFace.RequestResponseFormatRes;
|
|
522
522
|
});
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
async receiveCoupon(param = {}, clientParams) {
|
|
526
526
|
const loginType = isPc ? { loginType: 3 } : {};
|
|
527
527
|
return await this.gatewayReq(
|
|
528
528
|
'receiveShopCoupon',
|
|
529
529
|
{
|
|
530
530
|
operation: '3',
|
|
531
531
|
...param,
|
|
532
532
|
},
|
|
533
533
|
{ ...loginType, ...clientParams },
|
|
534
534
|
);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
getCustomerCenterDispatch(params = {}) {
|
|
538
538
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
539
539
|
clientVersion: '9.2.0',
|
|
540
540
|
client: 'H5',
|
|
541
541
|
uuid: 88888,
|
|
542
542
|
appid: 'shopmember_m_jd_com',
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
|
|
546
546
|
batchAddCart(...args) {
|
|
547
547
|
let skuIds, num, showToast, giftCard;
|
|
548
548
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
549
549
|
[skuIds, num = 1, showToast = true, giftCard = false] = args;
|
|
550
550
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
551
551
|
const params = args[0];
|
|
552
552
|
skuIds = params.skuIds;
|
|
553
553
|
num = params.num || 1;
|
|
554
554
|
showToast = params.showToast !== undefined ? params.showToast : true;
|
|
555
555
|
giftCard = params.giftCard !== undefined ? params.giftCard : false;
|
|
556
556
|
} else {
|
|
557
557
|
console.error('batchAddCart() Invalid arguments!', args);
|
|
558
558
|
const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
|
|
559
559
|
showFailToast({
|
|
560
560
|
title: msg,
|
|
561
561
|
});
|
|
562
562
|
return Promise.resolve({
|
|
563
563
|
ok: false,
|
|
564
564
|
msg,
|
|
565
565
|
});
|
|
566
566
|
}
|
|
567
567
|
const addToWhereText = giftCard ? '购物清单' : '购物车';
|
|
568
568
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
|
|
569
569
|
const failMsg = isLanguageForEn
|
|
570
570
|
? 'Please retry later'
|
|
571
571
|
: `加入${addToWhereText}失败,请稍后重试!`;
|
|
572
572
|
if (skuIds) {
|
|
573
573
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
574
574
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
575
575
|
if (res?.ok) {
|
|
576
576
|
if (showToast && !res?.isOpenApp)
|
|
577
577
|
showSuccessToast({
|
|
578
578
|
title: successMsg,
|
|
579
579
|
});
|
|
580
580
|
} else {
|
|
581
581
|
showToast &&
|
|
582
582
|
showFailToast({
|
|
583
583
|
title: res?.errMsg || failMsg,
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
586
|
return Promise.resolve(res);
|
|
587
587
|
})
|
|
588
588
|
.catch((e) => {
|
|
589
589
|
console.log('调用加购方法异常=======>', e);
|
|
590
590
|
return Promise.resolve({
|
|
591
591
|
ok: false,
|
|
592
592
|
msg: failMsg,
|
|
593
593
|
});
|
|
594
594
|
});
|
|
595
595
|
} else {
|
|
596
596
|
return Promise.resolve({
|
|
597
597
|
ok: false,
|
|
598
598
|
msg: failMsg,
|
|
599
599
|
});
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
602
|
|
|
603
603
|
async giftCardAddCart(skuList, num) {
|
|
604
604
|
const loginType = isPc ? { loginType: 3 } : {};
|
|
605
605
|
return this.gatewayReq(
|
|
606
606
|
'giftCardAddCart',
|
|
607
607
|
{
|
|
608
608
|
skuList,
|
|
609
609
|
num: Number(num),
|
|
610
610
|
},
|
|
611
611
|
{ ...loginType },
|
|
612
612
|
);
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
616
616
|
return new Promise((resolve) => {
|
|
617
617
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
|
|
618
618
|
if (productIdsArr.length > 0) {
|
|
619
619
|
if (giftCard) {
|
|
620
620
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
621
621
|
.then((res) => {
|
|
622
622
|
if (res?.code === '0' && res?.result?.value) {
|
|
623
623
|
resolve({
|
|
624
624
|
ok: true,
|
|
625
625
|
});
|
|
626
626
|
} else {
|
|
627
627
|
resolve({
|
|
628
628
|
ok: false,
|
|
629
629
|
msg: '加购失败,请稍后重试',
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
632
|
})
|
|
633
633
|
.catch((e) => {
|
|
634
634
|
console.error('礼品卡加车失败: ', e);
|
|
635
635
|
resolve({
|
|
636
636
|
ok: false,
|
|
637
637
|
msg: '加购失败,请稍后重试',
|
|
638
638
|
});
|
|
639
639
|
});
|
|
640
640
|
} else if (isJdApp) {
|
|
641
641
|
console.log('==========>', 'app原生批量加车!,小程序端暂不涉及');
|
|
642
642
|
} else if (isMin) {
|
|
643
643
|
console.log('==========>', '京购批量加车!');
|
|
644
644
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
645
645
|
return {
|
|
646
646
|
skuId: skuItem,
|
|
647
647
|
buyNum: addCardNum,
|
|
648
648
|
};
|
|
649
649
|
});
|
|
650
650
|
global.wxAppBizInstance
|
|
651
651
|
.addCart({ commArr: productsAddCartList })
|
|
652
652
|
.then((res) => {
|
|
653
653
|
console.log('dealCartSuccess: ', res);
|
|
654
654
|
resolve({
|
|
655
655
|
ok: true,
|
|
656
656
|
msg: '已加入购物车!',
|
|
657
657
|
data: res,
|
|
658
658
|
});
|
|
659
659
|
})
|
|
660
660
|
.catch((e) => {
|
|
661
661
|
console.log('京购小程序批量加车失败dealCartFail: ', e);
|
|
662
662
|
resolve({
|
|
663
663
|
ok: false,
|
|
664
664
|
msg: '加购失败,请稍后重试',
|
|
665
665
|
});
|
|
666
666
|
});
|
|
667
667
|
} else {
|
|
668
668
|
console.log('==========>', 'M站批量加车!');
|
|
669
669
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
|
|
670
670
|
}
|
|
671
671
|
} else {
|
|
672
672
|
resolve({
|
|
673
673
|
ok: false,
|
|
674
674
|
msg: '加购sku不能为空',
|
|
675
675
|
});
|
|
676
676
|
}
|
|
677
677
|
});
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
productAddToCart(skuIdsStr, num) {
|
|
681
681
|
return new Promise((resolve) => {
|
|
682
682
|
if (window.AddcartToolObj) {
|
|
683
683
|
window.AddcartToolObj.addCart({
|
|
684
684
|
skuId: skuIdsStr,
|
|
685
685
|
num,
|
|
686
686
|
source: 'sjdpyw',
|
|
687
687
|
actId: '1',
|
|
688
688
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
689
689
|
sucFun(res) {
|
|
690
690
|
console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
|
|
691
691
|
if (res.errId === '0' && res.cartJson) {
|
|
692
692
|
resolve({
|
|
693
693
|
ok: true,
|
|
694
694
|
msg: '已加入购物车!',
|
|
695
695
|
...res,
|
|
696
696
|
});
|
|
697
697
|
} else {
|
|
698
698
|
if (res.errId === '13') {
|
|
699
699
|
global.doLogin();
|
|
700
700
|
} else {
|
|
701
701
|
resolve({
|
|
702
702
|
ok: false,
|
|
703
703
|
msg: '加购失败,请稍后重试',
|
|
704
704
|
...res,
|
|
705
705
|
});
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
708
|
},
|
|
709
709
|
failFun(err) {
|
|
710
710
|
console.log('fail', err);
|
|
711
711
|
resolve({
|
|
712
712
|
ok: false,
|
|
713
713
|
msg: '加购失败,请稍后重试',
|
|
714
714
|
...err,
|
|
715
715
|
});
|
|
716
716
|
},
|
|
717
717
|
});
|
|
718
718
|
} else {
|
|
719
719
|
resolve({
|
|
720
720
|
ok: false,
|
|
721
721
|
msg: '购物车方法检查异常',
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
724
|
});
|
|
725
725
|
}
|
|
726
726
|
bMallGetUserInfo = () => {
|
|
727
727
|
return getBMallUserInfo();
|
|
728
728
|
};
|
|
729
729
|
async bMallAddCart(params = {}) {
|
|
730
730
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
731
731
|
client: 'H5',
|
|
732
732
|
clientVersion: '5.5.0',
|
|
733
733
|
});
|
|
734
734
|
}
|
|
735
735
|
async bMallChangeCart(params = {}) {
|
|
736
736
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
737
737
|
client: 'H5',
|
|
738
738
|
clientVersion: '5.5.0',
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
async bMallRemoveCart(params = {}) {
|
|
742
742
|
return await this.gatewayReq(
|
|
743
743
|
'bmall_cartRemove',
|
|
744
744
|
params,
|
|
745
745
|
{
|
|
746
746
|
client: 'H5',
|
|
747
747
|
clientVersion: '5.5.0',
|
|
748
748
|
},
|
|
749
749
|
);
|
|
750
750
|
}
|
|
751
751
|
async bMallGetOmittedProduct(params = {}) {
|
|
752
752
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
753
753
|
client: 'H5',
|
|
754
754
|
clientVersion: '5.5.0',
|
|
755
755
|
});
|
|
756
756
|
}
|
|
757
757
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
758
758
|
const params = await getParams({ ...data, skuId, bMallTag, num });
|
|
759
759
|
return await this.bMallAddCart(params);
|
|
760
760
|
}
|
|
761
761
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
762
762
|
const params = await getParams({ bMallTag });
|
|
763
763
|
delete params.operations;
|
|
764
764
|
return await this.bMallGetOmittedProduct(params);
|
|
765
765
|
}
|
|
766
766
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
767
767
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
768
768
|
return await this.bMallRemoveCart(params);
|
|
769
769
|
}
|
|
770
770
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
771
771
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
772
772
|
return await this.bMallChangeCart(params);
|
|
773
773
|
}
|
|
774
774
|
|
|
775
775
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
776
776
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
777
777
|
return window?.bMallCartData;
|
|
778
778
|
}
|
|
779
779
|
const cartData = await this.bMallGetSkuNumService(bMallTag);
|
|
780
780
|
let items;
|
|
781
781
|
if (cartData.ok && cartData.result) {
|
|
782
782
|
items = cartData?.result?.items || {};
|
|
783
783
|
}
|
|
784
784
|
if (isH5) {
|
|
785
785
|
window.bMallCartData = items;
|
|
786
786
|
}
|
|
787
787
|
return items;
|
|
788
788
|
}
|
|
789
789
|
|
|
790
790
|
async bMallCartHandle(goodItem, num) {
|
|
791
791
|
try {
|
|
792
792
|
const {
|
|
793
793
|
skuUuid,
|
|
794
794
|
limitUpper,
|
|
795
795
|
limitLower,
|
|
796
796
|
} = goodItem;
|
|
797
797
|
let cartNum = Number(num);
|
|
798
798
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
799
799
|
cartNum = limitLower;
|
|
800
800
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
801
801
|
cartNum = limitUpper;
|
|
802
802
|
}
|
|
803
803
|
if (skuUuid && cartNum > 0) {
|
|
804
804
|
return this.bMallChangeCartService({
|
|
805
805
|
...goodItem,
|
|
806
806
|
skuUuid,
|
|
807
807
|
num: cartNum,
|
|
808
808
|
});
|
|
809
809
|
} else if (!skuUuid && cartNum > 0) {
|
|
810
810
|
return this.bMallAddCartService({ ...goodItem, num: cartNum });
|
|
811
811
|
} else if (skuUuid && !cartNum) {
|
|
812
812
|
return this.bMallRemoveCartService({
|
|
813
813
|
...goodItem,
|
|
814
814
|
skuUuid,
|
|
815
815
|
num: cartNum,
|
|
816
816
|
});
|
|
817
817
|
} else {
|
|
818
818
|
console.error('参数不全');
|
|
819
819
|
return false;
|
|
820
820
|
}
|
|
821
821
|
} catch (e) {
|
|
822
822
|
console.error(e);
|
|
823
823
|
}
|
|
824
824
|
}
|