@conecli/cone-render 0.10.1-shop3.24 → 0.10.1-shop3.25

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