@conecli/cone-render 0.10.1-shop3.52 → 0.10.1-shop3.53

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