@conecli/cone-render 0.9.1-shop2.19 → 0.9.1-shop2.20

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