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