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

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
  BUSINESS_TYPE,
9
8
  SHOP_MENU_ID_TYPE,
10
9
  SHOP_MENU_ID_NAME,
11
10
  SECTION_HOME_TAB_NAME_TYPE,
12
11
  SECTION_HOME_TAB_TYPE,
13
12
  WXAPP_BIZ_KEY,
14
13
  WX_BUSINESS_TYPE,
15
14
  TaroEventType,
16
15
  getSystemInfos,
17
16
  getTaroStorageKeyValue,
18
17
  getWxAppCookieStr,
19
18
  languageNowType,
20
19
  accessibilityRunning: false,
21
20
  abTestLabels: {},
22
21
  nonSellableSkuids: {},
23
22
  loginState: jdUserLoginState,
24
23
  cookiesStr: '',
25
24
  userInfo: userPinKey,
26
25
  isImmersive: false,
27
26
  baseAddCartSwitch: true,
28
27
  pageInfo: {
29
28
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
30
29
  address: '',
31
30
  addressCommaStr: '',
32
31
  fullAddress: '',
33
32
  un_area: '',
34
33
  userLbsAddress: '',
35
34
  vapptype: '1',
36
35
  pageType: 'home',
37
36
  dataType: BUSINESS_TYPE.ONLINE,
38
37
  floorExposureInfo: {},
39
38
  floorVideInfo: {},
40
39
  productVideInfo: {},
41
40
  tabsLoadAllDataInfo: {
42
41
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
43
42
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
44
43
  },
45
44
  updateShopInfosAllState: false,
46
45
  isVipShop: false,
47
46
  isJdShowNativeImmersivePlayer: false,
48
47
  isSuperBrandShop: false,
49
48
  ...shopConfig,
50
49
  pageScrollTop: 0,
51
50
  pageIdxHeightInfo: {
52
51
  list: [],
53
52
  },
54
53
  isScanPreview: false,
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
  sysInfo: {
64
63
  windowWidth: 0,
65
64
  windowHeight: 0,
66
65
  netWorkType: '4g',
67
66
  jdBottomBarHeight: 0,
68
67
  jdNativeHeaderHeight: 0,
69
68
  },
70
69
  queryInfo: {},
71
70
  shopInfo: {},
72
71
  openAppData: {},
73
72
  public info: CommonInterFace.BaseConfigInfo;
74
73
  public config: {
75
74
  [key: string]: any;
76
75
  };
77
76
  public lazyContainer: CommonInterFace.lazyContainer;
78
77
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents;
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 wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
87
86
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
88
87
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
89
88
  public loadJsSdkList: Array<any>;
90
89
  public loadJsSdkListCachePromise: any;
91
90
  public languageJsonData: any | null;
92
91
  public businessWorkerReady: boolean;
93
92
  public jdWorkerReadyPromise: any | null;
94
93
  constructor(opt) {
95
94
  this.info = this._getConfig(opt);
96
95
  this.config = {};
97
96
  this.lazyContainer = {
98
97
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
99
98
  appLazyContainerList: [],
100
99
  appLazyFinishContainerList: [],
101
100
  },
102
101
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
103
102
  appLazyContainerList: [],
104
103
  appLazyFinishContainerList: [],
105
104
  },
106
105
  };
107
106
  this.loadJsSdkList = [];
108
107
  this.loadJsSdkListCachePromise = {};
109
108
  this.renderedIsvComponents = {};
110
109
  this.rootEleNode = null;
111
110
  this.miniApplogUtil = MiniAppLogUtil;
112
111
  this.miniAppLogInstance = null;
113
112
  this.checkStatusAndLoginPromise = null;
114
113
  this.wxAppLoginInstance = WXAPP_LOGIN;
115
114
  this.wxAppBizInstance = WXAPP_BIZ;
116
115
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
117
116
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
118
117
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
119
118
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
120
119
  this.languageJsonData = langeJsonDataForCn;
121
120
  this.businessWorkerReady = false;
122
121
  this.jdWorkerReadyPromise = Promise.resolve(false);
123
122
  }
124
123
  _getConfig(opt) {
125
124
  return Object.assign({}, DefaultConfig, opt);
126
125
  }
127
126
  loadApiSafeSteadyReayPromise() {
128
127
  return Promise.resolve(true);
129
128
  }
130
129
  loadH5tagReayPromise() {
131
130
  return Promise.resolve(true);
132
131
  }
133
132
 
134
133
  jmfeReayPromise(): Promise<any> {
135
134
  return Promise.reject(false);
136
135
  }
137
136
 
138
137
  taskTimeoutPromise(callBack, timeout = 2000) {
139
138
  return new Promise((resolve) => {
140
139
  setTimeout(() => {
141
140
  const getCallBackRes = typeof callBack === 'function' && callBack();
142
141
  return resolve(getCallBackRes || false);
143
142
  }, timeout);
144
143
  });
145
144
  }
146
145
  removeJdAndroidRquestEventForTouchStart() {}
147
146
 
148
147
  updateBusinessDomainAndApi(domain, api) {
149
148
  }
150
149
 
151
150
  getFullScreenHeight(systemInfo) {
152
151
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
153
152
  let result = screenHeight;
154
153
  if (statusBarHeight > 20 && isAndroid) {
155
154
  result = screenHeight + statusBarHeight;
156
155
  }
157
156
  return result;
158
157
  }
159
158
 
160
159
  getTabBarHeight(systemInfo) {
161
160
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
162
161
  let result = 50;
163
162
  if (statusBarHeight > 20) {
164
163
  if (isIOS) {
165
164
  result = 84;
166
165
  } else if (isAndroid) {
167
166
  result = 53;
168
167
  }
169
168
  }
170
169
  return result;
171
170
  }
172
171
 
173
172
  getSystemInfo() {
174
173
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
175
174
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
176
175
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
177
176
  const fullScreenHeight = this.getFullScreenHeight(info);
178
177
  const tabBarHeight = this.getTabBarHeight(info);
179
178
  const safeContentHeight = fullScreenHeight - headerHeight;
180
179
  this.info.sysInfo = {
181
180
  ...this.info.sysInfo,
182
181
  ...info,
183
182
  actualNavBarHeight,
184
183
  headerHeight,
185
184
  fullScreenHeight,
186
185
  tabBarHeight,
187
186
  safeContentHeight,
188
187
  languageType: languageNowType,
189
188
  };
190
189
  if (this.info.sysInfo['hostVersionName']) {
191
190
  this.info.sysInfo['hostAppVersion'] = Number(
192
191
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
193
192
  );
194
193
  }
195
194
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
196
195
  this.getNetWorkType();
197
196
  }
198
197
 
199
198
  getSysInfoReadyPromise(): Promise<any> {
200
199
  (this.info.sysInfo?.windowWidth || 0) <= 0 && this.getSystemInfo();
201
200
  return Promise.resolve(this.info.sysInfo);
202
201
  }
203
202
  async updateMPaasConfig() {}
204
203
 
205
204
  getNetWorkType() {
206
205
  return Taro.getNetworkType().then((getRes) => {
207
206
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
208
207
  return getRes;
209
208
  });
210
209
  }
211
210
  getAPPUseStraightCorner() {
212
211
  return Promise.resolve(false);
213
212
  }
214
213
  checkStatusAndLogin(options = {}) {
215
214
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
216
215
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
217
216
  this.toLogin(options)
218
217
  .then((res) => {
219
218
  console.log('微信小程序登录状态结果,成功', res);
220
219
  this.info.loginState = true;
221
220
  resolve(res);
222
221
  })
223
222
  .catch((err) => {
224
223
  console.log('微信小程序登录异常状态结果', err);
225
224
  this.doLogin(options)
226
225
  .then((res2) => {
227
226
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
228
227
  this.info.loginState = true;
229
228
  resolve(res2);
230
229
  })
231
230
  .catch((err2) => {
232
231
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
233
232
  this.checkStatusAndLoginPromise = null;
234
233
  reject(err2);
235
234
  });
236
235
  });
237
236
  });
238
237
  return this.checkStatusAndLoginPromise;
239
238
  }
240
239
 
241
240
  checkJdStatusAndLogin(options) {
242
241
  return this.checkStatusAndLogin(options);
243
242
  }
244
243
 
245
244
  toLogin(options = {}): Promise<any> {
246
245
  return this.wxAppLoginInstance
247
246
  .getLoginPromise({
248
247
  mode: 'silent',
249
248
  loginColor: {
250
249
  biz: WXAPP_BIZ_KEY,
251
250
  dpin: 0,
252
251
  },
253
252
  ...options,
254
253
  })
255
254
  .then((res) => {
256
255
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
257
256
  this.getLoginCookie();
258
257
  })
259
258
  .catch((err) => {
260
259
  console.log('微信app登录异常返回信息', err);
261
260
  });
262
261
  }
263
262
 
264
263
  doLogin(options = {}) {
265
264
  return this.wxAppLoginInstance
266
265
  .doLogin({
267
266
  loginColor: {
268
267
  biz: WXAPP_BIZ_KEY,
269
268
  dpin: 0,
270
269
  },
271
270
  ...options,
272
271
  })
273
272
  .then((res) => {
274
273
  this.getLoginCookie();
275
274
  console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
276
275
  return res;
277
276
  });
278
277
  }
279
278
 
280
279
  doLoginForJdPin(options = {}) {
281
280
  return this.doLogin(options);
282
281
  }
283
282
 
284
283
  getLoginCookie(updateKey = 'wxapp') {
285
284
  return new Promise((resolve) => {
286
285
  console.log('开始获取更新wxapp中的cookie信息', updateKey);
287
286
  if (
288
287
  this.config.wqCookie &&
289
288
  this.config.wqCookieStr &&
290
289
  this.config.getWqCookieKey === updateKey
291
290
  ) {
292
291
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
293
292
  resolve({
294
293
  wqCookie: this.config.wqCookie,
295
294
  wqCookieStr: this.config.wqCookieStr,
296
295
  });
297
296
  } else {
298
297
  if (isPublishToWxapp) {
299
298
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
300
299
  if (getWxappCookieObj) {
301
300
  const getCookieObj = getWxappCookieObj['_data'];
302
301
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
303
302
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
304
303
  this.info.loginState = true;
305
304
  this.info.userInfo.wqCookie = wqCookieStr;
306
305
  this.info.userInfo.wqVisitkey = visitkey;
307
306
  console.log('获取用户完整cookie信息', getCookieObj);
308
307
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
309
308
  console.log('获取微信用户地址信息', getUserAddress);
310
309
  if (getUserAddress) {
311
310
  this.info.pageInfo.address = getUserAddress?.areaId;
312
311
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
313
312
  ? this.info.pageInfo.address.replace(/_/g, ',')
314
313
  : '';
315
314
  this.info.pageInfo.un_area = this.info.pageInfo.address;
316
315
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
317
316
  area: this.info.pageInfo.address,
318
317
  });
319
318
  }
320
319
  if (this.miniAppLogInstance) {
321
320
  this.miniAppLogInstance.set({
322
321
  account: pin,
323
322
  unionid: wq_unionid,
324
323
  openid: wxapp_openid,
325
324
  });
326
325
  }
327
326
  this.config.wqCookie = wqCookie;
328
327
  this.config.wqCookieStr = wqCookieStr;
329
328
  this.config.getWqCookieKey = updateKey;
330
329
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
331
330
  resolve({
332
331
  wqCookie,
333
332
  wqCookieStr,
334
333
  });
335
334
  } else {
336
335
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
337
336
  resolve({
338
337
  wqCookie: false,
339
338
  wqCookieStr: false,
340
339
  });
341
340
  }
342
341
  } else {
343
342
  resolve({
344
343
  wqCookie: false,
345
344
  wqCookieStr: false,
346
345
  });
347
346
  }
348
347
  }
349
348
  });
350
349
  }
351
350
 
352
351
 
353
352
  checkLoginStatus() {
354
353
  return this.getLoginCookie();
355
354
  }
356
355
 
357
356
  getAddressCachePromise() {
358
357
  return Promise.reject('该方法只在APP内适用');
359
358
  }
360
359
 
361
360
  getLbsAddressCachePromise() {
362
361
  return Promise.resolve({
363
362
  status: '-1005',
364
363
  msg: '暂未实现,获取失败',
365
364
  });
366
365
  }
367
366
 
368
367
  getDynamicConfig(key: string) {
369
368
  console.warn('调用默认的 getDynamicConfig(),注意,此方法还未实现!');
370
369
  return null;
371
370
  }
372
371
 
373
372
  updatePageAndLogInfo(updateQuery = {}) {
374
373
  const createUpdateQueryInfo: {
375
374
  query: {
376
375
  shopId?: string | number;
377
376
  venderId?: string | number;
378
377
  };
379
378
  updateShopInfoState: boolean;
380
379
  } = Object.assign(
381
380
  {},
382
381
  {
383
382
  query: {},
384
383
  updateShopInfoState: false,
385
384
  },
386
385
  updateQuery,
387
386
  );
388
387
  console.log(
389
388
  '获取当前下发的店铺查询参数',
390
389
  updateQuery,
391
390
  '获取之前保存的shopInfo店铺查询参数',
392
391
  this.info?.shopInfo,
393
392
  );
394
393
  const { query, updateShopInfoState } = createUpdateQueryInfo;
395
394
  const { shopId, venderId } = query;
396
395
  if (updateShopInfoState) {
397
396
  this.info.queryInfo = {
398
397
  ...this.info.queryInfo,
399
398
  ...query,
400
399
  };
401
400
  if (shopId && venderId) {
402
401
  this.info.shopInfo = {
403
402
  shopId: `${shopId}`,
404
403
  venderId: `${venderId}`,
405
404
  };
406
405
  }
407
406
  } else {
408
407
  this.info.queryInfo = {
409
408
  ...query,
410
409
  };
411
410
  if (
412
411
  this.info.shopInfo?.shopId &&
413
412
  this.info.shopInfo?.venderId &&
414
413
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
415
414
  ) {
416
415
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
417
416
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
418
417
  console.log(
419
418
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
420
419
  this.info.queryInfo,
421
420
  );
422
421
  }
423
422
  }
424
423
  this.info.queryInfo['shopId'] &&
425
424
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
426
425
  this.info.queryInfo['venderId'] &&
427
426
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
428
427
  console.log(
429
428
  '默认==获取店铺下发查询参数\n',
430
429
  query,
431
430
  '\n获取店铺最后查询参数\n',
432
431
  this.info.queryInfo,
433
432
  '\n是否为更新店铺状态\n',
434
433
  updateShopInfoState,
435
434
  );
436
435
  }
437
436
 
438
437
  checkJingGouWxappEnv() {
439
438
  return false;
440
439
  }
441
440
  renderNextTickLoadSdk(_delayTime = 1000, _callback) {
442
441
  console.warn('暂未实现 index.ts');
443
442
  }
444
443
  loadOtherSdk() {
445
444
  console.warn('暂未实现 index.ts');
446
445
  }
447
446
  loadItemSdkPromise(jsInfo = {}) {
448
447
  console.warn('暂未实现 index.ts');
449
448
  }
450
449
  createLanguageProimse() {
451
450
  return Promise.reject({
452
451
  msg: '暂未实现',
453
452
  });
454
453
  }
454
+ import Taro from '@tarojs/taro';
455
455
  WXAPP_LOGIN,
456
456
  WXAPP_BIZ,
457
457
  WXAPP_USER_INFO,
458
458
  WXAPP_NAVIGATOR,
459
459
  WXAPP_REPORT_GDT,
460
460
  WXAPP_PARAMS_SIGN,
461
461
  BUSINESS_TYPE,
462
462
  SHOP_MENU_ID_TYPE,
463
463
  SHOP_MENU_ID_NAME,
464
464
  SECTION_HOME_TAB_NAME_TYPE,
465
465
  SECTION_HOME_TAB_TYPE,
466
466
  WXAPP_BIZ_KEY,
467
467
  WX_BUSINESS_TYPE,
468
468
  TaroEventType,
469
469
  getSystemInfos,
470
470
  getTaroStorageKeyValue,
471
471
  getWxAppCookieStr,
472
472
  languageNowType,
473
473
  accessibilityRunning: false,
474
474
  abTestLabels: {},
475
475
  nonSellableSkuids: {},
476
476
  loginState: jdUserLoginState,
477
477
  cookiesStr: '',
478
478
  userInfo: userPinKey,
479
479
  isImmersive: false,
480
480
  baseAddCartSwitch: true,
481
481
  pageInfo: {
482
482
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
483
483
  address: '',
484
484
  addressCommaStr: '',
485
485
  fullAddress: '',
486
486
  un_area: '',
487
487
  userLbsAddress: '',
488
488
  vapptype: '1',
489
489
  pageType: 'home',
490
490
  dataType: BUSINESS_TYPE.ONLINE,
491
491
  floorExposureInfo: {},
492
492
  floorVideInfo: {},
493
493
  productVideInfo: {},
494
494
  tabsLoadAllDataInfo: {
495
495
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
496
496
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
497
497
  },
498
498
  updateShopInfosAllState: false,
499
499
  isVipShop: false,
500
500
  isJdShowNativeImmersivePlayer: false,
501
501
  isSuperBrandShop: false,
502
502
  ...shopConfig,
503
503
  pageScrollTop: 0,
504
504
  pageIdxHeightInfo: {
505
505
  list: [],
506
506
  },
507
507
  isScanPreview: false,
508
508
  shopNavBarHeight: 0,
509
509
  },
510
510
  defaultQueryLogInfo: {
511
511
  sourceType: 'JDshop',
512
512
  sourceValue: '',
513
513
  moduleId: 'none',
514
514
  entrance: 'none',
515
515
  },
516
516
  sysInfo: {
517
517
  windowWidth: 0,
518
518
  windowHeight: 0,
519
519
  netWorkType: '4g',
520
520
  jdBottomBarHeight: 0,
521
521
  jdNativeHeaderHeight: 0,
522
522
  },
523
523
  queryInfo: {},
524
524
  shopInfo: {},
525
525
  openAppData: {},
526
526
  public info: CommonInterFace.BaseConfigInfo;
527
527
  public config: {
528
528
  [key: string]: any;
529
529
  };
530
530
  public lazyContainer: CommonInterFace.lazyContainer;
531
531
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents;
532
532
  public rootEleNode: HTMLElement | null;
533
533
  public miniApplogUtil: CommonInterFace.MiniApplogUtil;
534
534
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
535
535
  public checkStatusAndLoginPromise: object | null;
536
536
  public wxAppLoginInstance: CommonInterFace.WxAppLogin;
537
537
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
538
538
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
539
539
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
540
540
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
541
541
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
542
542
  public loadJsSdkList: Array<any>;
543
543
  public loadJsSdkListCachePromise: any;
544
544
  public languageJsonData: any | null;
545
545
  public businessWorkerReady: boolean;
546
546
  public jdWorkerReadyPromise: any | null;
547
547
  constructor(opt) {
548
548
  this.info = this._getConfig(opt);
549
549
  this.config = {};
550
550
  this.lazyContainer = {
551
551
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
552
552
  appLazyContainerList: [],
553
553
  appLazyFinishContainerList: [],
554
554
  },
555
555
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
556
556
  appLazyContainerList: [],
557
557
  appLazyFinishContainerList: [],
558
558
  },
559
559
  };
560
560
  this.loadJsSdkList = [];
561
561
  this.loadJsSdkListCachePromise = {};
562
562
  this.renderedIsvComponents = {};
563
563
  this.rootEleNode = null;
564
564
  this.miniApplogUtil = MiniAppLogUtil;
565
565
  this.miniAppLogInstance = null;
566
566
  this.checkStatusAndLoginPromise = null;
567
567
  this.wxAppLoginInstance = WXAPP_LOGIN;
568
568
  this.wxAppBizInstance = WXAPP_BIZ;
569
569
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
570
570
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
571
571
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
572
572
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
573
573
  this.languageJsonData = langeJsonDataForCn;
574
574
  this.businessWorkerReady = false;
575
575
  this.jdWorkerReadyPromise = Promise.resolve(false);
576
576
  }
577
577
  _getConfig(opt) {
578
578
  return Object.assign({}, DefaultConfig, opt);
579
579
  }
580
580
  loadApiSafeSteadyReayPromise() {
581
581
  return Promise.resolve(true);
582
582
  }
583
583
  loadH5tagReayPromise() {
584
584
  return Promise.resolve(true);
585
585
  }
586
586
 
587
587
  jmfeReayPromise(): Promise<any> {
588
588
  return Promise.reject(false);
589
589
  }
590
590
 
591
591
  taskTimeoutPromise(callBack, timeout = 2000) {
592
592
  return new Promise((resolve) => {
593
593
  setTimeout(() => {
594
594
  const getCallBackRes = typeof callBack === 'function' && callBack();
595
595
  return resolve(getCallBackRes || false);
596
596
  }, timeout);
597
597
  });
598
598
  }
599
599
  removeJdAndroidRquestEventForTouchStart() {}
600
600
 
601
601
  updateBusinessDomainAndApi(domain, api) {
602
602
  }
603
603
 
604
604
  getFullScreenHeight(systemInfo) {
605
605
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
606
606
  let result = screenHeight;
607
607
  if (statusBarHeight > 20 && isAndroid) {
608
608
  result = screenHeight + statusBarHeight;
609
609
  }
610
610
  return result;
611
611
  }
612
612
 
613
613
  getTabBarHeight(systemInfo) {
614
614
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
615
615
  let result = 50;
616
616
  if (statusBarHeight > 20) {
617
617
  if (isIOS) {
618
618
  result = 84;
619
619
  } else if (isAndroid) {
620
620
  result = 53;
621
621
  }
622
622
  }
623
623
  return result;
624
624
  }
625
625
 
626
626
  getSystemInfo() {
627
627
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
628
628
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
629
629
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
630
630
  const fullScreenHeight = this.getFullScreenHeight(info);
631
631
  const tabBarHeight = this.getTabBarHeight(info);
632
632
  const safeContentHeight = fullScreenHeight - headerHeight;
633
633
  this.info.sysInfo = {
634
634
  ...this.info.sysInfo,
635
635
  ...info,
636
636
  actualNavBarHeight,
637
637
  headerHeight,
638
638
  fullScreenHeight,
639
639
  tabBarHeight,
640
640
  safeContentHeight,
641
641
  languageType: languageNowType,
642
642
  };
643
643
  if (this.info.sysInfo['hostVersionName']) {
644
644
  this.info.sysInfo['hostAppVersion'] = Number(
645
645
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
646
646
  );
647
647
  }
648
648
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
649
649
  this.getNetWorkType();
650
650
  }
651
651
 
652
652
  getSysInfoReadyPromise(): Promise<any> {
653
653
  (this.info.sysInfo?.windowWidth || 0) <= 0 && this.getSystemInfo();
654
654
  return Promise.resolve(this.info.sysInfo);
655
655
  }
656
656
  async updateMPaasConfig() {}
657
657
 
658
658
  getNetWorkType() {
659
659
  return Taro.getNetworkType().then((getRes) => {
660
660
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
661
661
  return getRes;
662
662
  });
663
663
  }
664
664
  getAPPUseStraightCorner() {
665
665
  return Promise.resolve(false);
666
666
  }
667
667
  getIsGlassNavEnable() {
668
668
  return Promise.resolve(false);
669
669
  }
670
670
  checkStatusAndLogin(options = {}) {
671
671
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
672
672
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
673
673
  this.toLogin(options)
674
674
  .then((res) => {
675
675
  console.log('微信小程序登录状态结果,成功', res);
676
676
  this.info.loginState = true;
677
677
  resolve(res);
678
678
  })
679
679
  .catch((err) => {
680
680
  console.log('微信小程序登录异常状态结果', err);
681
681
  this.doLogin(options)
682
682
  .then((res2) => {
683
683
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
684
684
  this.info.loginState = true;
685
685
  resolve(res2);
686
686
  })
687
687
  .catch((err2) => {
688
688
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
689
689
  this.checkStatusAndLoginPromise = null;
690
690
  reject(err2);
691
691
  });
692
692
  });
693
693
  });
694
694
  return this.checkStatusAndLoginPromise;
695
695
  }
696
696
 
697
697
  checkJdStatusAndLogin(options) {
698
698
  return this.checkStatusAndLogin(options);
699
699
  }
700
700
 
701
701
  toLogin(options = {}): Promise<any> {
702
702
  return this.wxAppLoginInstance
703
703
  .getLoginPromise({
704
704
  mode: 'silent',
705
705
  loginColor: {
706
706
  biz: WXAPP_BIZ_KEY,
707
707
  dpin: 0,
708
708
  },
709
709
  ...options,
710
710
  })
711
711
  .then((res) => {
712
712
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
713
713
  this.getLoginCookie();
714
714
  })
715
715
  .catch((err) => {
716
716
  console.log('微信app登录异常返回信息', err);
717
717
  });
718
718
  }
719
719
 
720
720
  doLogin(options = {}) {
721
721
  return this.wxAppLoginInstance
722
722
  .doLogin({
723
723
  loginColor: {
724
724
  biz: WXAPP_BIZ_KEY,
725
725
  dpin: 0,
726
726
  },
727
727
  ...options,
728
728
  })
729
729
  .then((res) => {
730
730
  this.getLoginCookie();
731
731
  console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
732
732
  return res;
733
733
  });
734
734
  }
735
735
 
736
736
  doLoginForJdPin(options = {}) {
737
737
  return this.doLogin(options);
738
738
  }
739
739
 
740
740
  getLoginCookie(updateKey = 'wxapp') {
741
741
  return new Promise((resolve) => {
742
742
  console.log('开始获取更新wxapp中的cookie信息', updateKey);
743
743
  if (
744
744
  this.config.wqCookie &&
745
745
  this.config.wqCookieStr &&
746
746
  this.config.getWqCookieKey === updateKey
747
747
  ) {
748
748
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
749
749
  resolve({
750
750
  wqCookie: this.config.wqCookie,
751
751
  wqCookieStr: this.config.wqCookieStr,
752
752
  });
753
753
  } else {
754
754
  if (isPublishToWxapp) {
755
755
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
756
756
  if (getWxappCookieObj) {
757
757
  const getCookieObj = getWxappCookieObj['_data'];
758
758
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
759
759
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
760
760
  this.info.loginState = true;
761
761
  this.info.userInfo.wqCookie = wqCookieStr;
762
762
  this.info.userInfo.wqVisitkey = visitkey;
763
763
  console.log('获取用户完整cookie信息', getCookieObj);
764
764
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
765
765
  console.log('获取微信用户地址信息', getUserAddress);
766
766
  if (getUserAddress) {
767
767
  this.info.pageInfo.address = getUserAddress?.areaId;
768
768
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
769
769
  ? this.info.pageInfo.address.replace(/_/g, ',')
770
770
  : '';
771
771
  this.info.pageInfo.un_area = this.info.pageInfo.address;
772
772
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
773
773
  area: this.info.pageInfo.address,
774
774
  });
775
775
  }
776
776
  if (this.miniAppLogInstance) {
777
777
  this.miniAppLogInstance.set({
778
778
  account: pin,
779
779
  unionid: wq_unionid,
780
780
  openid: wxapp_openid,
781
781
  });
782
782
  }
783
783
  this.config.wqCookie = wqCookie;
784
784
  this.config.wqCookieStr = wqCookieStr;
785
785
  this.config.getWqCookieKey = updateKey;
786
786
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
787
787
  resolve({
788
788
  wqCookie,
789
789
  wqCookieStr,
790
790
  });
791
791
  } else {
792
792
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
793
793
  resolve({
794
794
  wqCookie: false,
795
795
  wqCookieStr: false,
796
796
  });
797
797
  }
798
798
  } else {
799
799
  resolve({
800
800
  wqCookie: false,
801
801
  wqCookieStr: false,
802
802
  });
803
803
  }
804
804
  }
805
805
  });
806
806
  }
807
807
 
808
808
 
809
809
  checkLoginStatus() {
810
810
  return this.getLoginCookie();
811
811
  }
812
812
 
813
813
  getAddressCachePromise() {
814
814
  return Promise.reject('该方法只在APP内适用');
815
815
  }
816
816
 
817
817
  getLbsAddressCachePromise() {
818
818
  return Promise.resolve({
819
819
  status: '-1005',
820
820
  msg: '暂未实现,获取失败',
821
821
  });
822
822
  }
823
823
 
824
824
  getDynamicConfig(key: string) {
825
825
  console.warn('调用默认的 getDynamicConfig(),注意,此方法还未实现!');
826
826
  return null;
827
827
  }
828
828
 
829
829
  updatePageAndLogInfo(updateQuery = {}) {
830
830
  const createUpdateQueryInfo: {
831
831
  query: {
832
832
  shopId?: string | number;
833
833
  venderId?: string | number;
834
834
  };
835
835
  updateShopInfoState: boolean;
836
836
  } = Object.assign(
837
837
  {},
838
838
  {
839
839
  query: {},
840
840
  updateShopInfoState: false,
841
841
  },
842
842
  updateQuery,
843
843
  );
844
844
  console.log(
845
845
  '获取当前下发的店铺查询参数',
846
846
  updateQuery,
847
847
  '获取之前保存的shopInfo店铺查询参数',
848
848
  this.info?.shopInfo,
849
849
  );
850
850
  const { query, updateShopInfoState } = createUpdateQueryInfo;
851
851
  const { shopId, venderId } = query;
852
852
  if (updateShopInfoState) {
853
853
  this.info.queryInfo = {
854
854
  ...this.info.queryInfo,
855
855
  ...query,
856
856
  };
857
857
  if (shopId && venderId) {
858
858
  this.info.shopInfo = {
859
859
  shopId: `${shopId}`,
860
860
  venderId: `${venderId}`,
861
861
  };
862
862
  }
863
863
  } else {
864
864
  this.info.queryInfo = {
865
865
  ...query,
866
866
  };
867
867
  if (
868
868
  this.info.shopInfo?.shopId &&
869
869
  this.info.shopInfo?.venderId &&
870
870
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
871
871
  ) {
872
872
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
873
873
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
874
874
  console.log(
875
875
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
876
876
  this.info.queryInfo,
877
877
  );
878
878
  }
879
879
  }
880
880
  this.info.queryInfo['shopId'] &&
881
881
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
882
882
  this.info.queryInfo['venderId'] &&
883
883
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
884
884
  console.log(
885
885
  '默认==获取店铺下发查询参数\n',
886
886
  query,
887
887
  '\n获取店铺最后查询参数\n',
888
888
  this.info.queryInfo,
889
889
  '\n是否为更新店铺状态\n',
890
890
  updateShopInfoState,
891
891
  );
892
892
  }
893
893
 
894
894
  checkJingGouWxappEnv() {
895
895
  return false;
896
896
  }
897
897
  renderNextTickLoadSdk(_delayTime = 1000, _callback) {
898
898
  console.warn('暂未实现 index.ts');
899
899
  }
900
900
  loadOtherSdk() {
901
901
  console.warn('暂未实现 index.ts');
902
902
  }
903
903
  loadItemSdkPromise(jsInfo = {}) {
904
904
  console.warn('暂未实现 index.ts');
905
905
  }
906
906
  createLanguageProimse() {
907
907
  return Promise.reject({
908
908
  msg: '暂未实现',
909
909
  });
910
910
  }