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