@conecli/cone-render 0.10.1-shop3.113 → 0.10.1-shop3.115

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