@conecli/cone-render 0.9.1-shop2.16 → 0.9.1-shop2.18

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