@conecli/cone-render 0.10.1-shop3.121 → 0.10.1-shop3.123

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