@conecli/cone-render 0.8.44 → 0.8.46-beta.0

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