@conecli/cone-render 0.10.1-shop3.121 → 0.10.1-shop3.123

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