@conecli/cone-render 0.10.1-shop-beta.24 → 0.10.1-shop-beta.26

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