@conecli/cone-render 0.10.1-shop3.113 → 0.10.1-shop3.115

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