@conecli/cone-render 0.10.1-shop3.47 → 0.10.1-shop3.49
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/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.weapp.tsx +1 -0
- package/dist/common/jssdk.weapp.ts +1 -0
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/CustomVideo/index.weapp.tsx +1 -0
- package/dist/components/base/InOrOutViewObserver/index.weapp.tsx +1 -0
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.weapp.tsx +1 -0
- package/dist/interface/component.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.h5.ts +1 -0
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/DecorateContainerFloorList/index.weapp.tsx +1 -0
- package/dist/open/api/shopMember.weapp.ts +1 -0
- package/dist/open/index.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -1
- package/dist/service/fetchJsonp.weapp.ts +1 -0
- package/dist/service/http/httpInterceptors.weapp.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/harmonyCallRouter.h5.ts +1 -0
- package/dist/utils/harmonyCallRouter.ts +0 -0
- package/dist/utils/sColor.weapp.ts +1 -0
- package/package.json +1 -1
- package/dist/jumpEventReport/web/wqshop.report.ts +0 -1
- package/dist/utils/priceUtils.js +0 -1
- /package/dist/utils/{sColor.js → sColor.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
1
|
WXAPP_LOGIN,
|
|
3
2
|
WXAPP_BIZ,
|
|
4
3
|
WXAPP_USER_INFO,
|
|
5
4
|
WXAPP_NAVIGATOR,
|
|
6
5
|
WXAPP_REPORT_GDT,
|
|
7
6
|
WXAPP_PARAMS_SIGN,
|
|
8
7
|
WXAPP_FINGER_REPORT,
|
|
9
8
|
WXAPP_REPORT_MANAGE,
|
|
10
9
|
WXAPP_SUBS_GUIDER,
|
|
11
10
|
WXAPP_ADDRESS_V2_API,
|
|
12
11
|
BUSINESS_TYPE,
|
|
13
12
|
SHOP_MENU_ID_TYPE,
|
|
14
13
|
SHOP_MENU_ID_NAME,
|
|
15
14
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
16
15
|
SECTION_HOME_TAB_TYPE,
|
|
17
16
|
TaroEventType,
|
|
18
17
|
WX_BUSINESS_TYPE,
|
|
19
18
|
WXAPP_BIZ_KEY,
|
|
20
19
|
WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
21
20
|
getSystemInfos,
|
|
22
21
|
getTaroStorageKeyValue,
|
|
23
22
|
getWxAppCookieStr,
|
|
24
23
|
objectToUrlEncode,
|
|
25
24
|
languageNowType,
|
|
26
25
|
abTestLabels: {},
|
|
27
26
|
nonSellableSkuids: {},
|
|
28
27
|
loginState: jdUserLoginState,
|
|
29
28
|
cookiesStr: '',
|
|
30
29
|
userInfo: userPinKey,
|
|
31
30
|
isImmersive: false,
|
|
32
31
|
pageInfo: {
|
|
33
32
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
34
33
|
address: '',
|
|
35
34
|
addressCommaStr: '',
|
|
36
35
|
un_area: '',
|
|
37
36
|
userLbsAddress: '',
|
|
38
37
|
vapptype: '1',
|
|
39
38
|
pageType: 'home',
|
|
40
39
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
41
40
|
floorExposureInfo: {},
|
|
42
41
|
floorVideInfo: {},
|
|
43
42
|
productVideInfo: {},
|
|
44
43
|
tabsLoadAllDataInfo: {
|
|
45
44
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
|
|
46
45
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
47
46
|
},
|
|
48
47
|
updateShopInfosAllState: false,
|
|
49
48
|
isVipShop: false,
|
|
50
49
|
isJdShowNativeImmersivePlayer: false,
|
|
51
50
|
...shopConfig,
|
|
52
51
|
pageScrollTop: 0,
|
|
53
52
|
pageIdxHeightInfo: {
|
|
54
53
|
list: [],
|
|
55
54
|
},
|
|
56
55
|
shopNavBarHeight: 0,
|
|
57
56
|
},
|
|
58
57
|
defaultQueryLogInfo: {
|
|
59
58
|
sourceType: 'JDshop',
|
|
60
59
|
sourceValue: '',
|
|
61
60
|
moduleId: 'none',
|
|
62
61
|
entrance: 'none',
|
|
63
62
|
},
|
|
64
63
|
originQueryInfo: {},
|
|
65
64
|
sysInfo: {
|
|
66
65
|
windowWidth: 0,
|
|
67
66
|
windowHeight: 0,
|
|
68
67
|
netWorkType: '4g',
|
|
69
68
|
jdBottomBarHeight: 0,
|
|
70
69
|
jdNativeHeaderHeight: 0,
|
|
71
70
|
},
|
|
72
71
|
queryInfo: {},
|
|
73
72
|
shopInfo: {},
|
|
74
73
|
openAppData: {},
|
|
75
74
|
public info: CommonInterFace.BaseConfigInfo;
|
|
76
75
|
public config: {
|
|
77
76
|
[key: string]: any;
|
|
78
77
|
};
|
|
79
78
|
public lazyContainer: CommonInterFace.lazyContainer;
|
|
80
79
|
public rootEleNode: HTMLElement | null;
|
|
81
80
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil;
|
|
82
81
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
|
|
83
82
|
public checkStatusAndLoginPromise: object | null;
|
|
84
83
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin;
|
|
85
84
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
|
|
86
85
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
|
|
87
86
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
|
|
88
87
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
|
|
89
88
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
|
|
90
89
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
|
|
91
90
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
|
|
92
91
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
|
|
93
92
|
public wxAppAddressV2apiInstance: CommonInterFace.wxAppAddressV2api;
|
|
94
93
|
public loadJsSdkList: Array<any>;
|
|
95
94
|
public loadJsSdkListCachePromise: any;
|
|
96
95
|
public lbsAddressCachePromise: Promise<any> | null;
|
|
97
96
|
public languageJsonData: any | null;
|
|
98
97
|
constructor(opt) {
|
|
99
98
|
this.info = this._getConfig(opt);
|
|
100
99
|
this.config = {};
|
|
101
100
|
this.lazyContainer = {
|
|
102
101
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
103
102
|
appLazyContainerList: [],
|
|
104
103
|
appLazyFinishContainerList: [],
|
|
105
104
|
},
|
|
106
105
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
107
106
|
appLazyContainerList: [],
|
|
108
107
|
appLazyFinishContainerList: [],
|
|
109
108
|
},
|
|
110
109
|
};
|
|
111
110
|
this.loadJsSdkList = [];
|
|
112
111
|
this.loadJsSdkListCachePromise = {};
|
|
113
112
|
this.rootEleNode = null;
|
|
114
113
|
this.miniApplogUtil = MiniAppLogUtil;
|
|
115
114
|
this.miniAppLogInstance = null;
|
|
116
115
|
this.checkStatusAndLoginPromise = null;
|
|
117
116
|
this.wxAppLoginInstance = WXAPP_LOGIN;
|
|
118
117
|
this.wxAppBizInstance = WXAPP_BIZ;
|
|
119
118
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO;
|
|
120
119
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
|
|
121
120
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
|
|
122
121
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
|
|
123
122
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
|
|
124
123
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT ? new WXAPP_FINGER_REPORT() : {};
|
|
125
124
|
this.wxAppSubsGuider = WXAPP_SUBS_GUIDER;
|
|
126
125
|
this.wxAppAddressV2apiInstance = WXAPP_ADDRESS_V2_API;
|
|
127
126
|
this.lbsAddressCachePromise = null;
|
|
128
127
|
this.languageJsonData = langeJsonDataForCn;
|
|
129
128
|
}
|
|
130
129
|
_getConfig(opt) {
|
|
131
130
|
return Object.assign({}, DefaultConfig, opt);
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
135
134
|
return new Promise((resolve) => {
|
|
136
135
|
setTimeout(() => {
|
|
137
136
|
const getCallBackRes = typeof callBack === 'function' && callBack();
|
|
138
137
|
return resolve(getCallBackRes || false);
|
|
139
138
|
}, timeout);
|
|
140
139
|
});
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
updateBusinessDomainAndApi(domain, api) {
|
|
144
143
|
console.log('=================>', 'updateBusinessDomainAndApi');
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
getFullScreenHeight(systemInfo) {
|
|
148
147
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
|
|
149
148
|
let result = screenHeight;
|
|
150
149
|
if (statusBarHeight > 20 && isAndroid) {
|
|
151
150
|
result = screenHeight + statusBarHeight;
|
|
152
151
|
}
|
|
153
152
|
return result;
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
getTabBarHeight(systemInfo) {
|
|
157
156
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo;
|
|
158
157
|
let result = 50;
|
|
159
158
|
if (statusBarHeight > 20) {
|
|
160
159
|
if (isIOS) {
|
|
161
160
|
result = 84;
|
|
162
161
|
} else if (isAndroid) {
|
|
163
162
|
result = 53;
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
return result;
|
|
167
166
|
}
|
|
168
167
|
|
|
169
168
|
getSystemInfo() {
|
|
170
169
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
|
|
171
170
|
const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
|
|
172
171
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
|
|
173
172
|
const fullScreenHeight = this.getFullScreenHeight(info);
|
|
174
173
|
const tabBarHeight = this.getTabBarHeight(info);
|
|
175
174
|
const safeContentHeight = fullScreenHeight - headerHeight;
|
|
176
175
|
this.info.sysInfo = {
|
|
177
176
|
...this.info.sysInfo,
|
|
178
177
|
...info,
|
|
179
178
|
actualNavBarHeight,
|
|
180
179
|
headerHeight,
|
|
181
180
|
fullScreenHeight,
|
|
182
181
|
tabBarHeight,
|
|
183
182
|
safeContentHeight,
|
|
184
183
|
languageType: languageNowType,
|
|
185
184
|
};
|
|
186
185
|
if (this.info.sysInfo['hostVersionName']) {
|
|
187
186
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
188
187
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
189
188
|
);
|
|
190
189
|
}
|
|
191
190
|
if (isPublishToWxapp) {
|
|
192
191
|
this.getAddressCachePromise();
|
|
193
192
|
this.getLbsAddressCachePromise();
|
|
194
193
|
}
|
|
195
194
|
this.info.sysInfo['wifiVideoAutoPlay'] = false;
|
|
196
195
|
this.getNetWorkType();
|
|
197
196
|
console.log('获取系统信息', this.info.sysInfo);
|
|
198
197
|
}
|
|
199
198
|
async updateMPaasConfig() {}
|
|
200
199
|
|
|
201
200
|
getNetWorkType() {
|
|
202
201
|
Taro.getNetworkType().then((getRes) => {
|
|
203
202
|
getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
|
|
204
203
|
});
|
|
205
204
|
}
|
|
206
205
|
getAPPUseStraightCorner() {
|
|
207
206
|
return Promise.resolve(false);
|
|
208
207
|
}
|
|
209
208
|
|
|
210
209
|
checkStatusAndLogin(options = {}) {
|
|
211
210
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
212
211
|
console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
|
|
213
212
|
this.toLogin(options)
|
|
214
213
|
.then((res) => {
|
|
215
214
|
console.log('微信小程序登录状态结果,成功', res);
|
|
216
215
|
this.info.loginState = true;
|
|
217
216
|
resolve(res);
|
|
218
217
|
})
|
|
219
218
|
.catch((err) => {
|
|
220
219
|
console.log('微信小程序登录异常状态结果', err);
|
|
221
220
|
this.doLogin(options)
|
|
222
221
|
.then((res2) => {
|
|
223
222
|
console.log('微信小程序wxDoLogin强制登陆成功:', res2);
|
|
224
223
|
this.info.loginState = true;
|
|
225
224
|
resolve(res2);
|
|
226
225
|
})
|
|
227
226
|
.catch((err2) => {
|
|
228
227
|
console.log('微信小程序wxDoLogin强制登陆失败:', err2);
|
|
229
228
|
this.checkStatusAndLoginPromise = null;
|
|
230
229
|
reject(err2);
|
|
231
230
|
});
|
|
232
231
|
});
|
|
233
232
|
});
|
|
234
233
|
return this.checkStatusAndLoginPromise;
|
|
235
234
|
}
|
|
236
235
|
|
|
237
236
|
checkJdStatusAndLogin(
|
|
238
237
|
options = {
|
|
239
238
|
loginColor: {
|
|
240
239
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
241
240
|
dpin: 0,
|
|
242
241
|
},
|
|
243
242
|
},
|
|
244
243
|
) {
|
|
245
244
|
return this.checkStatusAndLogin(options);
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
toLogin(options = {}): Promise<any> {
|
|
249
248
|
return this.wxAppLoginInstance
|
|
250
249
|
.getLoginPromise({
|
|
251
250
|
mode: 'common',
|
|
252
251
|
loginColor: {
|
|
253
252
|
biz: WXAPP_BIZ_KEY,
|
|
254
253
|
dpin: 1,
|
|
255
254
|
},
|
|
256
255
|
...options,
|
|
257
256
|
})
|
|
258
257
|
.then((res) => {
|
|
259
258
|
console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
|
|
260
259
|
setTimeout(() => {
|
|
261
260
|
console.log(
|
|
262
261
|
'微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
263
262
|
);
|
|
264
263
|
this.getLoginCookie(`${Date.now()}`);
|
|
265
264
|
}, 500);
|
|
266
265
|
})
|
|
267
266
|
.catch((err) => {
|
|
268
267
|
console.log('微信app登录异常返回信息,也获取cookie', err);
|
|
269
268
|
this.getLoginCookie(`${Date.now()}`);
|
|
270
269
|
});
|
|
271
270
|
}
|
|
272
271
|
|
|
273
272
|
doLogin(options = {}) {
|
|
274
273
|
const getParams = {
|
|
275
274
|
loginColor: {
|
|
276
275
|
biz: WXAPP_BIZ_KEY,
|
|
277
276
|
dpin: 1,
|
|
278
277
|
},
|
|
279
278
|
...options,
|
|
280
279
|
};
|
|
281
280
|
if (isPublishToWxapp) {
|
|
282
281
|
getParams['returnUrl'] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
283
282
|
...this.info.originQueryInfo,
|
|
284
283
|
loadShopxType: 'redirect',
|
|
285
284
|
})}`;
|
|
286
285
|
}
|
|
287
286
|
return this.wxAppLoginInstance.doLogin(getParams).then((res) => {
|
|
288
287
|
console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
|
|
289
288
|
setTimeout(() => {
|
|
290
289
|
console.log('微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie');
|
|
291
290
|
this.getLoginCookie(`${Date.now()}`);
|
|
292
291
|
}, 500);
|
|
293
292
|
return res;
|
|
294
293
|
});
|
|
295
294
|
}
|
|
296
295
|
|
|
297
296
|
doLoginForJdPin(options = {}) {
|
|
298
297
|
return this.doLogin({
|
|
299
298
|
loginColor: {
|
|
300
299
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
301
300
|
dpin: 0,
|
|
302
301
|
},
|
|
303
302
|
...options,
|
|
304
303
|
});
|
|
305
304
|
}
|
|
306
305
|
|
|
307
306
|
getLoginCookie(updateKey = 'wxapp') {
|
|
308
307
|
return new Promise(async (resolve) => {
|
|
309
308
|
console.log('开始获取更新wxapp中的cookie信息', updateKey);
|
|
310
309
|
if (
|
|
311
310
|
this.config.wqCookie &&
|
|
312
311
|
this.config.wqCookieStr &&
|
|
313
312
|
this.config.getWqCookieKey === updateKey
|
|
314
313
|
) {
|
|
315
314
|
console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
|
|
316
315
|
resolve({
|
|
317
316
|
wqCookie: this.config.wqCookie,
|
|
318
317
|
wqCookieStr: this.config.wqCookieStr,
|
|
319
318
|
});
|
|
320
319
|
} else {
|
|
321
320
|
if (isPublishToWxapp) {
|
|
322
321
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
|
|
323
322
|
if (getWxappCookieObj) {
|
|
324
323
|
const getCookieObj = getWxappCookieObj['_data'];
|
|
325
324
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
|
|
326
325
|
const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
|
|
327
326
|
this.info.loginState = true;
|
|
328
327
|
this.info.userInfo.wqCookie = wqCookieStr;
|
|
329
328
|
this.info.userInfo.wqVisitkey = visitkey;
|
|
330
329
|
console.log('获取用户完整cookie信息', getCookieObj);
|
|
331
330
|
if (this.miniAppLogInstance) {
|
|
332
331
|
this.miniAppLogInstance.set({
|
|
333
332
|
account: pin,
|
|
334
333
|
unionid: wq_unionid,
|
|
335
334
|
openid: wxapp_openid,
|
|
336
335
|
});
|
|
337
336
|
}
|
|
338
337
|
this.config.wqCookie = wqCookie;
|
|
339
338
|
this.config.wqCookieStr = wqCookieStr;
|
|
340
339
|
this.config.getWqCookieKey = updateKey;
|
|
341
340
|
console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
|
|
342
341
|
resolve({
|
|
343
342
|
wqCookie,
|
|
344
343
|
wqCookieStr,
|
|
345
344
|
});
|
|
346
345
|
} else {
|
|
347
346
|
console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
|
|
348
347
|
resolve({
|
|
349
348
|
wqCookie: false,
|
|
350
349
|
wqCookieStr: false,
|
|
351
350
|
});
|
|
352
351
|
}
|
|
353
352
|
} else {
|
|
354
353
|
resolve({
|
|
355
354
|
wqCookie: false,
|
|
356
355
|
wqCookieStr: false,
|
|
357
356
|
});
|
|
358
357
|
}
|
|
359
358
|
}
|
|
360
359
|
});
|
|
361
360
|
}
|
|
362
361
|
|
|
363
362
|
|
|
364
363
|
checkLoginStatus() {
|
|
365
364
|
return this.getLoginCookie();
|
|
366
365
|
}
|
|
367
366
|
|
|
368
367
|
getAddressCachePromise = () => {
|
|
369
368
|
return new Promise((resolve) => {
|
|
370
369
|
if (this.info.sysInfo?.area) {
|
|
371
370
|
resolve({
|
|
372
371
|
lat: this.info.sysInfo?.lat,
|
|
373
372
|
lng: this.info.sysInfo?.lng,
|
|
374
373
|
area: this.info.sysInfo?.area,
|
|
375
374
|
});
|
|
376
375
|
} else {
|
|
377
376
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress();
|
|
378
377
|
console.info('京购原生获取用户基地址信息', getUserAddress);
|
|
379
378
|
if (getUserAddress) {
|
|
380
379
|
const { areaId = '', latitude, longitude } = getUserAddress;
|
|
381
380
|
this.info.sysInfo['lat'] = `${latitude || ''}`;
|
|
382
381
|
this.info.sysInfo['lng'] = `${longitude || ''}`;
|
|
383
382
|
if (areaId && areaId !== '') {
|
|
384
383
|
this.info.pageInfo.address = areaId;
|
|
385
384
|
this.info.pageInfo.addressCommaStr = areaId.replace(/_/g, ',');
|
|
386
385
|
this.info.pageInfo.un_area = areaId;
|
|
387
386
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
388
387
|
area: areaId,
|
|
389
388
|
});
|
|
390
389
|
this.info.sysInfo['area'] = areaId;
|
|
391
390
|
}
|
|
392
391
|
resolve({
|
|
393
392
|
lat: this.info.sysInfo['lat'],
|
|
394
393
|
lng: this.info.sysInfo['lng'],
|
|
395
394
|
area: areaId,
|
|
396
395
|
});
|
|
397
396
|
} else {
|
|
398
397
|
resolve({ lat: '', lng: '', area: '' });
|
|
399
398
|
}
|
|
400
399
|
}
|
|
401
400
|
});
|
|
402
401
|
};
|
|
403
402
|
|
|
404
403
|
getLbsAddressCachePromise(): Promise<{
|
|
405
404
|
ok: boolean;
|
|
406
405
|
msg?: string;
|
|
407
406
|
realTimeArea: string;
|
|
408
407
|
data?: any;
|
|
409
408
|
}> {
|
|
410
409
|
if (!this.lbsAddressCachePromise) {
|
|
411
410
|
this.lbsAddressCachePromise = new Promise((resolve) => {
|
|
412
411
|
const getWxappLbsAddressInfo = this.wxAppUserInfoInstance.getLbsAddress();
|
|
413
412
|
console.info('京购原生获取用户基于lbs的缓存地址信息', getWxappLbsAddressInfo);
|
|
414
413
|
if (getWxappLbsAddressInfo && getWxappLbsAddressInfo?.areaId !== '') {
|
|
415
414
|
this.info.pageInfo.userLbsAddress = getWxappLbsAddressInfo?.areaId;
|
|
416
415
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
417
416
|
realTimeArea: this.info.pageInfo.userLbsAddress,
|
|
418
417
|
});
|
|
419
418
|
resolve({
|
|
420
419
|
ok: true,
|
|
421
420
|
realTimeArea: getWxappLbsAddressInfo?.areaId || '',
|
|
422
421
|
});
|
|
423
422
|
} else {
|
|
424
423
|
this.wxAppAddressV2apiInstance
|
|
425
424
|
.fetchLbsAddr({
|
|
426
425
|
token: 'W23b9sUlcnhCPZxQ2daYMkDqrTL0TeDw9tbDm5lVMVA=',
|
|
427
426
|
from: 'wxapp_shop_real_area',
|
|
428
427
|
})
|
|
429
428
|
.then((res) => {
|
|
430
429
|
console.info('微信京购里面获取静默实时lbs地址信息结果', res);
|
|
431
430
|
const { provinceId, cityId, countyId, townId } = res;
|
|
432
431
|
let realTimeArea = '';
|
|
433
432
|
if (provinceId) {
|
|
434
433
|
realTimeArea = `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
|
|
435
434
|
this.info.pageInfo.userLbsAddress = realTimeArea;
|
|
436
435
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
437
436
|
realTimeArea: realTimeArea,
|
|
438
437
|
});
|
|
439
438
|
} else {
|
|
440
439
|
this.lbsAddressCachePromise = null;
|
|
441
440
|
}
|
|
442
441
|
const getValidRealTimeArea = realTimeArea !== '';
|
|
443
442
|
resolve({
|
|
444
443
|
ok: getValidRealTimeArea,
|
|
445
444
|
msg: getValidRealTimeArea
|
|
446
445
|
? '成功'
|
|
447
446
|
: '根据微信底层接口获取静默实时lbs地址信息异常,详情见data',
|
|
448
447
|
data: getValidRealTimeArea ? null : res,
|
|
449
448
|
realTimeArea: realTimeArea,
|
|
450
449
|
});
|
|
451
450
|
})
|
|
452
451
|
.catch((err) => {
|
|
453
452
|
console.warn('微信京购里面获取静默实时lbs地址信息异常', err);
|
|
454
453
|
this.lbsAddressCachePromise = null;
|
|
455
454
|
resolve({
|
|
456
455
|
ok: false,
|
|
457
456
|
msg: '微信京购里面获取静默实时lbs地址信息异常',
|
|
458
457
|
realTimeArea: '',
|
|
459
458
|
});
|
|
460
459
|
});
|
|
461
460
|
}
|
|
462
461
|
});
|
|
463
462
|
}
|
|
464
463
|
return this.lbsAddressCachePromise;
|
|
465
464
|
}
|
|
466
465
|
|
|
467
466
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
468
467
|
const createUpdateQueryInfo: {
|
|
469
468
|
query: {
|
|
470
469
|
shopId?: string | number;
|
|
471
470
|
venderId?: string | number;
|
|
472
471
|
};
|
|
473
472
|
updateShopInfoState: boolean;
|
|
474
473
|
} = Object.assign(
|
|
475
474
|
{},
|
|
476
475
|
{
|
|
477
476
|
query: {},
|
|
478
477
|
updateShopInfoState: false,
|
|
479
478
|
},
|
|
480
479
|
updateQuery,
|
|
481
480
|
);
|
|
482
481
|
console.log(
|
|
483
482
|
'获取当前下发的店铺查询参数',
|
|
484
483
|
updateQuery,
|
|
485
484
|
'获取之前保存的shopInfo店铺查询参数',
|
|
486
485
|
this.info?.shopInfo,
|
|
487
486
|
);
|
|
488
487
|
const { query, updateShopInfoState } = createUpdateQueryInfo;
|
|
489
488
|
const { shopId, venderId } = query;
|
|
490
489
|
if (updateShopInfoState) {
|
|
491
490
|
this.info.queryInfo = {
|
|
492
491
|
...this.info.queryInfo,
|
|
493
492
|
...query,
|
|
494
493
|
};
|
|
495
494
|
if (shopId && venderId) {
|
|
496
495
|
this.info.shopInfo = {
|
|
497
496
|
shopId: `${shopId}`,
|
|
498
497
|
venderId: `${venderId}`,
|
|
499
498
|
};
|
|
500
499
|
}
|
|
501
500
|
} else {
|
|
502
501
|
this.info.queryInfo = {
|
|
503
502
|
...query,
|
|
504
503
|
};
|
|
505
504
|
this.info.originQueryInfo = {
|
|
506
505
|
...query,
|
|
507
506
|
};
|
|
508
507
|
if (
|
|
509
508
|
this.info.shopInfo?.shopId &&
|
|
510
509
|
this.info.shopInfo?.venderId &&
|
|
511
510
|
(this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
|
|
512
511
|
) {
|
|
513
512
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId;
|
|
514
513
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId;
|
|
515
514
|
console.log(
|
|
516
515
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
517
516
|
this.info.queryInfo,
|
|
518
517
|
);
|
|
519
518
|
}
|
|
520
519
|
}
|
|
521
520
|
this.info.queryInfo['shopId'] &&
|
|
522
521
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
|
|
523
522
|
this.info.queryInfo['venderId'] &&
|
|
524
523
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
|
|
525
524
|
console.log(
|
|
526
525
|
'weapp===获取店铺下发查询参数\n',
|
|
527
526
|
query,
|
|
528
527
|
'\n获取店铺最后查询参数\n',
|
|
529
528
|
this.info.queryInfo,
|
|
530
529
|
'\n是否为更新店铺状态\n',
|
|
531
530
|
updateShopInfoState,
|
|
532
531
|
);
|
|
533
532
|
}
|
|
534
533
|
|
|
535
534
|
getDynamicConfig(key: string) {
|
|
536
535
|
console.warn('调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!');
|
|
537
536
|
return null;
|
|
538
537
|
}
|
|
539
538
|
renderNextTickLoadSdk() {
|
|
540
539
|
console.warn('暂未实现 index.weapp.ts');
|
|
541
540
|
}
|
|
542
541
|
loadOtherSdk() {
|
|
543
542
|
console.warn('暂未实现 index.weapp.ts');
|
|
544
543
|
}
|
|
545
544
|
loadItemSdkPromise() {
|
|
546
545
|
console.warn('暂未实现 index.weapp.ts');
|
|
547
546
|
}
|
|
548
547
|
createLanguageProimse() {
|
|
549
548
|
return Promise.reject({
|
|
550
549
|
msg: '暂未实现',
|
|
551
550
|
});
|
|
552
551
|
}
|
|
552
|
+
import Taro from '@tarojs/taro';
|
|
553
553
|
WXAPP_LOGIN,
|
|
554
554
|
WXAPP_BIZ,
|
|
555
555
|
WXAPP_USER_INFO,
|
|
556
556
|
WXAPP_NAVIGATOR,
|
|
557
557
|
WXAPP_REPORT_GDT,
|
|
558
558
|
WXAPP_PARAMS_SIGN,
|
|
559
559
|
WXAPP_FINGER_REPORT,
|
|
560
560
|
WXAPP_REPORT_MANAGE,
|
|
561
561
|
WXAPP_SUBS_GUIDER,
|
|
562
562
|
WXAPP_ADDRESS_V2_API,
|
|
563
563
|
BUSINESS_TYPE,
|
|
564
564
|
SHOP_MENU_ID_TYPE,
|
|
565
565
|
SHOP_MENU_ID_NAME,
|
|
566
566
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
567
567
|
SECTION_HOME_TAB_TYPE,
|
|
568
568
|
TaroEventType,
|
|
569
569
|
WX_BUSINESS_TYPE,
|
|
570
570
|
WXAPP_BIZ_KEY,
|
|
571
571
|
WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
572
572
|
getSystemInfos,
|
|
573
573
|
getTaroStorageKeyValue,
|
|
574
574
|
getWxAppCookieStr,
|
|
575
575
|
objectToUrlEncode,
|
|
576
576
|
languageNowType,
|
|
577
577
|
abTestLabels: {},
|
|
578
578
|
nonSellableSkuids: {},
|
|
579
579
|
loginState: jdUserLoginState,
|
|
580
580
|
cookiesStr: '',
|
|
581
581
|
userInfo: userPinKey,
|
|
582
582
|
isImmersive: false,
|
|
583
583
|
pageInfo: {
|
|
584
584
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
585
585
|
address: '',
|
|
586
586
|
addressCommaStr: '',
|
|
587
587
|
un_area: '',
|
|
588
588
|
userLbsAddress: '',
|
|
589
589
|
vapptype: '1',
|
|
590
590
|
pageType: 'home',
|
|
591
591
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
592
592
|
floorExposureInfo: {},
|
|
593
593
|
floorVideInfo: {},
|
|
594
594
|
productVideInfo: {},
|
|
595
595
|
tabsLoadAllDataInfo: {
|
|
596
596
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
|
|
597
597
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
598
598
|
},
|
|
599
599
|
updateShopInfosAllState: false,
|
|
600
600
|
isVipShop: false,
|
|
601
601
|
isJdShowNativeImmersivePlayer: false,
|
|
602
602
|
...shopConfig,
|
|
603
603
|
pageScrollTop: 0,
|
|
604
604
|
pageIdxHeightInfo: {
|
|
605
605
|
list: [],
|
|
606
606
|
},
|
|
607
607
|
shopNavBarHeight: 0,
|
|
608
608
|
},
|
|
609
609
|
defaultQueryLogInfo: {
|
|
610
610
|
sourceType: 'JDshop',
|
|
611
611
|
sourceValue: '',
|
|
612
612
|
moduleId: 'none',
|
|
613
613
|
entrance: 'none',
|
|
614
614
|
},
|
|
615
615
|
originQueryInfo: {},
|
|
616
616
|
sysInfo: {
|
|
617
617
|
windowWidth: 0,
|
|
618
618
|
windowHeight: 0,
|
|
619
619
|
netWorkType: '4g',
|
|
620
620
|
jdBottomBarHeight: 0,
|
|
621
621
|
jdNativeHeaderHeight: 0,
|
|
622
622
|
},
|
|
623
623
|
queryInfo: {},
|
|
624
624
|
shopInfo: {},
|
|
625
625
|
openAppData: {},
|
|
626
626
|
public info: CommonInterFace.BaseConfigInfo;
|
|
627
627
|
public config: {
|
|
628
628
|
[key: string]: any;
|
|
629
629
|
};
|
|
630
630
|
public lazyContainer: CommonInterFace.lazyContainer;
|
|
631
631
|
public rootEleNode: HTMLElement | null;
|
|
632
632
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil;
|
|
633
633
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
|
|
634
634
|
public checkStatusAndLoginPromise: object | null;
|
|
635
635
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin;
|
|
636
636
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
|
|
637
637
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
|
|
638
638
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
|
|
639
639
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
|
|
640
640
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
|
|
641
641
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
|
|
642
642
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
|
|
643
643
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
|
|
644
644
|
public wxAppAddressV2apiInstance: CommonInterFace.wxAppAddressV2api;
|
|
645
645
|
public loadJsSdkList: Array<any>;
|
|
646
646
|
public loadJsSdkListCachePromise: any;
|
|
647
647
|
public lbsAddressCachePromise: Promise<any> | null;
|
|
648
648
|
public languageJsonData: any | null;
|
|
649
649
|
constructor(opt) {
|
|
650
650
|
this.info = this._getConfig(opt);
|
|
651
651
|
this.config = {};
|
|
652
652
|
this.lazyContainer = {
|
|
653
653
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
654
654
|
appLazyContainerList: [],
|
|
655
655
|
appLazyFinishContainerList: [],
|
|
656
656
|
},
|
|
657
657
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
658
658
|
appLazyContainerList: [],
|
|
659
659
|
appLazyFinishContainerList: [],
|
|
660
660
|
},
|
|
661
661
|
};
|
|
662
662
|
this.loadJsSdkList = [];
|
|
663
663
|
this.loadJsSdkListCachePromise = {};
|
|
664
664
|
this.rootEleNode = null;
|
|
665
665
|
this.miniApplogUtil = MiniAppLogUtil;
|
|
666
666
|
this.miniAppLogInstance = null;
|
|
667
667
|
this.checkStatusAndLoginPromise = null;
|
|
668
668
|
this.wxAppLoginInstance = WXAPP_LOGIN;
|
|
669
669
|
this.wxAppBizInstance = WXAPP_BIZ;
|
|
670
670
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO;
|
|
671
671
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
|
|
672
672
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
|
|
673
673
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
|
|
674
674
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
|
|
675
675
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT ? new WXAPP_FINGER_REPORT() : {};
|
|
676
676
|
this.wxAppSubsGuider = WXAPP_SUBS_GUIDER;
|
|
677
677
|
this.wxAppAddressV2apiInstance = WXAPP_ADDRESS_V2_API;
|
|
678
678
|
this.lbsAddressCachePromise = null;
|
|
679
679
|
this.languageJsonData = langeJsonDataForCn;
|
|
680
680
|
}
|
|
681
681
|
_getConfig(opt) {
|
|
682
682
|
return Object.assign({}, DefaultConfig, opt);
|
|
683
683
|
}
|
|
684
684
|
|
|
685
685
|
jmfeReayPromise(): Promise<any> {
|
|
686
686
|
return Promise.reject(false);
|
|
687
687
|
}
|
|
688
688
|
|
|
689
689
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
690
690
|
return new Promise((resolve) => {
|
|
691
691
|
setTimeout(() => {
|
|
692
692
|
const getCallBackRes = typeof callBack === 'function' && callBack();
|
|
693
693
|
return resolve(getCallBackRes || false);
|
|
694
694
|
}, timeout);
|
|
695
695
|
});
|
|
696
696
|
}
|
|
697
697
|
|
|
698
698
|
updateBusinessDomainAndApi(domain, api) {
|
|
699
699
|
console.log('=================>', 'updateBusinessDomainAndApi');
|
|
700
700
|
}
|
|
701
701
|
|
|
702
702
|
getFullScreenHeight(systemInfo) {
|
|
703
703
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
|
|
704
704
|
let result = screenHeight;
|
|
705
705
|
if (statusBarHeight > 20 && isAndroid) {
|
|
706
706
|
result = screenHeight + statusBarHeight;
|
|
707
707
|
}
|
|
708
708
|
return result;
|
|
709
709
|
}
|
|
710
710
|
|
|
711
711
|
getTabBarHeight(systemInfo) {
|
|
712
712
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo;
|
|
713
713
|
let result = 50;
|
|
714
714
|
if (statusBarHeight > 20) {
|
|
715
715
|
if (isIOS) {
|
|
716
716
|
result = 84;
|
|
717
717
|
} else if (isAndroid) {
|
|
718
718
|
result = 53;
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
721
|
return result;
|
|
722
722
|
}
|
|
723
723
|
|
|
724
724
|
getSystemInfo() {
|
|
725
725
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
|
|
726
726
|
const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
|
|
727
727
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
|
|
728
728
|
const fullScreenHeight = this.getFullScreenHeight(info);
|
|
729
729
|
const tabBarHeight = this.getTabBarHeight(info);
|
|
730
730
|
const safeContentHeight = fullScreenHeight - headerHeight;
|
|
731
731
|
this.info.sysInfo = {
|
|
732
732
|
...this.info.sysInfo,
|
|
733
733
|
...info,
|
|
734
734
|
actualNavBarHeight,
|
|
735
735
|
headerHeight,
|
|
736
736
|
fullScreenHeight,
|
|
737
737
|
tabBarHeight,
|
|
738
738
|
safeContentHeight,
|
|
739
739
|
languageType: languageNowType,
|
|
740
740
|
};
|
|
741
741
|
if (this.info.sysInfo['hostVersionName']) {
|
|
742
742
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
743
743
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
744
744
|
);
|
|
745
745
|
}
|
|
746
746
|
if (isPublishToWxapp) {
|
|
747
747
|
this.getAddressCachePromise();
|
|
748
748
|
this.getLbsAddressCachePromise();
|
|
749
749
|
}
|
|
750
750
|
this.info.sysInfo['wifiVideoAutoPlay'] = false;
|
|
751
751
|
this.getNetWorkType();
|
|
752
752
|
console.log('获取系统信息', this.info.sysInfo);
|
|
753
753
|
}
|
|
754
754
|
async updateMPaasConfig() {}
|
|
755
755
|
|
|
756
756
|
getNetWorkType() {
|
|
757
757
|
Taro.getNetworkType().then((getRes) => {
|
|
758
758
|
getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
|
|
759
759
|
});
|
|
760
760
|
}
|
|
761
761
|
getAPPUseStraightCorner() {
|
|
762
762
|
return Promise.resolve(false);
|
|
763
763
|
}
|
|
764
764
|
|
|
765
765
|
checkStatusAndLogin(options = {}) {
|
|
766
766
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
767
767
|
console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
|
|
768
768
|
this.toLogin(options)
|
|
769
769
|
.then((res) => {
|
|
770
770
|
console.log('微信小程序登录状态结果,成功', res);
|
|
771
771
|
this.info.loginState = true;
|
|
772
772
|
resolve(res);
|
|
773
773
|
})
|
|
774
774
|
.catch((err) => {
|
|
775
775
|
console.log('微信小程序登录异常状态结果', err);
|
|
776
776
|
this.doLogin(options)
|
|
777
777
|
.then((res2) => {
|
|
778
778
|
console.log('微信小程序wxDoLogin强制登陆成功:', res2);
|
|
779
779
|
this.info.loginState = true;
|
|
780
780
|
resolve(res2);
|
|
781
781
|
})
|
|
782
782
|
.catch((err2) => {
|
|
783
783
|
console.log('微信小程序wxDoLogin强制登陆失败:', err2);
|
|
784
784
|
this.checkStatusAndLoginPromise = null;
|
|
785
785
|
reject(err2);
|
|
786
786
|
});
|
|
787
787
|
});
|
|
788
788
|
});
|
|
789
789
|
return this.checkStatusAndLoginPromise;
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
checkJdStatusAndLogin(
|
|
793
793
|
options = {
|
|
794
794
|
loginColor: {
|
|
795
795
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
796
796
|
dpin: 0,
|
|
797
797
|
},
|
|
798
798
|
},
|
|
799
799
|
) {
|
|
800
800
|
return this.checkStatusAndLogin(options);
|
|
801
801
|
}
|
|
802
802
|
|
|
803
803
|
toLogin(options = {}): Promise<any> {
|
|
804
804
|
return this.wxAppLoginInstance
|
|
805
805
|
.getLoginPromise({
|
|
806
806
|
mode: 'common',
|
|
807
807
|
loginColor: {
|
|
808
808
|
biz: WXAPP_BIZ_KEY,
|
|
809
809
|
dpin: 1,
|
|
810
810
|
},
|
|
811
811
|
...options,
|
|
812
812
|
})
|
|
813
813
|
.then((res) => {
|
|
814
814
|
console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
|
|
815
815
|
setTimeout(() => {
|
|
816
816
|
console.log(
|
|
817
817
|
'微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
818
818
|
);
|
|
819
819
|
this.getLoginCookie(`${Date.now()}`);
|
|
820
820
|
}, 500);
|
|
821
821
|
})
|
|
822
822
|
.catch((err) => {
|
|
823
823
|
console.log('微信app登录异常返回信息,也获取cookie', err);
|
|
824
824
|
this.getLoginCookie(`${Date.now()}`);
|
|
825
825
|
});
|
|
826
826
|
}
|
|
827
827
|
|
|
828
828
|
doLogin(options = {}) {
|
|
829
829
|
const getParams = {
|
|
830
830
|
loginColor: {
|
|
831
831
|
biz: WXAPP_BIZ_KEY,
|
|
832
832
|
dpin: 1,
|
|
833
833
|
},
|
|
834
834
|
...options,
|
|
835
835
|
};
|
|
836
836
|
if (isPublishToWxapp) {
|
|
837
837
|
getParams['returnUrl'] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
838
838
|
...this.info.originQueryInfo,
|
|
839
839
|
loadShopxType: 'redirect',
|
|
840
840
|
})}`;
|
|
841
841
|
}
|
|
842
842
|
return this.wxAppLoginInstance.doLogin(getParams).then((res) => {
|
|
843
843
|
console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
|
|
844
844
|
setTimeout(() => {
|
|
845
845
|
console.log('微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie');
|
|
846
846
|
this.getLoginCookie(`${Date.now()}`);
|
|
847
847
|
}, 500);
|
|
848
848
|
return res;
|
|
849
849
|
});
|
|
850
850
|
}
|
|
851
851
|
|
|
852
852
|
doLoginForJdPin(options = {}) {
|
|
853
853
|
return this.doLogin({
|
|
854
854
|
loginColor: {
|
|
855
855
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
856
856
|
dpin: 0,
|
|
857
857
|
},
|
|
858
858
|
...options,
|
|
859
859
|
});
|
|
860
860
|
}
|
|
861
861
|
|
|
862
862
|
getLoginCookie(updateKey = 'wxapp') {
|
|
863
863
|
return new Promise(async (resolve) => {
|
|
864
864
|
console.log('开始获取更新wxapp中的cookie信息', updateKey);
|
|
865
865
|
if (
|
|
866
866
|
this.config.wqCookie &&
|
|
867
867
|
this.config.wqCookieStr &&
|
|
868
868
|
this.config.getWqCookieKey === updateKey
|
|
869
869
|
) {
|
|
870
870
|
console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
|
|
871
871
|
resolve({
|
|
872
872
|
wqCookie: this.config.wqCookie,
|
|
873
873
|
wqCookieStr: this.config.wqCookieStr,
|
|
874
874
|
});
|
|
875
875
|
} else {
|
|
876
876
|
if (isPublishToWxapp) {
|
|
877
877
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
|
|
878
878
|
if (getWxappCookieObj) {
|
|
879
879
|
const getCookieObj = getWxappCookieObj['_data'];
|
|
880
880
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
|
|
881
881
|
const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
|
|
882
882
|
this.info.loginState = true;
|
|
883
883
|
this.info.userInfo.wqCookie = wqCookieStr;
|
|
884
884
|
this.info.userInfo.wqVisitkey = visitkey;
|
|
885
885
|
console.log('获取用户完整cookie信息', getCookieObj);
|
|
886
886
|
if (this.miniAppLogInstance) {
|
|
887
887
|
this.miniAppLogInstance.set({
|
|
888
888
|
account: pin,
|
|
889
889
|
unionid: wq_unionid,
|
|
890
890
|
openid: wxapp_openid,
|
|
891
891
|
});
|
|
892
892
|
}
|
|
893
893
|
this.config.wqCookie = wqCookie;
|
|
894
894
|
this.config.wqCookieStr = wqCookieStr;
|
|
895
895
|
this.config.getWqCookieKey = updateKey;
|
|
896
896
|
console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
|
|
897
897
|
resolve({
|
|
898
898
|
wqCookie,
|
|
899
899
|
wqCookieStr,
|
|
900
900
|
});
|
|
901
901
|
} else {
|
|
902
902
|
console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
|
|
903
903
|
resolve({
|
|
904
904
|
wqCookie: false,
|
|
905
905
|
wqCookieStr: false,
|
|
906
906
|
});
|
|
907
907
|
}
|
|
908
908
|
} else {
|
|
909
909
|
resolve({
|
|
910
910
|
wqCookie: false,
|
|
911
911
|
wqCookieStr: false,
|
|
912
912
|
});
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
});
|
|
916
916
|
}
|
|
917
917
|
|
|
918
918
|
|
|
919
919
|
checkLoginStatus() {
|
|
920
920
|
return this.getLoginCookie();
|
|
921
921
|
}
|
|
922
922
|
|
|
923
923
|
getAddressCachePromise = () => {
|
|
924
924
|
return new Promise((resolve) => {
|
|
925
925
|
if (this.info.sysInfo?.area) {
|
|
926
926
|
resolve({
|
|
927
927
|
lat: this.info.sysInfo?.lat,
|
|
928
928
|
lng: this.info.sysInfo?.lng,
|
|
929
929
|
area: this.info.sysInfo?.area,
|
|
930
930
|
});
|
|
931
931
|
} else {
|
|
932
932
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress();
|
|
933
933
|
console.info('京购原生获取用户基地址信息', getUserAddress);
|
|
934
934
|
if (getUserAddress) {
|
|
935
935
|
const { areaId = '', latitude, longitude } = getUserAddress;
|
|
936
936
|
this.info.sysInfo['lat'] = `${latitude || ''}`;
|
|
937
937
|
this.info.sysInfo['lng'] = `${longitude || ''}`;
|
|
938
938
|
if (areaId && areaId !== '') {
|
|
939
939
|
this.info.pageInfo.address = areaId;
|
|
940
940
|
this.info.pageInfo.addressCommaStr = areaId.replace(/_/g, ',');
|
|
941
941
|
this.info.pageInfo.un_area = areaId;
|
|
942
942
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
943
943
|
area: areaId,
|
|
944
944
|
});
|
|
945
945
|
this.info.sysInfo['area'] = areaId;
|
|
946
946
|
}
|
|
947
947
|
resolve({
|
|
948
948
|
lat: this.info.sysInfo['lat'],
|
|
949
949
|
lng: this.info.sysInfo['lng'],
|
|
950
950
|
area: areaId,
|
|
951
951
|
});
|
|
952
952
|
} else {
|
|
953
953
|
resolve({ lat: '', lng: '', area: '' });
|
|
954
954
|
}
|
|
955
955
|
}
|
|
956
956
|
});
|
|
957
957
|
};
|
|
958
958
|
|
|
959
959
|
getLbsAddressCachePromise(): Promise<{
|
|
960
960
|
ok: boolean;
|
|
961
961
|
msg?: string;
|
|
962
962
|
realTimeArea: string;
|
|
963
963
|
data?: any;
|
|
964
964
|
}> {
|
|
965
965
|
if (!this.lbsAddressCachePromise) {
|
|
966
966
|
this.lbsAddressCachePromise = new Promise((resolve) => {
|
|
967
967
|
const getWxappLbsAddressInfo = this.wxAppUserInfoInstance.getLbsAddress();
|
|
968
968
|
console.info('京购原生获取用户基于lbs的缓存地址信息', getWxappLbsAddressInfo);
|
|
969
969
|
if (getWxappLbsAddressInfo && getWxappLbsAddressInfo?.areaId !== '') {
|
|
970
970
|
this.info.pageInfo.userLbsAddress = getWxappLbsAddressInfo?.areaId;
|
|
971
971
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
972
972
|
realTimeArea: this.info.pageInfo.userLbsAddress,
|
|
973
973
|
});
|
|
974
974
|
resolve({
|
|
975
975
|
ok: true,
|
|
976
976
|
realTimeArea: getWxappLbsAddressInfo?.areaId || '',
|
|
977
977
|
});
|
|
978
978
|
} else {
|
|
979
979
|
this.wxAppAddressV2apiInstance
|
|
980
980
|
.fetchLbsAddr({
|
|
981
981
|
token: 'W23b9sUlcnhCPZxQ2daYMkDqrTL0TeDw9tbDm5lVMVA=',
|
|
982
982
|
from: 'wxapp_shop_real_area',
|
|
983
983
|
})
|
|
984
984
|
.then((res) => {
|
|
985
985
|
console.info('微信京购里面获取静默实时lbs地址信息结果', res);
|
|
986
986
|
const { provinceId, cityId, countyId, townId } = res;
|
|
987
987
|
let realTimeArea = '';
|
|
988
988
|
if (provinceId) {
|
|
989
989
|
realTimeArea = `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
|
|
990
990
|
this.info.pageInfo.userLbsAddress = realTimeArea;
|
|
991
991
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
992
992
|
realTimeArea: realTimeArea,
|
|
993
993
|
});
|
|
994
994
|
} else {
|
|
995
995
|
this.lbsAddressCachePromise = null;
|
|
996
996
|
}
|
|
997
997
|
const getValidRealTimeArea = realTimeArea !== '';
|
|
998
998
|
resolve({
|
|
999
999
|
ok: getValidRealTimeArea,
|
|
1000
1000
|
msg: getValidRealTimeArea
|
|
1001
1001
|
? '成功'
|
|
1002
1002
|
: '根据微信底层接口获取静默实时lbs地址信息异常,详情见data',
|
|
1003
1003
|
data: getValidRealTimeArea ? null : res,
|
|
1004
1004
|
realTimeArea: realTimeArea,
|
|
1005
1005
|
});
|
|
1006
1006
|
})
|
|
1007
1007
|
.catch((err) => {
|
|
1008
1008
|
console.warn('微信京购里面获取静默实时lbs地址信息异常', err);
|
|
1009
1009
|
this.lbsAddressCachePromise = null;
|
|
1010
1010
|
resolve({
|
|
1011
1011
|
ok: false,
|
|
1012
1012
|
msg: '微信京购里面获取静默实时lbs地址信息异常',
|
|
1013
1013
|
realTimeArea: '',
|
|
1014
1014
|
});
|
|
1015
1015
|
});
|
|
1016
1016
|
}
|
|
1017
1017
|
});
|
|
1018
1018
|
}
|
|
1019
1019
|
return this.lbsAddressCachePromise;
|
|
1020
1020
|
}
|
|
1021
1021
|
|
|
1022
1022
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
1023
1023
|
const createUpdateQueryInfo: {
|
|
1024
1024
|
query: {
|
|
1025
1025
|
shopId?: string | number;
|
|
1026
1026
|
venderId?: string | number;
|
|
1027
1027
|
};
|
|
1028
1028
|
updateShopInfoState: boolean;
|
|
1029
1029
|
} = Object.assign(
|
|
1030
1030
|
{},
|
|
1031
1031
|
{
|
|
1032
1032
|
query: {},
|
|
1033
1033
|
updateShopInfoState: false,
|
|
1034
1034
|
},
|
|
1035
1035
|
updateQuery,
|
|
1036
1036
|
);
|
|
1037
1037
|
console.log(
|
|
1038
1038
|
'获取当前下发的店铺查询参数',
|
|
1039
1039
|
updateQuery,
|
|
1040
1040
|
'获取之前保存的shopInfo店铺查询参数',
|
|
1041
1041
|
this.info?.shopInfo,
|
|
1042
1042
|
);
|
|
1043
1043
|
const { query, updateShopInfoState } = createUpdateQueryInfo;
|
|
1044
1044
|
const { shopId, venderId } = query;
|
|
1045
1045
|
if (updateShopInfoState) {
|
|
1046
1046
|
this.info.queryInfo = {
|
|
1047
1047
|
...this.info.queryInfo,
|
|
1048
1048
|
...query,
|
|
1049
1049
|
};
|
|
1050
1050
|
if (shopId && venderId) {
|
|
1051
1051
|
this.info.shopInfo = {
|
|
1052
1052
|
shopId: `${shopId}`,
|
|
1053
1053
|
venderId: `${venderId}`,
|
|
1054
1054
|
};
|
|
1055
1055
|
}
|
|
1056
1056
|
} else {
|
|
1057
1057
|
this.info.queryInfo = {
|
|
1058
1058
|
...query,
|
|
1059
1059
|
};
|
|
1060
1060
|
this.info.originQueryInfo = {
|
|
1061
1061
|
...query,
|
|
1062
1062
|
};
|
|
1063
1063
|
if (
|
|
1064
1064
|
this.info.shopInfo?.shopId &&
|
|
1065
1065
|
this.info.shopInfo?.venderId &&
|
|
1066
1066
|
(this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
|
|
1067
1067
|
) {
|
|
1068
1068
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId;
|
|
1069
1069
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId;
|
|
1070
1070
|
console.log(
|
|
1071
1071
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
1072
1072
|
this.info.queryInfo,
|
|
1073
1073
|
);
|
|
1074
1074
|
}
|
|
1075
1075
|
}
|
|
1076
1076
|
this.info.queryInfo['shopId'] &&
|
|
1077
1077
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
|
|
1078
1078
|
this.info.queryInfo['venderId'] &&
|
|
1079
1079
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
|
|
1080
1080
|
console.log(
|
|
1081
1081
|
'weapp===获取店铺下发查询参数\n',
|
|
1082
1082
|
query,
|
|
1083
1083
|
'\n获取店铺最后查询参数\n',
|
|
1084
1084
|
this.info.queryInfo,
|
|
1085
1085
|
'\n是否为更新店铺状态\n',
|
|
1086
1086
|
updateShopInfoState,
|
|
1087
1087
|
);
|
|
1088
1088
|
}
|
|
1089
1089
|
|
|
1090
1090
|
getDynamicConfig(key: string) {
|
|
1091
1091
|
console.warn('调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!');
|
|
1092
1092
|
return null;
|
|
1093
1093
|
}
|
|
1094
1094
|
renderNextTickLoadSdk() {
|
|
1095
1095
|
console.warn('暂未实现 index.weapp.ts');
|
|
1096
1096
|
}
|
|
1097
1097
|
loadOtherSdk() {
|
|
1098
1098
|
console.warn('暂未实现 index.weapp.ts');
|
|
1099
1099
|
}
|
|
1100
1100
|
loadItemSdkPromise() {
|
|
1101
1101
|
console.warn('暂未实现 index.weapp.ts');
|
|
1102
1102
|
}
|
|
1103
1103
|
createLanguageProimse() {
|
|
1104
1104
|
return Promise.reject({
|
|
1105
1105
|
msg: '暂未实现',
|
|
1106
1106
|
});
|
|
1107
1107
|
}
|