@conecli/cone-render 0.9.1-shop2.27 → 0.9.1-shop2.29

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