@conecli/cone-render 0.10.1-shop3.96 → 0.10.1-shop3.97

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