@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
  WXAPP_SUBS_GUIDER,
11
10
  WXAPP_ADDRESS_V2_API,
12
11
  BUSINESS_TYPE,
13
12
  SHOP_MENU_ID_TYPE,
14
13
  SHOP_MENU_ID_NAME,
15
14
  SECTION_HOME_TAB_NAME_TYPE,
16
15
  SECTION_HOME_TAB_TYPE,
17
16
  TaroEventType,
18
17
  WX_BUSINESS_TYPE,
19
18
  WXAPP_BIZ_KEY,
20
19
  WXAPP_BIZ_SHOP_LIGHT_KEY,
21
20
  getSystemInfos,
22
21
  getTaroStorageKeyValue,
23
22
  getWxAppCookieStr,
24
23
  objectToUrlEncode,
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
  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 wxAppAddressV2apiInstance: CommonInterFace.wxAppAddressV2api;
93
92
  public loadJsSdkList: Array<any>;
94
93
  public loadJsSdkListCachePromise: any;
95
94
  public lbsAddressCachePromise: Promise<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 = WXAPP_SUBS_GUIDER;
124
123
  this.wxAppAddressV2apiInstance = WXAPP_ADDRESS_V2_API;
125
124
  this.lbsAddressCachePromise = null;
126
125
  }
127
126
  _getConfig(opt) {
128
127
  return Object.assign({}, DefaultConfig, opt);
129
128
  }
130
129
 
131
130
  taskTimeoutPromise(callBack, timeout = 2000) {
132
131
  return new Promise((resolve) => {
133
132
  setTimeout(() => {
134
133
  const getCallBackRes = typeof callBack === 'function' && callBack();
135
134
  return resolve(getCallBackRes || false);
136
135
  }, timeout);
137
136
  });
138
137
  }
139
138
 
140
139
  updateBusinessDomainAndApi(domain, api) {
141
140
  console.log('=================>', 'updateBusinessDomainAndApi');
142
141
  }
143
142
 
144
143
  getFullScreenHeight(systemInfo) {
145
144
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
146
145
  let result = screenHeight;
147
146
  if (statusBarHeight > 20 && isAndroid) {
148
147
  result = screenHeight + statusBarHeight;
149
148
  }
150
149
  return result;
151
150
  }
152
151
 
153
152
  getTabBarHeight(systemInfo) {
154
153
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
155
154
  let result = 50;
156
155
  if (statusBarHeight > 20) {
157
156
  if (isIOS) {
158
157
  result = 84;
159
158
  } else if (isAndroid) {
160
159
  result = 53;
161
160
  }
162
161
  }
163
162
  return result;
164
163
  }
165
164
 
166
165
  getSystemInfo() {
167
166
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
168
167
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
169
168
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
170
169
  const fullScreenHeight = this.getFullScreenHeight(info);
171
170
  const tabBarHeight = this.getTabBarHeight(info);
172
171
  const safeContentHeight = fullScreenHeight - headerHeight;
173
172
  this.info.sysInfo = {
174
173
  ...this.info.sysInfo,
175
174
  ...info,
176
175
  actualNavBarHeight,
177
176
  headerHeight,
178
177
  fullScreenHeight,
179
178
  tabBarHeight,
180
179
  safeContentHeight,
181
180
  };
182
181
  if (this.info.sysInfo['hostVersionName']) {
183
182
  this.info.sysInfo['hostAppVersion'] = Number(
184
183
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
185
184
  );
186
185
  }
187
186
  if (isPublishToWxapp) {
188
187
  this.getAddressCachePromise();
189
188
  this.getLbsAddressCachePromise();
190
189
  }
191
190
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
192
191
  this.getNetWorkType();
193
192
  console.log('获取系统信息', this.info.sysInfo);
194
193
  }
195
194
  async updateMPaasConfig() {}
196
195
 
197
196
  getNetWorkType() {
198
197
  Taro.getNetworkType().then((getRes) => {
199
198
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
200
199
  });
201
200
  }
202
201
  getAPPUseStraightCorner() {
203
202
  return Promise.resolve(false);
204
203
  }
205
204
 
206
205
  checkStatusAndLogin(options = {}) {
207
206
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
208
207
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
209
208
  this.toLogin(options)
210
209
  .then((res) => {
211
210
  console.log('微信小程序登录状态结果,成功', res);
212
211
  this.info.loginState = true;
213
212
  resolve(res);
214
213
  })
215
214
  .catch((err) => {
216
215
  console.log('微信小程序登录异常状态结果', err);
217
216
  this.doLogin(options)
218
217
  .then((res2) => {
219
218
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
220
219
  this.info.loginState = true;
221
220
  resolve(res2);
222
221
  })
223
222
  .catch((err2) => {
224
223
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
225
224
  this.checkStatusAndLoginPromise = null;
226
225
  reject(err2);
227
226
  });
228
227
  });
229
228
  });
230
229
  return this.checkStatusAndLoginPromise;
231
230
  }
232
231
 
233
232
  checkJdStatusAndLogin(
234
233
  options = {
235
234
  loginColor: {
236
235
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
237
236
  dpin: 0,
238
237
  },
239
238
  },
240
239
  ) {
241
240
  return this.checkStatusAndLogin(options);
242
241
  }
243
242
 
244
243
  toLogin(options = {}): Promise<any> {
245
244
  return this.wxAppLoginInstance
246
245
  .getLoginPromise({
247
246
  mode: 'common',
248
247
  loginColor: {
249
248
  biz: WXAPP_BIZ_KEY,
250
249
  dpin: 1,
251
250
  },
252
251
  ...options,
253
252
  })
254
253
  .then((res) => {
255
254
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
256
255
  setTimeout(() => {
257
256
  console.log(
258
257
  '微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
259
258
  );
260
259
  this.getLoginCookie(`${Date.now()}`);
261
260
  }, 500);
262
261
  })
263
262
  .catch((err) => {
264
263
  console.log('微信app登录异常返回信息,也获取cookie', err);
265
264
  this.getLoginCookie(`${Date.now()}`);
266
265
  });
267
266
  }
268
267
 
269
268
  doLogin(options = {}) {
270
269
  const getParams = {
271
270
  loginColor: {
272
271
  biz: WXAPP_BIZ_KEY,
273
272
  dpin: 1,
274
273
  },
275
274
  ...options,
276
275
  };
277
276
  if (isPublishToWxapp) {
278
277
  getParams['returnUrl'] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
279
278
  ...this.info.originQueryInfo,
280
279
  loadShopxType: 'redirect',
281
280
  })}`;
282
281
  }
283
282
  return this.wxAppLoginInstance.doLogin(getParams).then((res) => {
284
283
  console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
285
284
  setTimeout(() => {
286
285
  console.log('微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie');
287
286
  this.getLoginCookie(`${Date.now()}`);
288
287
  }, 500);
289
288
  return res;
290
289
  });
291
290
  }
292
291
 
293
292
  doLoginForJdPin(options = {}) {
294
293
  return this.doLogin({
295
294
  loginColor: {
296
295
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
297
296
  dpin: 0,
298
297
  },
299
298
  ...options,
300
299
  });
301
300
  }
302
301
 
303
302
  getLoginCookie(updateKey = 'wxapp') {
304
303
  return new Promise(async (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
  if (this.miniAppLogInstance) {
328
327
  this.miniAppLogInstance.set({
329
328
  account: pin,
330
329
  unionid: wq_unionid,
331
330
  openid: wxapp_openid,
332
331
  });
333
332
  }
334
333
  this.config.wqCookie = wqCookie;
335
334
  this.config.wqCookieStr = wqCookieStr;
336
335
  this.config.getWqCookieKey = updateKey;
337
336
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
338
337
  resolve({
339
338
  wqCookie,
340
339
  wqCookieStr,
341
340
  });
342
341
  } else {
343
342
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
344
343
  resolve({
345
344
  wqCookie: false,
346
345
  wqCookieStr: false,
347
346
  });
348
347
  }
349
348
  } else {
350
349
  resolve({
351
350
  wqCookie: false,
352
351
  wqCookieStr: false,
353
352
  });
354
353
  }
355
354
  }
356
355
  });
357
356
  }
358
357
 
359
358
 
360
359
  checkLoginStatus() {
361
360
  return this.getLoginCookie();
362
361
  }
363
362
 
364
363
  getAddressCachePromise = () => {
365
364
  return new Promise((resolve) => {
366
365
  if (this.info.sysInfo?.area) {
367
366
  resolve({
368
367
  lat: this.info.sysInfo?.lat,
369
368
  lng: this.info.sysInfo?.lng,
370
369
  area: this.info.sysInfo?.area,
371
370
  });
372
371
  } else {
373
372
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
374
373
  console.info('京购原生获取用户基地址信息', getUserAddress);
375
374
  if (getUserAddress) {
376
375
  const { areaId = '', latitude, longitude } = getUserAddress;
377
376
  this.info.sysInfo['lat'] = `${latitude || ''}`;
378
377
  this.info.sysInfo['lng'] = `${longitude || ''}`;
379
378
  if (areaId && areaId !== '') {
380
379
  this.info.pageInfo.address = areaId;
381
380
  this.info.pageInfo.addressCommaStr = areaId.replace(/_/g, ',');
382
381
  this.info.pageInfo.un_area = areaId;
383
382
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
384
383
  area: areaId,
385
384
  });
386
385
  this.info.sysInfo['area'] = areaId;
387
386
  }
388
387
  resolve({
389
388
  lat: this.info.sysInfo['lat'],
390
389
  lng: this.info.sysInfo['lng'],
391
390
  area: areaId,
392
391
  });
393
392
  } else {
394
393
  resolve({ lat: '', lng: '', area: '' });
395
394
  }
396
395
  }
397
396
  });
398
397
  };
399
398
 
400
399
  getLbsAddressCachePromise(): Promise<{
401
400
  ok: boolean;
402
401
  msg?: string;
403
402
  realTimeArea: string;
404
403
  data?: any;
405
404
  }> {
406
405
  if (!this.lbsAddressCachePromise) {
407
406
  this.lbsAddressCachePromise = new Promise((resolve) => {
408
407
  const getWxappLbsAddressInfo = this.wxAppUserInfoInstance.getLbsAddress();
409
408
  console.info('京购原生获取用户基于lbs的缓存地址信息', getWxappLbsAddressInfo);
410
409
  if (getWxappLbsAddressInfo && getWxappLbsAddressInfo?.areaId !== '') {
411
410
  this.info.pageInfo.userLbsAddress = getWxappLbsAddressInfo?.areaId;
412
411
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
413
412
  realTimeArea: this.info.pageInfo.userLbsAddress,
414
413
  });
415
414
  resolve({
416
415
  ok: true,
417
416
  realTimeArea: getWxappLbsAddressInfo?.areaId || '',
418
417
  });
419
418
  } else {
420
419
  this.wxAppAddressV2apiInstance
421
420
  .fetchLbsAddr({
422
421
  token: 'W23b9sUlcnhCPZxQ2daYMkDqrTL0TeDw9tbDm5lVMVA=',
423
422
  from: 'wxapp_shop_real_area',
424
423
  })
425
424
  .then((res) => {
426
425
  console.info('微信京购里面获取静默实时lbs地址信息结果', res);
427
426
  const { provinceId, cityId, countyId, townId } = res;
428
427
  let realTimeArea = '';
429
428
  if (provinceId) {
430
429
  realTimeArea = `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
431
430
  this.info.pageInfo.userLbsAddress = realTimeArea;
432
431
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
433
432
  realTimeArea: realTimeArea,
434
433
  });
435
434
  } else {
436
435
  this.lbsAddressCachePromise = null;
437
436
  }
438
437
  const getValidRealTimeArea = realTimeArea !== '';
439
438
  resolve({
440
439
  ok: getValidRealTimeArea,
441
440
  msg: getValidRealTimeArea
442
441
  ? '成功'
443
442
  : '根据微信底层接口获取静默实时lbs地址信息异常,详情见data',
444
443
  data: getValidRealTimeArea ? null : res,
445
444
  realTimeArea: realTimeArea,
446
445
  });
447
446
  })
448
447
  .catch((err) => {
449
448
  console.warn('微信京购里面获取静默实时lbs地址信息异常', err);
450
449
  this.lbsAddressCachePromise = null;
451
450
  resolve({
452
451
  ok: false,
453
452
  msg: '微信京购里面获取静默实时lbs地址信息异常',
454
453
  realTimeArea: '',
455
454
  });
456
455
  });
457
456
  }
458
457
  });
459
458
  }
460
459
  return this.lbsAddressCachePromise;
461
460
  }
462
461
 
463
462
  updatePageAndLogInfo(updateQuery = {}) {
464
463
  const createUpdateQueryInfo: {
465
464
  query: {
466
465
  shopId?: string | number;
467
466
  venderId?: string | number;
468
467
  };
469
468
  updateShopInfoState: boolean;
470
469
  } = Object.assign(
471
470
  {},
472
471
  {
473
472
  query: {},
474
473
  updateShopInfoState: false,
475
474
  },
476
475
  updateQuery,
477
476
  );
478
477
  console.log(
479
478
  '获取当前下发的店铺查询参数',
480
479
  updateQuery,
481
480
  '获取之前保存的shopInfo店铺查询参数',
482
481
  this.info?.shopInfo,
483
482
  );
484
483
  const { query, updateShopInfoState } = createUpdateQueryInfo;
485
484
  const { shopId, venderId } = query;
486
485
  if (updateShopInfoState) {
487
486
  this.info.queryInfo = {
488
487
  ...this.info.queryInfo,
489
488
  ...query,
490
489
  };
491
490
  if (shopId && venderId) {
492
491
  this.info.shopInfo = {
493
492
  shopId: `${shopId}`,
494
493
  venderId: `${venderId}`,
495
494
  };
496
495
  }
497
496
  } else {
498
497
  this.info.queryInfo = {
499
498
  ...query,
500
499
  };
501
500
  this.info.originQueryInfo = {
502
501
  ...query,
503
502
  };
504
503
  if (
505
504
  this.info.shopInfo?.shopId &&
506
505
  this.info.shopInfo?.venderId &&
507
506
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
508
507
  ) {
509
508
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
510
509
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
511
510
  console.log(
512
511
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
513
512
  this.info.queryInfo,
514
513
  );
515
514
  }
516
515
  }
517
516
  this.info.queryInfo['shopId'] &&
518
517
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
519
518
  this.info.queryInfo['venderId'] &&
520
519
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
521
520
  console.log(
522
521
  'weapp===获取店铺下发查询参数\n',
523
522
  query,
524
523
  '\n获取店铺最后查询参数\n',
525
524
  this.info.queryInfo,
526
525
  '\n是否为更新店铺状态\n',
527
526
  updateShopInfoState,
528
527
  );
529
528
  }
530
529
 
531
530
  getDynamicConfig(key: string) {
532
531
  console.warn('调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!');
533
532
  return null;
534
533
  }
535
534
  renderNextTickLoadSdk() {
536
535
  console.warn('暂未实现 index.weapp.ts');
537
536
  }
538
537
  loadOtherSdk() {
539
538
  console.warn('暂未实现 index.weapp.ts');
540
539
  }
541
540
  loadItemSdkPromise() {
542
541
  console.warn('暂未实现 index.weapp.ts');
543
542
  }
543
+ import Taro from '@tarojs/taro';
544
544
  WXAPP_LOGIN,
545
545
  WXAPP_BIZ,
546
546
  WXAPP_USER_INFO,
547
547
  WXAPP_NAVIGATOR,
548
548
  WXAPP_REPORT_GDT,
549
549
  WXAPP_PARAMS_SIGN,
550
550
  WXAPP_FINGER_REPORT,
551
551
  WXAPP_REPORT_MANAGE,
552
552
  WXAPP_SUBS_GUIDER,
553
553
  WXAPP_ADDRESS_V2_API,
554
554
  BUSINESS_TYPE,
555
555
  SHOP_MENU_ID_TYPE,
556
556
  SHOP_MENU_ID_NAME,
557
557
  SECTION_HOME_TAB_NAME_TYPE,
558
558
  SECTION_HOME_TAB_TYPE,
559
559
  TaroEventType,
560
560
  WX_BUSINESS_TYPE,
561
561
  WXAPP_BIZ_KEY,
562
562
  WXAPP_BIZ_SHOP_LIGHT_KEY,
563
563
  getSystemInfos,
564
564
  getTaroStorageKeyValue,
565
565
  getWxAppCookieStr,
566
566
  objectToUrlEncode,
567
567
  languageNowType,
568
568
  isAscfApp,
569
569
  abTestLabels: {},
570
570
  nonSellableSkuids: {},
571
571
  loginState: jdUserLoginState,
572
572
  cookiesStr: '',
573
573
  userInfo: userPinKey,
574
574
  isImmersive: false,
575
575
  baseAddCartSwitch: true,
576
576
  pageInfo: {
577
577
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
578
578
  address: '',
579
579
  addressCommaStr: '',
580
580
  un_area: '',
581
581
  fullAddress: '',
582
582
  userLbsAddress: '',
583
583
  vapptype: '1',
584
584
  pageType: 'home',
585
585
  dataType: BUSINESS_TYPE.ONLINE,
586
586
  floorExposureInfo: {},
587
587
  floorVideInfo: {},
588
588
  productVideInfo: {},
589
589
  tabsLoadAllDataInfo: {
590
590
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
591
591
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
592
592
  },
593
593
  updateShopInfosAllState: false,
594
594
  isVipShop: false,
595
595
  isJdShowNativeImmersivePlayer: false,
596
596
  isSuperBrandShop: false,
597
597
  ...shopConfig,
598
598
  pageScrollTop: 0,
599
599
  pageIdxHeightInfo: {
600
600
  list: [],
601
601
  },
602
602
  shopNavBarHeight: 0,
603
603
  },
604
604
  defaultQueryLogInfo: {
605
605
  sourceType: 'JDshop',
606
606
  sourceValue: '',
607
607
  moduleId: 'none',
608
608
  entrance: 'none',
609
609
  },
610
610
  originQueryInfo: {},
611
611
  sysInfo: {
612
612
  windowWidth: 0,
613
613
  windowHeight: 0,
614
614
  netWorkType: '4g',
615
615
  jdBottomBarHeight: 0,
616
616
  jdNativeHeaderHeight: 0,
617
617
  },
618
618
  queryInfo: {},
619
619
  shopInfo: {},
620
620
  openAppData: {},
621
621
  public info: CommonInterFace.BaseConfigInfo;
622
622
  public config: {
623
623
  [key: string]: any;
624
624
  };
625
625
  public lazyContainer: CommonInterFace.lazyContainer;
626
626
  public rootEleNode: HTMLElement | null;
627
627
  public miniApplogUtil: CommonInterFace.MiniApplogUtil;
628
628
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
629
629
  public checkStatusAndLoginPromise: object | null;
630
630
  public wxAppLoginInstance: CommonInterFace.WxAppLogin;
631
631
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
632
632
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
633
633
  public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
634
634
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
635
635
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
636
636
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
637
637
  public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
638
638
  public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
639
639
  public wxAppAddressV2apiInstance: CommonInterFace.wxAppAddressV2api;
640
640
  public loadJsSdkList: Array<any>;
641
641
  public loadJsSdkListCachePromise: any;
642
642
  public lbsAddressCachePromise: Promise<any> | null;
643
643
  public languageJsonData: any | null;
644
644
  public businessWorkerReady: boolean;
645
645
  public jdWorkerReadyPromise: any | null;
646
646
  constructor(opt) {
647
647
  this.info = this._getConfig(opt);
648
648
  this.config = {};
649
649
  this.lazyContainer = {
650
650
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
651
651
  appLazyContainerList: [],
652
652
  appLazyFinishContainerList: [],
653
653
  },
654
654
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
655
655
  appLazyContainerList: [],
656
656
  appLazyFinishContainerList: [],
657
657
  },
658
658
  };
659
659
  this.loadJsSdkList = [];
660
660
  this.loadJsSdkListCachePromise = {};
661
661
  this.rootEleNode = null;
662
662
  this.miniApplogUtil = MiniAppLogUtil;
663
663
  this.miniAppLogInstance = null;
664
664
  this.checkStatusAndLoginPromise = null;
665
665
  this.wxAppLoginInstance = WXAPP_LOGIN;
666
666
  this.wxAppBizInstance = WXAPP_BIZ;
667
667
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
668
668
  this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
669
669
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
670
670
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
671
671
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
672
672
  this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT ? new WXAPP_FINGER_REPORT() : {};
673
673
  this.wxAppSubsGuider = WXAPP_SUBS_GUIDER;
674
674
  this.wxAppAddressV2apiInstance = WXAPP_ADDRESS_V2_API;
675
675
  this.lbsAddressCachePromise = null;
676
676
  this.languageJsonData = langeJsonDataForCn;
677
677
  this.businessWorkerReady = false;
678
678
  this.jdWorkerReadyPromise = Promise.resolve(false);
679
679
  }
680
680
  _getConfig(opt) {
681
681
  return Object.assign({}, DefaultConfig, opt);
682
682
  }
683
683
  loadApiSafeSteadyReayPromise() {
684
684
  return Promise.resolve(true);
685
685
  }
686
686
  loadH5tagReayPromise() {
687
687
  return Promise.resolve(true);
688
688
  }
689
689
 
690
690
  jmfeReayPromise(): Promise<any> {
691
691
  return Promise.reject(false);
692
692
  }
693
693
 
694
694
  taskTimeoutPromise(callBack, timeout = 2000) {
695
695
  return new Promise((resolve) => {
696
696
  setTimeout(() => {
697
697
  const getCallBackRes = typeof callBack === 'function' && callBack();
698
698
  return resolve(getCallBackRes || false);
699
699
  }, timeout);
700
700
  });
701
701
  }
702
702
 
703
703
  updateBusinessDomainAndApi(domain, api) {
704
704
  console.log('=================>', 'updateBusinessDomainAndApi');
705
705
  }
706
706
 
707
707
  getFullScreenHeight(systemInfo) {
708
708
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
709
709
  let result = screenHeight;
710
710
  if (statusBarHeight > 20 && isAndroid) {
711
711
  result = screenHeight + statusBarHeight;
712
712
  }
713
713
  return result;
714
714
  }
715
715
 
716
716
  getTabBarHeight(systemInfo) {
717
717
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
718
718
  let result = 50;
719
719
  if (statusBarHeight > 20) {
720
720
  if (isIOS) {
721
721
  result = 84;
722
722
  } else if (isAndroid) {
723
723
  result = 53;
724
724
  }
725
725
  }
726
726
  return result;
727
727
  }
728
728
 
729
729
  getSystemInfo() {
730
730
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
731
731
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
732
732
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
733
733
  const fullScreenHeight = this.getFullScreenHeight(info);
734
734
  const tabBarHeight = this.getTabBarHeight(info);
735
735
  const safeContentHeight = fullScreenHeight - headerHeight;
736
736
  this.info.sysInfo = {
737
737
  ...this.info.sysInfo,
738
738
  ...info,
739
739
  actualNavBarHeight,
740
740
  headerHeight,
741
741
  fullScreenHeight,
742
742
  tabBarHeight,
743
743
  safeContentHeight,
744
744
  languageType: languageNowType,
745
745
  };
746
746
  if (this.info.sysInfo['hostVersionName']) {
747
747
  this.info.sysInfo['hostAppVersion'] = Number(
748
748
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
749
749
  );
750
750
  }
751
751
  if (isPublishToWxapp) {
752
752
  this.getAddressCachePromise();
753
753
  this.getLbsAddressCachePromise();
754
754
  }
755
755
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
756
756
  this.getNetWorkType();
757
757
  console.log('获取系统信息', this.info.sysInfo);
758
758
  }
759
759
  async updateMPaasConfig() {}
760
760
 
761
761
  getNetWorkType() {
762
762
  Taro.getNetworkType().then((getRes) => {
763
763
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
764
764
  });
765
765
  }
766
766
  getAPPUseStraightCorner() {
767
767
  return Promise.resolve(false);
768
768
  }
769
769
 
770
770
  checkStatusAndLogin(options = {}) {
771
771
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
772
772
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
773
773
  this.toLogin(options)
774
774
  .then((res) => {
775
775
  console.log('微信小程序登录状态结果,成功', res);
776
776
  this.info.loginState = true;
777
777
  resolve(res);
778
778
  })
779
779
  .catch((err) => {
780
780
  console.log('微信小程序登录异常状态结果', err);
781
781
  this.doLogin(options)
782
782
  .then((res2) => {
783
783
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
784
784
  this.info.loginState = true;
785
785
  resolve(res2);
786
786
  })
787
787
  .catch((err2) => {
788
788
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
789
789
  this.checkStatusAndLoginPromise = null;
790
790
  reject(err2);
791
791
  });
792
792
  });
793
793
  });
794
794
  return this.checkStatusAndLoginPromise;
795
795
  }
796
796
 
797
797
  checkJdStatusAndLogin(
798
798
  options = {
799
799
  loginColor: {
800
800
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
801
801
  dpin: 0,
802
802
  },
803
803
  },
804
804
  ) {
805
805
  return this.checkStatusAndLogin(options);
806
806
  }
807
807
 
808
808
  toLogin(options = {}): Promise<any> {
809
809
  return this.wxAppLoginInstance
810
810
  .getLoginPromise({
811
811
  mode: 'common',
812
812
  loginColor: {
813
813
  biz: WXAPP_BIZ_KEY,
814
814
  dpin: 1,
815
815
  },
816
816
  ...options,
817
817
  })
818
818
  .then((res) => {
819
819
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
820
820
  setTimeout(() => {
821
821
  console.log(
822
822
  '微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
823
823
  );
824
824
  this.getLoginCookie(`${Date.now()}`);
825
825
  }, 500);
826
826
  })
827
827
  .catch((err) => {
828
828
  console.log('微信app登录异常返回信息,也获取cookie', err);
829
829
  this.getLoginCookie(`${Date.now()}`);
830
830
  });
831
831
  }
832
832
 
833
833
  doLogin(options = {}) {
834
834
  const getParams = {
835
835
  loginColor: {
836
836
  biz: WXAPP_BIZ_KEY,
837
837
  dpin: 1,
838
838
  },
839
839
  ...options,
840
840
  };
841
841
  if (isPublishToWxapp) {
842
842
  getParams['returnUrl'] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
843
843
  ...this.info.originQueryInfo,
844
844
  loadShopxType: 'redirect',
845
845
  })}`;
846
846
  }
847
847
  return this.wxAppLoginInstance.doLogin(getParams).then((res) => {
848
848
  console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
849
849
  setTimeout(() => {
850
850
  console.log('微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie');
851
851
  this.getLoginCookie(`${Date.now()}`);
852
852
  }, 500);
853
853
  return res;
854
854
  });
855
855
  }
856
856
 
857
857
  doLoginForJdPin(options = {}) {
858
858
  return this.doLogin({
859
859
  loginColor: {
860
860
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
861
861
  dpin: 0,
862
862
  },
863
863
  ...options,
864
864
  });
865
865
  }
866
866
 
867
867
  getLoginCookie(updateKey = 'wxapp') {
868
868
  return new Promise(async (resolve) => {
869
869
  console.log('开始获取更新wxapp中的cookie信息', updateKey);
870
870
  if (
871
871
  this.config.wqCookie &&
872
872
  this.config.wqCookieStr &&
873
873
  this.config.getWqCookieKey === updateKey
874
874
  ) {
875
875
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
876
876
  resolve({
877
877
  wqCookie: this.config.wqCookie,
878
878
  wqCookieStr: this.config.wqCookieStr,
879
879
  });
880
880
  } else {
881
881
  if (isPublishToWxapp) {
882
882
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
883
883
  if (getWxappCookieObj) {
884
884
  const getCookieObj = getWxappCookieObj['_data'];
885
885
  if (isAscfApp) {
886
886
  const ptKey = this.wxAppLoginInstance.getPtKey();
887
887
  const ptPin = this.wxAppLoginInstance.getPtPin();
888
888
  getCookieObj.pt_key = { name: 'pt_key', value: ptKey };
889
889
  getCookieObj.pt_pin = { name: 'pt_pin', value: ptPin };
890
890
  }
891
891
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
892
892
  const {
893
893
  pin = '',
894
894
  pt_pin = '',
895
895
  visitkey = '-1',
896
896
  wq_unionid = '',
897
897
  wxapp_openid = '',
898
898
  } = wqCookie;
899
899
  this.info.loginState = true;
900
900
  this.info.userInfo.wqCookie = wqCookieStr;
901
901
  this.info.userInfo.wqVisitkey = visitkey;
902
902
  console.log('获取用户完整cookie信息', getCookieObj);
903
903
  if (this.miniAppLogInstance && this.miniAppLogInstance.setCommon) {
904
904
  this.miniAppLogInstance.setCommon({
905
905
  account: pin || pt_pin,
906
906
  unionid: wq_unionid,
907
907
  openid: wxapp_openid,
908
908
  });
909
909
  }
910
910
  this.config.wqCookie = wqCookie;
911
911
  this.config.wqCookieStr = wqCookieStr;
912
912
  this.config.getWqCookieKey = updateKey;
913
913
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
914
914
  resolve({
915
915
  wqCookie,
916
916
  wqCookieStr,
917
917
  });
918
918
  } else {
919
919
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
920
920
  resolve({
921
921
  wqCookie: false,
922
922
  wqCookieStr: false,
923
923
  });
924
924
  }
925
925
  } else {
926
926
  resolve({
927
927
  wqCookie: false,
928
928
  wqCookieStr: false,
929
929
  });
930
930
  }
931
931
  }
932
932
  });
933
933
  }
934
934
 
935
935
 
936
936
  checkLoginStatus() {
937
937
  return this.getLoginCookie();
938
938
  }
939
939
 
940
940
  getAddressCachePromise = () => {
941
941
  return new Promise((resolve) => {
942
942
  if (this.info.sysInfo?.area) {
943
943
  resolve({
944
944
  lat: this.info.sysInfo?.lat,
945
945
  lng: this.info.sysInfo?.lng,
946
946
  area: this.info.sysInfo?.area,
947
947
  fullAddress: this?.info?.pageInfo?.fullAddress,
948
948
  });
949
949
  } else {
950
950
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
951
951
  if (getUserAddress) {
952
952
  const { areaId = '', addressName, latitude, longitude } = getUserAddress;
953
953
  this.info.sysInfo['lat'] = `${latitude || ''}`;
954
954
  this.info.sysInfo['lng'] = `${longitude || ''}`;
955
955
  const getEncodeFullAddress = addressName ? encodeURIComponent(addressName) : "";
956
956
  if (areaId && areaId !== '') {
957
957
  this.info.pageInfo.address = areaId;
958
958
  this.info.pageInfo.addressCommaStr = areaId.replace(/_/g, ',');
959
959
  this.info.pageInfo.un_area = areaId;
960
960
  const getUpdateData = {
961
961
  area: areaId,
962
962
  }
963
963
  if(addressName && addressName.length > 0) {
964
964
  getUpdateData.fullAddress = getEncodeFullAddress;
965
965
  this.info.pageInfo.fullAddress = getEncodeFullAddress;
966
966
  }
967
967
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, getUpdateData);
968
968
  this.info.sysInfo['area'] = areaId;
969
969
  }
970
970
  resolve({
971
971
  lat: this.info.sysInfo['lat'],
972
972
  lng: this.info.sysInfo['lng'],
973
973
  fullAddress: getEncodeFullAddress,
974
974
  area: areaId,
975
975
  });
976
976
  } else {
977
977
  resolve({ lat: '', lng: '', area: '', fullAddress: "" });
978
978
  }
979
979
  }
980
980
  });
981
981
  };
982
982
 
983
983
  getLbsAddressCachePromise(): Promise<{
984
984
  ok: boolean;
985
985
  msg?: string;
986
986
  realTimeArea: string;
987
987
  data?: any;
988
988
  }> {
989
989
  if (!this.lbsAddressCachePromise) {
990
990
  this.lbsAddressCachePromise = new Promise((resolve) => {
991
991
  const getWxappLbsAddressInfo = this.wxAppUserInfoInstance.getLbsAddress();
992
992
  console.info('京购原生获取用户基于lbs的缓存地址信息', getWxappLbsAddressInfo);
993
993
  if (getWxappLbsAddressInfo && getWxappLbsAddressInfo?.areaId !== '') {
994
994
  this.info.pageInfo.userLbsAddress = getWxappLbsAddressInfo?.areaId;
995
995
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
996
996
  realTimeArea: this.info.pageInfo.userLbsAddress,
997
997
  });
998
998
  resolve({
999
999
  ok: true,
1000
1000
  realTimeArea: getWxappLbsAddressInfo?.areaId || '',
1001
1001
  });
1002
1002
  } else {
1003
1003
  this.wxAppAddressV2apiInstance
1004
1004
  .fetchLbsAddr({
1005
1005
  token: 'W23b9sUlcnhCPZxQ2daYMkDqrTL0TeDw9tbDm5lVMVA=',
1006
1006
  from: 'wxapp_shop_real_area',
1007
1007
  })
1008
1008
  .then((res) => {
1009
1009
  console.info('微信京购里面获取静默实时lbs地址信息结果', res);
1010
1010
  const { provinceId, cityId, countyId, townId } = res;
1011
1011
  let realTimeArea = '';
1012
1012
  if (provinceId) {
1013
1013
  realTimeArea = `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
1014
1014
  this.info.pageInfo.userLbsAddress = realTimeArea;
1015
1015
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
1016
1016
  realTimeArea: realTimeArea,
1017
1017
  });
1018
1018
  } else {
1019
1019
  this.lbsAddressCachePromise = null;
1020
1020
  }
1021
1021
  const getValidRealTimeArea = realTimeArea !== '';
1022
1022
  resolve({
1023
1023
  ok: getValidRealTimeArea,
1024
1024
  msg: getValidRealTimeArea
1025
1025
  ? '成功'
1026
1026
  : '根据微信底层接口获取静默实时lbs地址信息异常,详情见data',
1027
1027
  data: getValidRealTimeArea ? null : res,
1028
1028
  realTimeArea: realTimeArea,
1029
1029
  });
1030
1030
  })
1031
1031
  .catch((err) => {
1032
1032
  console.warn('微信京购里面获取静默实时lbs地址信息异常', err);
1033
1033
  this.lbsAddressCachePromise = null;
1034
1034
  resolve({
1035
1035
  ok: false,
1036
1036
  msg: '微信京购里面获取静默实时lbs地址信息异常',
1037
1037
  realTimeArea: '',
1038
1038
  });
1039
1039
  });
1040
1040
  }
1041
1041
  });
1042
1042
  }
1043
1043
  return this.lbsAddressCachePromise;
1044
1044
  }
1045
1045
 
1046
1046
  updatePageAndLogInfo(updateQuery = {}) {
1047
1047
  const createUpdateQueryInfo: {
1048
1048
  query: {
1049
1049
  shopId?: string | number;
1050
1050
  venderId?: string | number;
1051
1051
  };
1052
1052
  updateShopInfoState: boolean;
1053
1053
  } = Object.assign(
1054
1054
  {},
1055
1055
  {
1056
1056
  query: {},
1057
1057
  updateShopInfoState: false,
1058
1058
  },
1059
1059
  updateQuery,
1060
1060
  );
1061
1061
  console.log(
1062
1062
  '获取当前下发的店铺查询参数',
1063
1063
  updateQuery,
1064
1064
  '获取之前保存的shopInfo店铺查询参数',
1065
1065
  this.info?.shopInfo,
1066
1066
  );
1067
1067
  const { query, updateShopInfoState } = createUpdateQueryInfo;
1068
1068
  const { shopId, venderId } = query;
1069
1069
  if (updateShopInfoState) {
1070
1070
  this.info.queryInfo = {
1071
1071
  ...this.info.queryInfo,
1072
1072
  ...query,
1073
1073
  };
1074
1074
  if (shopId && venderId) {
1075
1075
  this.info.shopInfo = {
1076
1076
  shopId: `${shopId}`,
1077
1077
  venderId: `${venderId}`,
1078
1078
  };
1079
1079
  }
1080
1080
  } else {
1081
1081
  this.info.queryInfo = {
1082
1082
  ...query,
1083
1083
  };
1084
1084
  this.info.originQueryInfo = {
1085
1085
  ...query,
1086
1086
  };
1087
1087
  if (
1088
1088
  this.info.shopInfo?.shopId &&
1089
1089
  this.info.shopInfo?.venderId &&
1090
1090
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
1091
1091
  ) {
1092
1092
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
1093
1093
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
1094
1094
  console.log(
1095
1095
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
1096
1096
  this.info.queryInfo,
1097
1097
  );
1098
1098
  }
1099
1099
  }
1100
1100
  this.info.queryInfo['shopId'] &&
1101
1101
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
1102
1102
  this.info.queryInfo['venderId'] &&
1103
1103
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
1104
1104
  console.log(
1105
1105
  'weapp===获取店铺下发查询参数\n',
1106
1106
  query,
1107
1107
  '\n获取店铺最后查询参数\n',
1108
1108
  this.info.queryInfo,
1109
1109
  '\n是否为更新店铺状态\n',
1110
1110
  updateShopInfoState,
1111
1111
  );
1112
1112
  }
1113
1113
 
1114
1114
  getDynamicConfig(key: string) {
1115
1115
  console.warn('调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!');
1116
1116
  return null;
1117
1117
  }
1118
1118
  renderNextTickLoadSdk() {
1119
1119
  console.warn('暂未实现 index.weapp.ts');
1120
1120
  }
1121
1121
  loadOtherSdk() {
1122
1122
  console.warn('暂未实现 index.weapp.ts');
1123
1123
  }
1124
1124
  loadItemSdkPromise() {
1125
1125
  console.warn('暂未实现 index.weapp.ts');
1126
1126
  }
1127
1127
  createLanguageProimse() {
1128
1128
  return Promise.reject({
1129
1129
  msg: '暂未实现',
1130
1130
  });
1131
1131
  }