@conecli/cone-render 0.10.1-shop3.136 → 0.10.1-shop3.138

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