@conecli/cone-render 0.10.1-shop3.16 → 0.10.1-shop3.18

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