@conecli/cone-render 0.10.1-shop3.95 → 0.10.1-shop3.97

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