@conecli/cone-render 0.10.1-isv2.4 → 0.10.1-isv3.1

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