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