@conecli/cone-render 0.10.1-shop3.121 → 0.10.1-shop3.123

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