@conecli/cone-render 0.10.1-shop3.76 → 0.10.1-shop3.77

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