@conecli/cone-render 0.10.1-shop3.136 → 0.10.1-shop3.138

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