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