@conecli/cone-render 0.9.1-shop2.38 → 0.9.1-shop2.39

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