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