@conecli/cone-render 0.10.1-shop3.76 → 0.10.1-shop3.79
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/interface/common.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.pc.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/utils.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
|
baseAddCartSwitch: true,
|
|
592
592
|
pageInfo: {
|
|
593
593
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
594
594
|
address: '',
|
|
595
595
|
addressCommaStr: '',
|
|
596
596
|
un_area: '',
|
|
597
597
|
userLbsAddress: '',
|
|
598
598
|
vapptype: '1',
|
|
599
599
|
pageType: 'home',
|
|
600
600
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
601
601
|
floorExposureInfo: {},
|
|
602
602
|
floorVideInfo: {},
|
|
603
603
|
productVideInfo: {},
|
|
604
604
|
tabsLoadAllDataInfo: {
|
|
605
605
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
|
|
606
606
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
607
607
|
},
|
|
608
608
|
updateShopInfosAllState: false,
|
|
609
609
|
isVipShop: false,
|
|
610
610
|
isJdShowNativeImmersivePlayer: false,
|
|
611
611
|
isSuperBrandShop: false,
|
|
612
612
|
...shopConfig,
|
|
613
613
|
pageScrollTop: 0,
|
|
614
614
|
pageIdxHeightInfo: {
|
|
615
615
|
list: [],
|
|
616
616
|
},
|
|
617
617
|
shopNavBarHeight: 0,
|
|
618
618
|
},
|
|
619
619
|
defaultQueryLogInfo: {
|
|
620
620
|
sourceType: 'JDshop',
|
|
621
621
|
sourceValue: '',
|
|
622
622
|
moduleId: 'none',
|
|
623
623
|
entrance: 'none',
|
|
624
624
|
},
|
|
625
625
|
originQueryInfo: {},
|
|
626
626
|
sysInfo: {
|
|
627
627
|
windowWidth: 0,
|
|
628
628
|
windowHeight: 0,
|
|
629
629
|
netWorkType: '4g',
|
|
630
630
|
jdBottomBarHeight: 0,
|
|
631
631
|
jdNativeHeaderHeight: 0,
|
|
632
632
|
},
|
|
633
633
|
queryInfo: {},
|
|
634
634
|
shopInfo: {},
|
|
635
635
|
openAppData: {},
|
|
636
636
|
public info: CommonInterFace.BaseConfigInfo;
|
|
637
637
|
public config: {
|
|
638
638
|
[key: string]: any;
|
|
639
639
|
};
|
|
640
640
|
public lazyContainer: CommonInterFace.lazyContainer;
|
|
641
641
|
public rootEleNode: HTMLElement | null;
|
|
642
642
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil;
|
|
643
643
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
|
|
644
644
|
public checkStatusAndLoginPromise: object | null;
|
|
645
645
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin;
|
|
646
646
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
|
|
647
647
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
|
|
648
648
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
|
|
649
649
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
|
|
650
650
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
|
|
651
651
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
|
|
652
652
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
|
|
653
653
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
|
|
654
654
|
public wxAppAddressV2apiInstance: CommonInterFace.wxAppAddressV2api;
|
|
655
655
|
public loadJsSdkList: Array<any>;
|
|
656
656
|
public loadJsSdkListCachePromise: any;
|
|
657
657
|
public lbsAddressCachePromise: Promise<any> | null;
|
|
658
658
|
public languageJsonData: any | null;
|
|
659
659
|
public businessWorkerReady: boolean;
|
|
660
660
|
public jdWorkerReadyPromise: any | null;
|
|
661
661
|
constructor(opt) {
|
|
662
662
|
this.info = this._getConfig(opt);
|
|
663
663
|
this.config = {};
|
|
664
664
|
this.lazyContainer = {
|
|
665
665
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
666
666
|
appLazyContainerList: [],
|
|
667
667
|
appLazyFinishContainerList: [],
|
|
668
668
|
},
|
|
669
669
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
670
670
|
appLazyContainerList: [],
|
|
671
671
|
appLazyFinishContainerList: [],
|
|
672
672
|
},
|
|
673
673
|
};
|
|
674
674
|
this.loadJsSdkList = [];
|
|
675
675
|
this.loadJsSdkListCachePromise = {};
|
|
676
676
|
this.rootEleNode = null;
|
|
677
677
|
this.miniApplogUtil = MiniAppLogUtil;
|
|
678
678
|
this.miniAppLogInstance = null;
|
|
679
679
|
this.checkStatusAndLoginPromise = null;
|
|
680
680
|
this.wxAppLoginInstance = WXAPP_LOGIN;
|
|
681
681
|
this.wxAppBizInstance = WXAPP_BIZ;
|
|
682
682
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO;
|
|
683
683
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
|
|
684
684
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
|
|
685
685
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
|
|
686
686
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
|
|
687
687
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT ? new WXAPP_FINGER_REPORT() : {};
|
|
688
688
|
this.wxAppSubsGuider = WXAPP_SUBS_GUIDER;
|
|
689
689
|
this.wxAppAddressV2apiInstance = WXAPP_ADDRESS_V2_API;
|
|
690
690
|
this.lbsAddressCachePromise = null;
|
|
691
691
|
this.languageJsonData = langeJsonDataForCn;
|
|
692
692
|
this.businessWorkerReady = false;
|
|
693
693
|
this.jdWorkerReadyPromise = Promise.resolve(false);
|
|
694
694
|
}
|
|
695
695
|
_getConfig(opt) {
|
|
696
696
|
return Object.assign({}, DefaultConfig, opt);
|
|
697
697
|
}
|
|
698
698
|
loadApiSafeSteadyReayPromise() {
|
|
699
699
|
return Promise.resolve(true);
|
|
700
700
|
}
|
|
701
701
|
loadH5tagReayPromise() {
|
|
702
702
|
return Promise.resolve(true);
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
jmfeReayPromise(): Promise<any> {
|
|
706
706
|
return Promise.reject(false);
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
710
710
|
return new Promise((resolve) => {
|
|
711
711
|
setTimeout(() => {
|
|
712
712
|
const getCallBackRes = typeof callBack === 'function' && callBack();
|
|
713
713
|
return resolve(getCallBackRes || false);
|
|
714
714
|
}, timeout);
|
|
715
715
|
});
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
updateBusinessDomainAndApi(domain, api) {
|
|
719
719
|
console.log('=================>', 'updateBusinessDomainAndApi');
|
|
720
720
|
}
|
|
721
721
|
|
|
722
722
|
getFullScreenHeight(systemInfo) {
|
|
723
723
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
|
|
724
724
|
let result = screenHeight;
|
|
725
725
|
if (statusBarHeight > 20 && isAndroid) {
|
|
726
726
|
result = screenHeight + statusBarHeight;
|
|
727
727
|
}
|
|
728
728
|
return result;
|
|
729
729
|
}
|
|
730
730
|
|
|
731
731
|
getTabBarHeight(systemInfo) {
|
|
732
732
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo;
|
|
733
733
|
let result = 50;
|
|
734
734
|
if (statusBarHeight > 20) {
|
|
735
735
|
if (isIOS) {
|
|
736
736
|
result = 84;
|
|
737
737
|
} else if (isAndroid) {
|
|
738
738
|
result = 53;
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
return result;
|
|
742
742
|
}
|
|
743
743
|
|
|
744
744
|
getSystemInfo() {
|
|
745
745
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
|
|
746
746
|
const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
|
|
747
747
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
|
|
748
748
|
const fullScreenHeight = this.getFullScreenHeight(info);
|
|
749
749
|
const tabBarHeight = this.getTabBarHeight(info);
|
|
750
750
|
const safeContentHeight = fullScreenHeight - headerHeight;
|
|
751
751
|
this.info.sysInfo = {
|
|
752
752
|
...this.info.sysInfo,
|
|
753
753
|
...info,
|
|
754
754
|
actualNavBarHeight,
|
|
755
755
|
headerHeight,
|
|
756
756
|
fullScreenHeight,
|
|
757
757
|
tabBarHeight,
|
|
758
758
|
safeContentHeight,
|
|
759
759
|
languageType: languageNowType,
|
|
760
760
|
};
|
|
761
761
|
if (this.info.sysInfo['hostVersionName']) {
|
|
762
762
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
763
763
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
764
764
|
);
|
|
765
765
|
}
|
|
766
766
|
if (isPublishToWxapp) {
|
|
767
767
|
this.getAddressCachePromise();
|
|
768
768
|
this.getLbsAddressCachePromise();
|
|
769
769
|
}
|
|
770
770
|
this.info.sysInfo['wifiVideoAutoPlay'] = false;
|
|
771
771
|
this.getNetWorkType();
|
|
772
772
|
console.log('获取系统信息', this.info.sysInfo);
|
|
773
773
|
}
|
|
774
774
|
async updateMPaasConfig() {}
|
|
775
775
|
|
|
776
776
|
getNetWorkType() {
|
|
777
777
|
Taro.getNetworkType().then((getRes) => {
|
|
778
778
|
getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
|
|
779
779
|
});
|
|
780
780
|
}
|
|
781
781
|
getAPPUseStraightCorner() {
|
|
782
782
|
return Promise.resolve(false);
|
|
783
783
|
}
|
|
784
784
|
|
|
785
785
|
checkStatusAndLogin(options = {}) {
|
|
786
786
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
787
787
|
console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
|
|
788
788
|
this.toLogin(options)
|
|
789
789
|
.then((res) => {
|
|
790
790
|
console.log('微信小程序登录状态结果,成功', res);
|
|
791
791
|
this.info.loginState = true;
|
|
792
792
|
resolve(res);
|
|
793
793
|
})
|
|
794
794
|
.catch((err) => {
|
|
795
795
|
console.log('微信小程序登录异常状态结果', err);
|
|
796
796
|
this.doLogin(options)
|
|
797
797
|
.then((res2) => {
|
|
798
798
|
console.log('微信小程序wxDoLogin强制登陆成功:', res2);
|
|
799
799
|
this.info.loginState = true;
|
|
800
800
|
resolve(res2);
|
|
801
801
|
})
|
|
802
802
|
.catch((err2) => {
|
|
803
803
|
console.log('微信小程序wxDoLogin强制登陆失败:', err2);
|
|
804
804
|
this.checkStatusAndLoginPromise = null;
|
|
805
805
|
reject(err2);
|
|
806
806
|
});
|
|
807
807
|
});
|
|
808
808
|
});
|
|
809
809
|
return this.checkStatusAndLoginPromise;
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
checkJdStatusAndLogin(
|
|
813
813
|
options = {
|
|
814
814
|
loginColor: {
|
|
815
815
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
816
816
|
dpin: 0,
|
|
817
817
|
},
|
|
818
818
|
},
|
|
819
819
|
) {
|
|
820
820
|
return this.checkStatusAndLogin(options);
|
|
821
821
|
}
|
|
822
822
|
|
|
823
823
|
toLogin(options = {}): Promise<any> {
|
|
824
824
|
return this.wxAppLoginInstance
|
|
825
825
|
.getLoginPromise({
|
|
826
826
|
mode: 'common',
|
|
827
827
|
loginColor: {
|
|
828
828
|
biz: WXAPP_BIZ_KEY,
|
|
829
829
|
dpin: 1,
|
|
830
830
|
},
|
|
831
831
|
...options,
|
|
832
832
|
})
|
|
833
833
|
.then((res) => {
|
|
834
834
|
console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
|
|
835
835
|
setTimeout(() => {
|
|
836
836
|
console.log(
|
|
837
837
|
'微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
838
838
|
);
|
|
839
839
|
this.getLoginCookie(`${Date.now()}`);
|
|
840
840
|
}, 500);
|
|
841
841
|
})
|
|
842
842
|
.catch((err) => {
|
|
843
843
|
console.log('微信app登录异常返回信息,也获取cookie', err);
|
|
844
844
|
this.getLoginCookie(`${Date.now()}`);
|
|
845
845
|
});
|
|
846
846
|
}
|
|
847
847
|
|
|
848
848
|
doLogin(options = {}) {
|
|
849
849
|
const getParams = {
|
|
850
850
|
loginColor: {
|
|
851
851
|
biz: WXAPP_BIZ_KEY,
|
|
852
852
|
dpin: 1,
|
|
853
853
|
},
|
|
854
854
|
...options,
|
|
855
855
|
};
|
|
856
856
|
if (isPublishToWxapp) {
|
|
857
857
|
getParams['returnUrl'] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
858
858
|
...this.info.originQueryInfo,
|
|
859
859
|
loadShopxType: 'redirect',
|
|
860
860
|
})}`;
|
|
861
861
|
}
|
|
862
862
|
return this.wxAppLoginInstance.doLogin(getParams).then((res) => {
|
|
863
863
|
console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
|
|
864
864
|
setTimeout(() => {
|
|
865
865
|
console.log('微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie');
|
|
866
866
|
this.getLoginCookie(`${Date.now()}`);
|
|
867
867
|
}, 500);
|
|
868
868
|
return res;
|
|
869
869
|
});
|
|
870
870
|
}
|
|
871
871
|
|
|
872
872
|
doLoginForJdPin(options = {}) {
|
|
873
873
|
return this.doLogin({
|
|
874
874
|
loginColor: {
|
|
875
875
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
876
876
|
dpin: 0,
|
|
877
877
|
},
|
|
878
878
|
...options,
|
|
879
879
|
});
|
|
880
880
|
}
|
|
881
881
|
|
|
882
882
|
getLoginCookie(updateKey = 'wxapp') {
|
|
883
883
|
return new Promise(async (resolve) => {
|
|
884
884
|
console.log('开始获取更新wxapp中的cookie信息', updateKey);
|
|
885
885
|
if (
|
|
886
886
|
this.config.wqCookie &&
|
|
887
887
|
this.config.wqCookieStr &&
|
|
888
888
|
this.config.getWqCookieKey === updateKey
|
|
889
889
|
) {
|
|
890
890
|
console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
|
|
891
891
|
resolve({
|
|
892
892
|
wqCookie: this.config.wqCookie,
|
|
893
893
|
wqCookieStr: this.config.wqCookieStr,
|
|
894
894
|
});
|
|
895
895
|
} else {
|
|
896
896
|
if (isPublishToWxapp) {
|
|
897
897
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
|
|
898
898
|
if (getWxappCookieObj) {
|
|
899
899
|
const getCookieObj = getWxappCookieObj['_data'];
|
|
900
900
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
|
|
901
901
|
const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
|
|
902
902
|
this.info.loginState = true;
|
|
903
903
|
this.info.userInfo.wqCookie = wqCookieStr;
|
|
904
904
|
this.info.userInfo.wqVisitkey = visitkey;
|
|
905
905
|
console.log('获取用户完整cookie信息', getCookieObj);
|
|
906
906
|
if (this.miniAppLogInstance) {
|
|
907
907
|
this.miniAppLogInstance.set({
|
|
908
908
|
account: pin,
|
|
909
909
|
unionid: wq_unionid,
|
|
910
910
|
openid: wxapp_openid,
|
|
911
911
|
});
|
|
912
912
|
}
|
|
913
913
|
this.config.wqCookie = wqCookie;
|
|
914
914
|
this.config.wqCookieStr = wqCookieStr;
|
|
915
915
|
this.config.getWqCookieKey = updateKey;
|
|
916
916
|
console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
|
|
917
917
|
resolve({
|
|
918
918
|
wqCookie,
|
|
919
919
|
wqCookieStr,
|
|
920
920
|
});
|
|
921
921
|
} else {
|
|
922
922
|
console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
|
|
923
923
|
resolve({
|
|
924
924
|
wqCookie: false,
|
|
925
925
|
wqCookieStr: false,
|
|
926
926
|
});
|
|
927
927
|
}
|
|
928
928
|
} else {
|
|
929
929
|
resolve({
|
|
930
930
|
wqCookie: false,
|
|
931
931
|
wqCookieStr: false,
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
934
|
}
|
|
935
935
|
});
|
|
936
936
|
}
|
|
937
937
|
|
|
938
938
|
|
|
939
939
|
checkLoginStatus() {
|
|
940
940
|
return this.getLoginCookie();
|
|
941
941
|
}
|
|
942
942
|
|
|
943
943
|
getAddressCachePromise = () => {
|
|
944
944
|
return new Promise((resolve) => {
|
|
945
945
|
if (this.info.sysInfo?.area) {
|
|
946
946
|
resolve({
|
|
947
947
|
lat: this.info.sysInfo?.lat,
|
|
948
948
|
lng: this.info.sysInfo?.lng,
|
|
949
949
|
area: this.info.sysInfo?.area,
|
|
950
950
|
});
|
|
951
951
|
} else {
|
|
952
952
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress();
|
|
953
953
|
console.info('京购原生获取用户基地址信息', getUserAddress);
|
|
954
954
|
if (getUserAddress) {
|
|
955
955
|
const { areaId = '', latitude, longitude } = getUserAddress;
|
|
956
956
|
this.info.sysInfo['lat'] = `${latitude || ''}`;
|
|
957
957
|
this.info.sysInfo['lng'] = `${longitude || ''}`;
|
|
958
958
|
if (areaId && areaId !== '') {
|
|
959
959
|
this.info.pageInfo.address = areaId;
|
|
960
960
|
this.info.pageInfo.addressCommaStr = areaId.replace(/_/g, ',');
|
|
961
961
|
this.info.pageInfo.un_area = areaId;
|
|
962
962
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
963
963
|
area: areaId,
|
|
964
964
|
});
|
|
965
965
|
this.info.sysInfo['area'] = areaId;
|
|
966
966
|
}
|
|
967
967
|
resolve({
|
|
968
968
|
lat: this.info.sysInfo['lat'],
|
|
969
969
|
lng: this.info.sysInfo['lng'],
|
|
970
970
|
area: areaId,
|
|
971
971
|
});
|
|
972
972
|
} else {
|
|
973
973
|
resolve({ lat: '', lng: '', area: '' });
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
976
|
});
|
|
977
977
|
};
|
|
978
978
|
|
|
979
979
|
getLbsAddressCachePromise(): Promise<{
|
|
980
980
|
ok: boolean;
|
|
981
981
|
msg?: string;
|
|
982
982
|
realTimeArea: string;
|
|
983
983
|
data?: any;
|
|
984
984
|
}> {
|
|
985
985
|
if (!this.lbsAddressCachePromise) {
|
|
986
986
|
this.lbsAddressCachePromise = new Promise((resolve) => {
|
|
987
987
|
const getWxappLbsAddressInfo = this.wxAppUserInfoInstance.getLbsAddress();
|
|
988
988
|
console.info('京购原生获取用户基于lbs的缓存地址信息', getWxappLbsAddressInfo);
|
|
989
989
|
if (getWxappLbsAddressInfo && getWxappLbsAddressInfo?.areaId !== '') {
|
|
990
990
|
this.info.pageInfo.userLbsAddress = getWxappLbsAddressInfo?.areaId;
|
|
991
991
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
992
992
|
realTimeArea: this.info.pageInfo.userLbsAddress,
|
|
993
993
|
});
|
|
994
994
|
resolve({
|
|
995
995
|
ok: true,
|
|
996
996
|
realTimeArea: getWxappLbsAddressInfo?.areaId || '',
|
|
997
997
|
});
|
|
998
998
|
} else {
|
|
999
999
|
this.wxAppAddressV2apiInstance
|
|
1000
1000
|
.fetchLbsAddr({
|
|
1001
1001
|
token: 'W23b9sUlcnhCPZxQ2daYMkDqrTL0TeDw9tbDm5lVMVA=',
|
|
1002
1002
|
from: 'wxapp_shop_real_area',
|
|
1003
1003
|
})
|
|
1004
1004
|
.then((res) => {
|
|
1005
1005
|
console.info('微信京购里面获取静默实时lbs地址信息结果', res);
|
|
1006
1006
|
const { provinceId, cityId, countyId, townId } = res;
|
|
1007
1007
|
let realTimeArea = '';
|
|
1008
1008
|
if (provinceId) {
|
|
1009
1009
|
realTimeArea = `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
|
|
1010
1010
|
this.info.pageInfo.userLbsAddress = realTimeArea;
|
|
1011
1011
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
1012
1012
|
realTimeArea: realTimeArea,
|
|
1013
1013
|
});
|
|
1014
1014
|
} else {
|
|
1015
1015
|
this.lbsAddressCachePromise = null;
|
|
1016
1016
|
}
|
|
1017
1017
|
const getValidRealTimeArea = realTimeArea !== '';
|
|
1018
1018
|
resolve({
|
|
1019
1019
|
ok: getValidRealTimeArea,
|
|
1020
1020
|
msg: getValidRealTimeArea
|
|
1021
1021
|
? '成功'
|
|
1022
1022
|
: '根据微信底层接口获取静默实时lbs地址信息异常,详情见data',
|
|
1023
1023
|
data: getValidRealTimeArea ? null : res,
|
|
1024
1024
|
realTimeArea: realTimeArea,
|
|
1025
1025
|
});
|
|
1026
1026
|
})
|
|
1027
1027
|
.catch((err) => {
|
|
1028
1028
|
console.warn('微信京购里面获取静默实时lbs地址信息异常', err);
|
|
1029
1029
|
this.lbsAddressCachePromise = null;
|
|
1030
1030
|
resolve({
|
|
1031
1031
|
ok: false,
|
|
1032
1032
|
msg: '微信京购里面获取静默实时lbs地址信息异常',
|
|
1033
1033
|
realTimeArea: '',
|
|
1034
1034
|
});
|
|
1035
1035
|
});
|
|
1036
1036
|
}
|
|
1037
1037
|
});
|
|
1038
1038
|
}
|
|
1039
1039
|
return this.lbsAddressCachePromise;
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
1042
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
1043
1043
|
const createUpdateQueryInfo: {
|
|
1044
1044
|
query: {
|
|
1045
1045
|
shopId?: string | number;
|
|
1046
1046
|
venderId?: string | number;
|
|
1047
1047
|
};
|
|
1048
1048
|
updateShopInfoState: boolean;
|
|
1049
1049
|
} = Object.assign(
|
|
1050
1050
|
{},
|
|
1051
1051
|
{
|
|
1052
1052
|
query: {},
|
|
1053
1053
|
updateShopInfoState: false,
|
|
1054
1054
|
},
|
|
1055
1055
|
updateQuery,
|
|
1056
1056
|
);
|
|
1057
1057
|
console.log(
|
|
1058
1058
|
'获取当前下发的店铺查询参数',
|
|
1059
1059
|
updateQuery,
|
|
1060
1060
|
'获取之前保存的shopInfo店铺查询参数',
|
|
1061
1061
|
this.info?.shopInfo,
|
|
1062
1062
|
);
|
|
1063
1063
|
const { query, updateShopInfoState } = createUpdateQueryInfo;
|
|
1064
1064
|
const { shopId, venderId } = query;
|
|
1065
1065
|
if (updateShopInfoState) {
|
|
1066
1066
|
this.info.queryInfo = {
|
|
1067
1067
|
...this.info.queryInfo,
|
|
1068
1068
|
...query,
|
|
1069
1069
|
};
|
|
1070
1070
|
if (shopId && venderId) {
|
|
1071
1071
|
this.info.shopInfo = {
|
|
1072
1072
|
shopId: `${shopId}`,
|
|
1073
1073
|
venderId: `${venderId}`,
|
|
1074
1074
|
};
|
|
1075
1075
|
}
|
|
1076
1076
|
} else {
|
|
1077
1077
|
this.info.queryInfo = {
|
|
1078
1078
|
...query,
|
|
1079
1079
|
};
|
|
1080
1080
|
this.info.originQueryInfo = {
|
|
1081
1081
|
...query,
|
|
1082
1082
|
};
|
|
1083
1083
|
if (
|
|
1084
1084
|
this.info.shopInfo?.shopId &&
|
|
1085
1085
|
this.info.shopInfo?.venderId &&
|
|
1086
1086
|
(this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
|
|
1087
1087
|
) {
|
|
1088
1088
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId;
|
|
1089
1089
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId;
|
|
1090
1090
|
console.log(
|
|
1091
1091
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
1092
1092
|
this.info.queryInfo,
|
|
1093
1093
|
);
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
this.info.queryInfo['shopId'] &&
|
|
1097
1097
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
|
|
1098
1098
|
this.info.queryInfo['venderId'] &&
|
|
1099
1099
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
|
|
1100
1100
|
console.log(
|
|
1101
1101
|
'weapp===获取店铺下发查询参数\n',
|
|
1102
1102
|
query,
|
|
1103
1103
|
'\n获取店铺最后查询参数\n',
|
|
1104
1104
|
this.info.queryInfo,
|
|
1105
1105
|
'\n是否为更新店铺状态\n',
|
|
1106
1106
|
updateShopInfoState,
|
|
1107
1107
|
);
|
|
1108
1108
|
}
|
|
1109
1109
|
|
|
1110
1110
|
getDynamicConfig(key: string) {
|
|
1111
1111
|
console.warn('调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!');
|
|
1112
1112
|
return null;
|
|
1113
1113
|
}
|
|
1114
1114
|
renderNextTickLoadSdk() {
|
|
1115
1115
|
console.warn('暂未实现 index.weapp.ts');
|
|
1116
1116
|
}
|
|
1117
1117
|
loadOtherSdk() {
|
|
1118
1118
|
console.warn('暂未实现 index.weapp.ts');
|
|
1119
1119
|
}
|
|
1120
1120
|
loadItemSdkPromise() {
|
|
1121
1121
|
console.warn('暂未实现 index.weapp.ts');
|
|
1122
1122
|
}
|
|
1123
1123
|
createLanguageProimse() {
|
|
1124
1124
|
return Promise.reject({
|
|
1125
1125
|
msg: '暂未实现',
|
|
1126
1126
|
});
|
|
1127
1127
|
}
|