@conecli/cone-render 0.10.1-shop3.47 → 0.10.1-shop3.49

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