@conecli/cone-render 0.10.1-shop3.129 → 0.10.1-shop3.130

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