@conecli/cone-render 0.10.1-shop-beta.5 → 0.10.1-shop3.0

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