@conecli/cone-render 0.8.19 → 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/isvStorage/index.h5.ts +1 -0
- package/dist/common/isvStorage/index.ts +1 -0
- 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/const.ts +1 -0
- package/dist/common/token/index.h5.ts +1 -0
- package/dist/common/token/index.ts +1 -0
- package/dist/common/token/token.jd.ts +1 -0
- package/dist/common/token/token.ts +1 -0
- package/dist/common/token/token.wxapp.ts +1 -0
- 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/const.ts +1 -0
- package/dist/components/base/CustomVideo/index.module.scss +40 -64
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +22 -2
- 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 +128 -69
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/{const.ts → Base/const.ts} +0 -0
- package/dist/components/base/Price/Base/index.module.scss +148 -0
- package/dist/components/base/Price/Base/index.tsx +1 -0
- package/dist/components/base/Price/Double/index.module.scss +190 -0
- package/dist/components/base/Price/Double/index.tsx +1 -0
- 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 -0
- 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 -0
- 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/business.ts +1 -0
- package/dist/open/api/jump/index.ts +1 -0
- package/dist/open/api/jump/minPath.ts +1 -0
- package/dist/open/api/jump/side.ts +1 -0
- package/dist/open/api/jump/webUrl.ts +1 -0
- package/dist/open/api/jump copy.ts +1 -0
- package/dist/open/api/moduleUtil.ts +1 -1
- package/dist/open/api/request.ts +1 -0
- package/dist/open/api/shopMember.ts +1 -0
- package/dist/open/api/track.ts +1 -1
- package/dist/open/api/userToken.ts +1 -0
- 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 -0
- package/dist/service/bMallConst.weapp.ts +1 -0
- package/dist/service/fetchGateway.ts +1 -0
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/fetchJsonp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -0
- package/dist/service/http/colorSign.weapp.ts +1 -0
- package/dist/service/http/const.ts +1 -0
- package/dist/service/http/h5Http.ts +1 -0
- package/dist/service/http/http.ts +1 -0
- package/dist/service/http/httpInterceptors.jd.ts +1 -0
- package/dist/service/http/httpInterceptors.ts +1 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/http/index.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- package/dist/service/requestServer.ts +1 -0
- 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/priceUtils.js +1 -0
- package/dist/utils/ready.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 -114
- package/dist/components/base/Price/index.module.scss +0 -136
- package/dist/components/base/Skeleton/old.tsx +0 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
- package/dist/open/api/jump.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
|
isLanguageForEn,
|
|
11
13
|
isJdApp,
|
|
12
14
|
showSuccessToast,
|
|
13
15
|
showFailToast,
|
|
14
16
|
isH5,
|
|
15
17
|
isWxMinAndWxapp,
|
|
16
18
|
isMin,
|
|
17
19
|
isPc,
|
|
18
20
|
cookiesStr: '',
|
|
19
21
|
requestHeaderContentType: {
|
|
20
22
|
jsonHeader: {
|
|
21
23
|
'content-type': 'application/json;charset=utf-8',
|
|
22
24
|
},
|
|
23
25
|
formDataHeader: {
|
|
24
26
|
'content-type': 'application/x-www-form-urlencoded',
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
requestBaseParam: {
|
|
28
30
|
data: null,
|
|
29
31
|
header: {
|
|
30
32
|
'content-type': 'application/json;charset=utf-8',
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
timeOut: 7000,
|
|
34
36
|
apiClientParams: {
|
|
35
37
|
clientVersion: '11.0.0',
|
|
36
38
|
client: 'wh5',
|
|
37
39
|
area: '1_72_2799_0',
|
|
38
40
|
screen: `${Math.ceil(getSystemInfo?.screenWidth * devicePixelRatio)}*${Math.ceil(
|
|
39
41
|
getSystemInfo?.screenHeight * devicePixelRatio,
|
|
40
42
|
)}`,
|
|
41
43
|
uuid: UUID,
|
|
42
44
|
},
|
|
43
45
|
public addressFetchInfo: {
|
|
44
46
|
reqState: boolean;
|
|
45
47
|
promiseInstance: null | Promise<any>;
|
|
46
48
|
};
|
|
47
49
|
public getPromotionConfig: {
|
|
48
50
|
projectId: null | string | number;
|
|
49
51
|
pageId: null | string | number;
|
|
50
52
|
};
|
|
51
53
|
public resInfo: ServiceInterFace.HttpRequestInfo;
|
|
52
54
|
public api: ServiceInterFace.HttpApi;
|
|
53
55
|
public isPageDomain: boolean;
|
|
54
56
|
public verifyColorList: string[];
|
|
55
57
|
constructor(opt) {
|
|
56
58
|
this._init();
|
|
57
59
|
this.addressFetchInfo = {
|
|
58
60
|
reqState: false,
|
|
59
61
|
promiseInstance: null,
|
|
60
62
|
};
|
|
61
63
|
this.getPromotionConfig = {
|
|
62
64
|
projectId: null,
|
|
63
65
|
pageId: null,
|
|
64
66
|
};
|
|
65
67
|
this._userAreaUpdateListen();
|
|
66
68
|
this.resInfo = this._getResConfig(opt);
|
|
67
69
|
this.api = api;
|
|
68
70
|
this.isPageDomain = isH5 ? window?.location?.hostname === PAGES_DOMAIN : false;
|
|
69
71
|
this.verifyColorList = [
|
|
70
72
|
...MobileVerifyColorList,
|
|
71
73
|
...AppVerifyColorList,
|
|
72
74
|
...JshopxVerifyColorList,
|
|
73
75
|
...BMallVerifyColorList,
|
|
74
76
|
];
|
|
75
77
|
}
|
|
76
78
|
_init(): void {
|
|
77
79
|
httpInterceptors.forEach((item) => {
|
|
78
80
|
Taro.addInterceptor((chain) => item(chain));
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
83
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
82
84
|
return Object.assign({}, DefaultConfig, opt);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
_userAreaUpdateListen() {
|
|
86
88
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (areaInfo) => {
|
|
87
89
|
this.updateApiClientParamsResInfo(areaInfo);
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
92
|
updateApiClientParamsResInfo(opt = {}) {
|
|
91
93
|
const { area, realTimeArea, ...others } = opt;
|
|
92
94
|
this.resInfo.apiClientParams = {
|
|
93
95
|
...this.resInfo.apiClientParams,
|
|
94
96
|
...others,
|
|
95
97
|
};
|
|
96
98
|
area && area !== '' && (this.resInfo.apiClientParams.area = area);
|
|
97
99
|
realTimeArea &&
|
|
98
100
|
realTimeArea !== '' &&
|
|
99
101
|
(this.resInfo.apiClientParams.realTimeArea = realTimeArea);
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
checkFunctionIdToReturnAppId(functionId) {
|
|
103
105
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
104
106
|
return APPID.JSHOPX_COLOR_APPID;
|
|
105
107
|
} else if (this.isPageDomain && PagesColorFunctionIdList.includes(functionId)) {
|
|
106
108
|
return APPID.PAGES_COLOR_APPID;
|
|
107
109
|
} else if (shopMemberColorFunctionIdList.includes(functionId)) {
|
|
108
110
|
return APPID.SHOP_MEMBER_COLOR_APPID;
|
|
109
111
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
110
112
|
return APPID.B2B_COLOR_APPID;
|
|
111
113
|
} else if (isPc) {
|
|
112
114
|
return APPID.MALL_COLOR_APPID;
|
|
113
115
|
} else {
|
|
114
116
|
return APPID.SHOP_COLOR_APPID;
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
gatewayReq(functionId: string, bodyParams = {}, clientParams = {}): Promise<any> {
|
|
119
121
|
if (
|
|
120
122
|
functionId === 'receiveShopCoupon' &&
|
|
121
123
|
((isH5 && (window?.isJingGouMiniViewState || window?.isJingxiMiniViewState)) ||
|
|
122
124
|
isWxMinAndWxapp)
|
|
123
125
|
) {
|
|
124
126
|
clientParams = Object.assign(
|
|
125
127
|
{},
|
|
126
128
|
{
|
|
127
129
|
loginType: '1',
|
|
128
130
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
129
131
|
},
|
|
130
132
|
clientParams,
|
|
131
133
|
);
|
|
132
134
|
}
|
|
133
135
|
const apiClientParams = Object.assign({}, this.resInfo.apiClientParams, clientParams);
|
|
134
136
|
typeof apiClientParams.appid === 'undefined' &&
|
|
135
137
|
(apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId));
|
|
136
138
|
const isColorVerify = this.verifyColorList.includes(functionId);
|
|
137
139
|
const getReqData = {
|
|
138
140
|
functionId: functionId,
|
|
139
141
|
body: JSON.stringify(bodyParams),
|
|
140
142
|
t: Date.now(),
|
|
141
143
|
...apiClientParams,
|
|
142
144
|
};
|
|
143
145
|
return http
|
|
144
146
|
.request({
|
|
145
147
|
url: this.api.apiFunc,
|
|
146
148
|
data: getReqData,
|
|
147
149
|
isColorVerify,
|
|
148
150
|
})
|
|
149
151
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
150
152
|
const { statusCode, data } = res;
|
|
151
153
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
152
154
|
ok: true,
|
|
153
155
|
};
|
|
154
156
|
if (statusCode === 200 && data) {
|
|
155
157
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
156
158
|
? Number(res.data.code)
|
|
157
159
|
: -1;
|
|
158
160
|
const subCode = Object.prototype.hasOwnProperty.call(res.data, 'subCode')
|
|
159
161
|
? Number(res.data.subCode)
|
|
160
162
|
: -1;
|
|
161
163
|
if (
|
|
162
164
|
data.success === true ||
|
|
163
165
|
data.isSuccess ||
|
|
164
166
|
resCode === 0 ||
|
|
165
167
|
resCode === 200 ||
|
|
166
168
|
subCode === 0
|
|
167
169
|
) {
|
|
168
170
|
changeRes = {
|
|
169
171
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
170
172
|
? data.result
|
|
171
173
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
172
174
|
? data.data
|
|
173
175
|
: data,
|
|
174
176
|
code: data.code || 200,
|
|
175
177
|
ok: true,
|
|
176
178
|
source: data,
|
|
177
179
|
};
|
|
178
180
|
return changeRes;
|
|
179
181
|
} else {
|
|
180
182
|
changeRes = {
|
|
181
183
|
...data,
|
|
182
184
|
ok: false,
|
|
183
185
|
statusCode: res.statusCode,
|
|
184
186
|
};
|
|
185
187
|
return changeRes;
|
|
186
188
|
}
|
|
187
189
|
} else {
|
|
188
190
|
changeRes = {
|
|
189
191
|
...data,
|
|
190
192
|
ok: false,
|
|
191
193
|
statusCode: res.statusCode,
|
|
192
194
|
};
|
|
193
195
|
return changeRes;
|
|
194
196
|
}
|
|
195
197
|
})
|
|
196
198
|
.catch((res) => {
|
|
197
199
|
return {
|
|
198
200
|
...res,
|
|
199
201
|
ok: false,
|
|
200
202
|
} as ServiceInterFace.RequestResponseFormatRes;
|
|
201
203
|
});
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
async receiveCoupon(param = {}, clientParams) {
|
|
205
207
|
const loginType = isPc ? { loginType: 3 } : {};
|
|
206
208
|
return await this.gatewayReq(
|
|
207
209
|
'receiveShopCoupon',
|
|
208
210
|
{
|
|
209
211
|
operation: '3',
|
|
210
212
|
...param,
|
|
211
213
|
},
|
|
212
214
|
{ ...loginType, ...clientParams },
|
|
213
215
|
);
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
getCustomerCenterDispatch(params = {}) {
|
|
217
219
|
return this.gatewayReq('customerCenterDispatch', params, {
|
|
218
220
|
clientVersion: '9.2.0',
|
|
219
221
|
client: 'H5',
|
|
220
222
|
uuid: 88888,
|
|
221
223
|
appid: 'shopmember_m_jd_com',
|
|
222
224
|
});
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
batchAddCart(...args) {
|
|
226
228
|
let skuIds, num, showToast, giftCard;
|
|
227
229
|
if (['number', 'string'].includes(typeof args[0])) {
|
|
228
230
|
[skuIds, num = 1, showToast = true, giftCard = false] = args;
|
|
229
231
|
} else if (typeof args[0] === 'object' && args[0] !== null) {
|
|
230
232
|
const params = args[0];
|
|
231
233
|
skuIds = params.skuIds;
|
|
232
234
|
num = params.num || 1;
|
|
233
235
|
showToast = params.showToast !== undefined ? params.showToast : true;
|
|
234
236
|
giftCard = params.giftCard !== undefined ? params.giftCard : false;
|
|
235
237
|
} else {
|
|
236
238
|
console.error('batchAddCart() Invalid arguments!', args);
|
|
237
239
|
const msg = isLanguageForEn ? 'Please retry later' : '加入购物车失败,请稍后重试!';
|
|
238
240
|
showFailToast({
|
|
239
241
|
title: msg,
|
|
240
242
|
});
|
|
241
243
|
return Promise.resolve({
|
|
242
244
|
ok: false,
|
|
243
245
|
msg,
|
|
244
246
|
});
|
|
245
247
|
}
|
|
246
248
|
const addToWhereText = giftCard ? '购物清单' : '购物车';
|
|
247
249
|
const successMsg = isLanguageForEn ? 'Success' : `加入${addToWhereText}成功`;
|
|
248
250
|
const failMsg = isLanguageForEn
|
|
249
251
|
? 'Please retry later'
|
|
250
252
|
: `加入${addToWhereText}失败,请稍后重试!`;
|
|
251
253
|
if (skuIds) {
|
|
252
254
|
return this._addShopGoodCart(`${skuIds}`, `${num}`, { giftCard })
|
|
253
255
|
.then((res: ServiceInterFace.SkuToCartDataRes) => {
|
|
254
256
|
if (res?.ok) {
|
|
255
257
|
if (showToast && !res?.isOpenApp)
|
|
256
258
|
showSuccessToast({
|
|
257
259
|
title: successMsg,
|
|
258
260
|
});
|
|
259
261
|
} else {
|
|
260
262
|
showToast &&
|
|
261
263
|
showFailToast({
|
|
262
264
|
title: res?.errMsg || failMsg,
|
|
263
265
|
});
|
|
264
266
|
}
|
|
265
267
|
return Promise.resolve(res);
|
|
266
268
|
})
|
|
267
269
|
.catch((e) => {
|
|
268
270
|
console.log('调用加购方法异常=======>', e);
|
|
269
271
|
return Promise.resolve({
|
|
270
272
|
ok: false,
|
|
271
273
|
msg: failMsg,
|
|
272
274
|
});
|
|
273
275
|
});
|
|
274
276
|
} else {
|
|
275
277
|
return Promise.resolve({
|
|
276
278
|
ok: false,
|
|
277
279
|
msg: failMsg,
|
|
278
280
|
});
|
|
279
281
|
}
|
|
280
282
|
}
|
|
281
283
|
|
|
282
284
|
async giftCardAddCart(skuList, num) {
|
|
283
285
|
const loginType = isPc ? { loginType: 3 } : {};
|
|
284
286
|
return this.gatewayReq(
|
|
285
287
|
'giftCardAddCart',
|
|
286
288
|
{
|
|
287
289
|
skuList,
|
|
288
290
|
num: Number(num),
|
|
289
291
|
},
|
|
290
292
|
{ ...loginType },
|
|
291
293
|
);
|
|
292
294
|
}
|
|
293
295
|
|
|
294
296
|
_addShopGoodCart(skuIdsStr, addCardNum = '1', { giftCard }) {
|
|
295
297
|
return new Promise((resolve) => {
|
|
296
298
|
const productIdsArr = skuIdsStr ? `${skuIdsStr}`.split(',') : [];
|
|
297
299
|
if (productIdsArr.length > 0) {
|
|
298
300
|
if (giftCard) {
|
|
299
301
|
this.giftCardAddCart(productIdsArr, addCardNum)
|
|
300
302
|
.then((res) => {
|
|
301
303
|
if (res?.code === '0' && res?.result?.value) {
|
|
302
304
|
resolve({
|
|
303
305
|
ok: true,
|
|
304
306
|
});
|
|
305
307
|
} else {
|
|
306
308
|
resolve({
|
|
307
309
|
ok: false,
|
|
308
310
|
msg: '加购失败,请稍后重试',
|
|
309
311
|
});
|
|
310
312
|
}
|
|
311
313
|
})
|
|
312
314
|
.catch((e) => {
|
|
313
315
|
console.error('礼品卡加车失败: ', e);
|
|
314
316
|
resolve({
|
|
315
317
|
ok: false,
|
|
316
318
|
msg: '加购失败,请稍后重试',
|
|
317
319
|
});
|
|
318
320
|
});
|
|
319
321
|
} else if (isJdApp) {
|
|
320
322
|
console.log('==========>', 'app原生批量加车!,小程序端暂不涉及');
|
|
321
323
|
} else if (isMin) {
|
|
322
324
|
console.log('==========>', '京购批量加车!');
|
|
323
325
|
const productsAddCartList = productIdsArr.map((skuItem) => {
|
|
324
326
|
return {
|
|
325
327
|
skuId: skuItem,
|
|
326
328
|
buyNum: addCardNum,
|
|
327
329
|
};
|
|
328
330
|
});
|
|
329
331
|
global.wxAppBizInstance
|
|
330
332
|
.addCart({ commArr: productsAddCartList })
|
|
331
333
|
.then((res) => {
|
|
332
334
|
console.log('dealCartSuccess: ', res);
|
|
333
335
|
resolve({
|
|
334
336
|
ok: true,
|
|
335
337
|
msg: '已加入购物车!',
|
|
336
338
|
data: res,
|
|
337
339
|
});
|
|
338
340
|
})
|
|
339
341
|
.catch((e) => {
|
|
340
342
|
console.log('京购小程序批量加车失败dealCartFail: ', e);
|
|
341
343
|
resolve({
|
|
342
344
|
ok: false,
|
|
343
345
|
msg: '加购失败,请稍后重试',
|
|
344
346
|
});
|
|
345
347
|
});
|
|
346
348
|
} else {
|
|
347
349
|
console.log('==========>', 'M站批量加车!');
|
|
348
350
|
return this.productAddToCart(skuIdsStr, addCardNum).then((res) => resolve(res));
|
|
349
351
|
}
|
|
350
352
|
} else {
|
|
351
353
|
resolve({
|
|
352
354
|
ok: false,
|
|
353
355
|
msg: '加购sku不能为空',
|
|
354
356
|
});
|
|
355
357
|
}
|
|
356
358
|
});
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
productAddToCart(skuIdsStr, num) {
|
|
360
362
|
return new Promise((resolve) => {
|
|
361
363
|
if (window.AddcartToolObj) {
|
|
362
364
|
window.AddcartToolObj.addCart({
|
|
363
365
|
skuId: skuIdsStr,
|
|
364
366
|
num,
|
|
365
367
|
source: 'sjdpyw',
|
|
366
368
|
actId: '1',
|
|
367
369
|
loginType: window?.isJingGouMiniViewState ? '11' : '2',
|
|
368
370
|
sucFun(res) {
|
|
369
371
|
console.log('ok,接口请求成功,不一定指的加车成功,加车成功需要看返回码errId为0', res);
|
|
370
372
|
if (res.errId === '0' && res.cartJson) {
|
|
371
373
|
resolve({
|
|
372
374
|
ok: true,
|
|
373
375
|
msg: '已加入购物车!',
|
|
374
376
|
...res,
|
|
375
377
|
});
|
|
376
378
|
} else {
|
|
377
379
|
if (res.errId === '13') {
|
|
378
380
|
global.doLogin();
|
|
379
381
|
} else {
|
|
380
382
|
resolve({
|
|
381
383
|
ok: false,
|
|
382
384
|
msg: '加购失败,请稍后重试',
|
|
383
385
|
...res,
|
|
384
386
|
});
|
|
385
387
|
}
|
|
386
388
|
}
|
|
387
389
|
},
|
|
388
390
|
failFun(err) {
|
|
389
391
|
console.log('fail', err);
|
|
390
392
|
resolve({
|
|
391
393
|
ok: false,
|
|
392
394
|
msg: '加购失败,请稍后重试',
|
|
393
395
|
...err,
|
|
394
396
|
});
|
|
395
397
|
},
|
|
396
398
|
});
|
|
397
399
|
} else {
|
|
398
400
|
resolve({
|
|
399
401
|
ok: false,
|
|
400
402
|
msg: '购物车方法检查异常',
|
|
401
403
|
});
|
|
402
404
|
}
|
|
403
405
|
});
|
|
404
406
|
}
|
|
405
407
|
bMallGetUserInfo = () => {
|
|
406
408
|
return getBMallUserInfo();
|
|
407
409
|
};
|
|
408
410
|
async bMallAddCart(params = {}) {
|
|
409
411
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
410
412
|
client: 'H5',
|
|
411
413
|
clientVersion: '5.5.0',
|
|
412
414
|
});
|
|
413
415
|
}
|
|
414
416
|
async bMallChangeCart(params = {}) {
|
|
415
417
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
416
418
|
client: 'H5',
|
|
417
419
|
clientVersion: '5.5.0',
|
|
418
420
|
});
|
|
419
421
|
}
|
|
420
422
|
async bMallRemoveCart(params = {}) {
|
|
421
423
|
return await this.gatewayReq(
|
|
422
424
|
'bmall_cartRemove',
|
|
423
425
|
params,
|
|
424
426
|
{
|
|
425
427
|
client: 'H5',
|
|
426
428
|
clientVersion: '5.5.0',
|
|
427
429
|
},
|
|
428
430
|
);
|
|
429
431
|
}
|
|
430
432
|
async bMallGetOmittedProduct(params = {}) {
|
|
431
433
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
432
434
|
client: 'H5',
|
|
433
435
|
clientVersion: '5.5.0',
|
|
434
436
|
});
|
|
435
437
|
}
|
|
436
438
|
async bMallAddCartService({ skuId, bMallTag, num, data = {} }) {
|
|
437
439
|
const params = await getParams({ ...data, skuId, bMallTag, num });
|
|
438
440
|
return await this.bMallAddCart(params);
|
|
439
441
|
}
|
|
440
442
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
441
443
|
const params = await getParams({ bMallTag });
|
|
442
444
|
delete params.operations;
|
|
443
445
|
return await this.bMallGetOmittedProduct(params);
|
|
444
446
|
}
|
|
445
447
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
446
448
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
447
449
|
return await this.bMallRemoveCart(params);
|
|
448
450
|
}
|
|
449
451
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid, data = {} }) {
|
|
450
452
|
let params = await getParams({ ...data, skuId, bMallTag, num, skuUuid });
|
|
451
453
|
return await this.bMallChangeCart(params);
|
|
452
454
|
}
|
|
453
455
|
|
|
454
456
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
455
457
|
if (!needRequest && isH5 && window?.bMallCartData) {
|
|
456
458
|
return window?.bMallCartData;
|
|
457
459
|
}
|
|
458
460
|
const cartData = await this.bMallGetSkuNumService(bMallTag);
|
|
459
461
|
let items;
|
|
460
462
|
if (cartData.ok && cartData.result) {
|
|
461
463
|
items = cartData?.result?.items || {};
|
|
462
464
|
}
|
|
463
465
|
if (isH5) {
|
|
464
466
|
window.bMallCartData = items;
|
|
465
467
|
}
|
|
466
468
|
return items;
|
|
467
469
|
}
|
|
468
470
|
|
|
469
471
|
async bMallCartHandle(goodItem, num) {
|
|
470
472
|
try {
|
|
471
473
|
const {
|
|
472
474
|
skuUuid,
|
|
473
475
|
limitUpper,
|
|
474
476
|
limitLower,
|
|
475
477
|
} = goodItem;
|
|
476
478
|
let cartNum = Number(num);
|
|
477
479
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
478
480
|
cartNum = limitLower;
|
|
479
481
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
480
482
|
cartNum = limitUpper;
|
|
481
483
|
}
|
|
482
484
|
if (skuUuid && cartNum > 0) {
|
|
483
485
|
return this.bMallChangeCartService({
|
|
484
486
|
...goodItem,
|
|
485
487
|
skuUuid,
|
|
486
488
|
num: cartNum,
|
|
487
489
|
});
|
|
488
490
|
} else if (!skuUuid && cartNum > 0) {
|
|
489
491
|
return this.bMallAddCartService({ ...goodItem, num: cartNum });
|
|
490
492
|
} else if (skuUuid && !cartNum) {
|
|
491
493
|
return this.bMallRemoveCartService({
|
|
492
494
|
...goodItem,
|
|
493
495
|
skuUuid,
|
|
494
496
|
num: cartNum,
|
|
495
497
|
});
|
|
496
498
|
} else {
|
|
497
499
|
console.error('参数不全');
|
|
498
500
|
return false;
|
|
499
501
|
}
|
|
500
502
|
} catch (e) {
|
|
501
503
|
console.error(e);
|
|
502
504
|
}
|
|
503
505
|
}
|