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