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

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
  baseAddCartSwitch: true,
463
463
  pageInfo: {
464
464
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
465
465
  address: '',
466
466
  addressCommaStr: '',
467
467
  un_area: '',
468
468
  userLbsAddress: '',
469
469
  vapptype: '1',
470
470
  pageType: 'home',
471
471
  dataType: BUSINESS_TYPE.ONLINE,
472
472
  floorExposureInfo: {},
473
473
  floorVideInfo: {},
474
474
  productVideInfo: {},
475
475
  tabsLoadAllDataInfo: {
476
476
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
477
477
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
478
478
  },
479
479
  updateShopInfosAllState: false,
480
480
  isVipShop: false,
481
481
  isJdShowNativeImmersivePlayer: false,
482
482
  isSuperBrandShop: false,
483
483
  ...shopConfig,
484
484
  pageScrollTop: 0,
485
485
  pageIdxHeightInfo: {
486
486
  list: [],
487
487
  },
488
488
  shopNavBarHeight: 0,
489
489
  },
490
490
  defaultQueryLogInfo: {
491
491
  sourceType: 'JDshop',
492
492
  sourceValue: '',
493
493
  moduleId: 'none',
494
494
  entrance: 'none',
495
495
  },
496
496
  sysInfo: {
497
497
  windowWidth: 0,
498
498
  windowHeight: 0,
499
499
  netWorkType: '4g',
500
500
  jdBottomBarHeight: 0,
501
501
  jdNativeHeaderHeight: 0,
502
502
  },
503
503
  queryInfo: {},
504
504
  shopInfo: {},
505
505
  openAppData: {},
506
506
  public info: CommonInterFace.BaseConfigInfo;
507
507
  public config: {
508
508
  [key: string]: any;
509
509
  };
510
510
  public lazyContainer: CommonInterFace.lazyContainer;
511
511
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents;
512
512
  public rootEleNode: HTMLElement | null;
513
513
  public miniApplogUtil: CommonInterFace.MiniApplogUtil;
514
514
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
515
515
  public checkStatusAndLoginPromise: object | null;
516
516
  public wxAppLoginInstance: CommonInterFace.WxAppLogin;
517
517
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
518
518
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
519
519
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
520
520
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
521
521
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
522
522
  public loadJsSdkList: Array<any>;
523
523
  public loadJsSdkListCachePromise: any;
524
524
  public languageJsonData: any | null;
525
525
  public businessWorkerReady: boolean;
526
526
  public jdWorkerReadyPromise: any | null;
527
527
  constructor(opt) {
528
528
  this.info = this._getConfig(opt);
529
529
  this.config = {};
530
530
  this.lazyContainer = {
531
531
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
532
532
  appLazyContainerList: [],
533
533
  appLazyFinishContainerList: [],
534
534
  },
535
535
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
536
536
  appLazyContainerList: [],
537
537
  appLazyFinishContainerList: [],
538
538
  },
539
539
  };
540
540
  this.loadJsSdkList = [];
541
541
  this.loadJsSdkListCachePromise = {};
542
542
  this.renderedIsvComponents = {};
543
543
  this.rootEleNode = null;
544
544
  this.miniApplogUtil = MiniAppLogUtil;
545
545
  this.miniAppLogInstance = null;
546
546
  this.checkStatusAndLoginPromise = null;
547
547
  this.wxAppLoginInstance = WXAPP_LOGIN;
548
548
  this.wxAppBizInstance = WXAPP_BIZ;
549
549
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
550
550
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
551
551
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
552
552
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
553
553
  this.languageJsonData = langeJsonDataForCn;
554
554
  this.businessWorkerReady = false;
555
555
  this.jdWorkerReadyPromise = Promise.resolve(false);
556
556
  }
557
557
  _getConfig(opt) {
558
558
  return Object.assign({}, DefaultConfig, opt);
559
559
  }
560
560
  loadApiSafeSteadyReayPromise() {
561
561
  return Promise.resolve(true);
562
562
  }
563
563
  loadH5tagReayPromise() {
564
564
  return Promise.resolve(true);
565
565
  }
566
566
 
567
567
  jmfeReayPromise(): Promise<any> {
568
568
  return Promise.reject(false);
569
569
  }
570
570
 
571
571
  taskTimeoutPromise(callBack, timeout = 2000) {
572
572
  return new Promise((resolve) => {
573
573
  setTimeout(() => {
574
574
  const getCallBackRes = typeof callBack === 'function' && callBack();
575
575
  return resolve(getCallBackRes || false);
576
576
  }, timeout);
577
577
  });
578
578
  }
579
579
  removeJdAndroidRquestEventForTouchStart() {}
580
580
 
581
581
  updateBusinessDomainAndApi(domain, api) {
582
582
  }
583
583
 
584
584
  getFullScreenHeight(systemInfo) {
585
585
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
586
586
  let result = screenHeight;
587
587
  if (statusBarHeight > 20 && isAndroid) {
588
588
  result = screenHeight + statusBarHeight;
589
589
  }
590
590
  return result;
591
591
  }
592
592
 
593
593
  getTabBarHeight(systemInfo) {
594
594
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
595
595
  let result = 50;
596
596
  if (statusBarHeight > 20) {
597
597
  if (isIOS) {
598
598
  result = 84;
599
599
  } else if (isAndroid) {
600
600
  result = 53;
601
601
  }
602
602
  }
603
603
  return result;
604
604
  }
605
605
 
606
606
  getSystemInfo() {
607
607
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
608
608
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
609
609
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
610
610
  const fullScreenHeight = this.getFullScreenHeight(info);
611
611
  const tabBarHeight = this.getTabBarHeight(info);
612
612
  const safeContentHeight = fullScreenHeight - headerHeight;
613
613
  this.info.sysInfo = {
614
614
  ...this.info.sysInfo,
615
615
  ...info,
616
616
  actualNavBarHeight,
617
617
  headerHeight,
618
618
  fullScreenHeight,
619
619
  tabBarHeight,
620
620
  safeContentHeight,
621
621
  languageType: languageNowType,
622
622
  };
623
623
  if (this.info.sysInfo['hostVersionName']) {
624
624
  this.info.sysInfo['hostAppVersion'] = Number(
625
625
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
626
626
  );
627
627
  }
628
628
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
629
629
  this.getNetWorkType();
630
630
  }
631
631
  async updateMPaasConfig() {}
632
632
 
633
633
  getNetWorkType() {
634
634
  Taro.getNetworkType().then((getRes) => {
635
635
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
636
636
  });
637
637
  }
638
638
  getAPPUseStraightCorner() {
639
639
  return Promise.resolve(false);
640
640
  }
641
641
  checkStatusAndLogin(options = {}) {
642
642
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
643
643
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
644
644
  this.toLogin(options)
645
645
  .then((res) => {
646
646
  console.log('微信小程序登录状态结果,成功', res);
647
647
  this.info.loginState = true;
648
648
  resolve(res);
649
649
  })
650
650
  .catch((err) => {
651
651
  console.log('微信小程序登录异常状态结果', err);
652
652
  this.doLogin(options)
653
653
  .then((res2) => {
654
654
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
655
655
  this.info.loginState = true;
656
656
  resolve(res2);
657
657
  })
658
658
  .catch((err2) => {
659
659
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
660
660
  this.checkStatusAndLoginPromise = null;
661
661
  reject(err2);
662
662
  });
663
663
  });
664
664
  });
665
665
  return this.checkStatusAndLoginPromise;
666
666
  }
667
667
 
668
668
  checkJdStatusAndLogin(options) {
669
669
  return this.checkStatusAndLogin(options);
670
670
  }
671
671
 
672
672
  toLogin(options = {}): Promise<any> {
673
673
  return this.wxAppLoginInstance
674
674
  .getLoginPromise({
675
675
  mode: 'silent',
676
676
  loginColor: {
677
677
  biz: WXAPP_BIZ_KEY,
678
678
  dpin: 0,
679
679
  },
680
680
  ...options,
681
681
  })
682
682
  .then((res) => {
683
683
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
684
684
  this.getLoginCookie();
685
685
  })
686
686
  .catch((err) => {
687
687
  console.log('微信app登录异常返回信息', err);
688
688
  });
689
689
  }
690
690
 
691
691
  doLogin(options = {}) {
692
692
  return this.wxAppLoginInstance
693
693
  .doLogin({
694
694
  loginColor: {
695
695
  biz: WXAPP_BIZ_KEY,
696
696
  dpin: 0,
697
697
  },
698
698
  ...options,
699
699
  })
700
700
  .then((res) => {
701
701
  this.getLoginCookie();
702
702
  console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
703
703
  return res;
704
704
  });
705
705
  }
706
706
 
707
707
  doLoginForJdPin(options = {}) {
708
708
  return this.doLogin(options);
709
709
  }
710
710
 
711
711
  getLoginCookie(updateKey = 'wxapp') {
712
712
  return new Promise((resolve) => {
713
713
  console.log('开始获取更新wxapp中的cookie信息', updateKey);
714
714
  if (
715
715
  this.config.wqCookie &&
716
716
  this.config.wqCookieStr &&
717
717
  this.config.getWqCookieKey === updateKey
718
718
  ) {
719
719
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
720
720
  resolve({
721
721
  wqCookie: this.config.wqCookie,
722
722
  wqCookieStr: this.config.wqCookieStr,
723
723
  });
724
724
  } else {
725
725
  if (isPublishToWxapp) {
726
726
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
727
727
  if (getWxappCookieObj) {
728
728
  const getCookieObj = getWxappCookieObj['_data'];
729
729
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
730
730
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
731
731
  this.info.loginState = true;
732
732
  this.info.userInfo.wqCookie = wqCookieStr;
733
733
  this.info.userInfo.wqVisitkey = visitkey;
734
734
  console.log('获取用户完整cookie信息', getCookieObj);
735
735
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
736
736
  console.log('获取微信用户地址信息', getUserAddress);
737
737
  if (getUserAddress) {
738
738
  this.info.pageInfo.address = getUserAddress?.areaId;
739
739
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
740
740
  ? this.info.pageInfo.address.replace(/_/g, ',')
741
741
  : '';
742
742
  this.info.pageInfo.un_area = this.info.pageInfo.address;
743
743
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
744
744
  area: this.info.pageInfo.address,
745
745
  });
746
746
  }
747
747
  if (this.miniAppLogInstance) {
748
748
  this.miniAppLogInstance.set({
749
749
  account: pin,
750
750
  unionid: wq_unionid,
751
751
  openid: wxapp_openid,
752
752
  });
753
753
  }
754
754
  this.config.wqCookie = wqCookie;
755
755
  this.config.wqCookieStr = wqCookieStr;
756
756
  this.config.getWqCookieKey = updateKey;
757
757
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
758
758
  resolve({
759
759
  wqCookie,
760
760
  wqCookieStr,
761
761
  });
762
762
  } else {
763
763
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
764
764
  resolve({
765
765
  wqCookie: false,
766
766
  wqCookieStr: false,
767
767
  });
768
768
  }
769
769
  } else {
770
770
  resolve({
771
771
  wqCookie: false,
772
772
  wqCookieStr: false,
773
773
  });
774
774
  }
775
775
  }
776
776
  });
777
777
  }
778
778
 
779
779
 
780
780
  checkLoginStatus() {
781
781
  return this.getLoginCookie();
782
782
  }
783
783
 
784
784
  getAddressCachePromise() {
785
785
  return Promise.reject('该方法只在APP内适用');
786
786
  }
787
787
 
788
788
  getLbsAddressCachePromise() {
789
789
  return Promise.resolve({
790
790
  status: '-1005',
791
791
  msg: '暂未实现,获取失败',
792
792
  });
793
793
  }
794
794
 
795
795
  getDynamicConfig(key: string) {
796
796
  console.warn('调用默认的 getDynamicConfig(),注意,此方法还未实现!');
797
797
  return null;
798
798
  }
799
799
 
800
800
  updatePageAndLogInfo(updateQuery = {}) {
801
801
  const createUpdateQueryInfo: {
802
802
  query: {
803
803
  shopId?: string | number;
804
804
  venderId?: string | number;
805
805
  };
806
806
  updateShopInfoState: boolean;
807
807
  } = Object.assign(
808
808
  {},
809
809
  {
810
810
  query: {},
811
811
  updateShopInfoState: false,
812
812
  },
813
813
  updateQuery,
814
814
  );
815
815
  console.log(
816
816
  '获取当前下发的店铺查询参数',
817
817
  updateQuery,
818
818
  '获取之前保存的shopInfo店铺查询参数',
819
819
  this.info?.shopInfo,
820
820
  );
821
821
  const { query, updateShopInfoState } = createUpdateQueryInfo;
822
822
  const { shopId, venderId } = query;
823
823
  if (updateShopInfoState) {
824
824
  this.info.queryInfo = {
825
825
  ...this.info.queryInfo,
826
826
  ...query,
827
827
  };
828
828
  if (shopId && venderId) {
829
829
  this.info.shopInfo = {
830
830
  shopId: `${shopId}`,
831
831
  venderId: `${venderId}`,
832
832
  };
833
833
  }
834
834
  } else {
835
835
  this.info.queryInfo = {
836
836
  ...query,
837
837
  };
838
838
  if (
839
839
  this.info.shopInfo?.shopId &&
840
840
  this.info.shopInfo?.venderId &&
841
841
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
842
842
  ) {
843
843
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
844
844
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
845
845
  console.log(
846
846
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
847
847
  this.info.queryInfo,
848
848
  );
849
849
  }
850
850
  }
851
851
  this.info.queryInfo['shopId'] &&
852
852
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
853
853
  this.info.queryInfo['venderId'] &&
854
854
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
855
855
  console.log(
856
856
  '默认==获取店铺下发查询参数\n',
857
857
  query,
858
858
  '\n获取店铺最后查询参数\n',
859
859
  this.info.queryInfo,
860
860
  '\n是否为更新店铺状态\n',
861
861
  updateShopInfoState,
862
862
  );
863
863
  }
864
864
 
865
865
  checkJingGouWxappEnv() {
866
866
  return false;
867
867
  }
868
868
  renderNextTickLoadSdk() {
869
869
  console.warn('暂未实现 index.ts');
870
870
  }
871
871
  loadOtherSdk() {
872
872
  console.warn('暂未实现 index.ts');
873
873
  }
874
874
  loadItemSdkPromise(jsInfo = {}) {
875
875
  console.warn('暂未实现 index.ts');
876
876
  }
877
877
  createLanguageProimse() {
878
878
  return Promise.reject({
879
879
  msg: '暂未实现',
880
880
  });
881
881
  }