@conecli/cone-render 0.10.1-shop-beta.11 → 0.10.1-shop-beta.13

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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.dynamic.ts +1 -0
  4. package/dist/common/index.h5.ts +1 -1
  5. package/dist/common/index.jd.ts +1 -1
  6. package/dist/common/index.ts +1 -1
  7. package/dist/common/index.weapp.ts +1 -1
  8. package/dist/common/jssdk.ts +1 -1
  9. package/dist/common/token/index.h5.ts +1 -1
  10. package/dist/common/wxappApi.ts +1 -1
  11. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  12. package/dist/components/base/CountDown/index.tsx +1 -1
  13. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  14. package/dist/components/base/Dialog/index.dynamic.module.scss +126 -0
  15. package/dist/components/base/Dialog/index.dynamic.tsx +1 -0
  16. package/dist/components/base/DynamicTest/index.dynamic.module.scss +15 -0
  17. package/dist/components/base/DynamicTest/index.module.scss +16 -0
  18. package/dist/components/base/DynamicTest/index.tsx +1 -0
  19. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  20. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  21. package/dist/components/base/JdLoading/index.module.scss +2 -0
  22. package/dist/components/base/JdLoading/index.tsx +1 -1
  23. package/dist/components/base/LazyLoadImage/index.tsx +1 -1
  24. package/dist/components/base/NetworkDataError/const.ts +1 -1
  25. package/dist/components/base/NetworkDataError/index.module.scss +116 -70
  26. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  27. package/dist/components/base/Price/Base/index.dynamic.module.scss +63 -0
  28. package/dist/components/base/Price/Base/index.dynamic.tsx +1 -0
  29. package/dist/components/base/Price/Base/index.module.scss +6 -0
  30. package/dist/components/base/Price/Base/index.tsx +1 -1
  31. package/dist/components/base/Price/Double/index.dynamic.module.scss +172 -0
  32. package/dist/components/base/Price/Double/index.dynamic.tsx +1 -0
  33. package/dist/components/base/Price/Double/index.module.scss +6 -0
  34. package/dist/components/base/Price/Double/index.tsx +1 -1
  35. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  36. package/dist/config/env.ts +1 -1
  37. package/dist/interface/common.ts +1 -1
  38. package/dist/interface/component.ts +1 -1
  39. package/dist/interface/jumpEventReport.ts +1 -1
  40. package/dist/jumpEventReport/const.ts +1 -1
  41. package/dist/jumpEventReport/index.dynamic.ts +1 -0
  42. package/dist/jumpEventReport/index.h5.ts +1 -1
  43. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  44. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  45. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  46. package/dist/jumpEventReport/web.base.ts +1 -1
  47. package/dist/jumpEventReport/web.jd.ts +1 -1
  48. package/dist/language/zh_CN.json +162 -0
  49. package/dist/open/api/index.ts +1 -1
  50. package/dist/open/api/shopMember.dynamic.ts +1 -0
  51. package/dist/open/api/shopMember.ts +1 -1
  52. package/dist/open/components/index.dynamic.ts +1 -0
  53. package/dist/open/components/index.ts +1 -1
  54. package/dist/sass/app.dynamic.scss +306 -0
  55. package/dist/service/fetchGateway.h5.ts +1 -0
  56. package/dist/service/fetchGateway.ts +1 -1
  57. package/dist/service/fetchGateway.weapp.ts +1 -1
  58. package/dist/service/fetchJsonp.h5.ts +1 -0
  59. package/dist/service/fetchJsonp.ts +1 -1
  60. package/dist/service/http/colorSign.dynamic.ts +1 -0
  61. package/dist/service/http/http.ts +1 -1
  62. package/dist/service/requestServer.h5.ts +1 -1
  63. package/dist/service/requestServer.ts +1 -1
  64. package/dist/service/requestServer.weapp.ts +1 -1
  65. package/dist/utils/connectNativeJsBridge.dynamic.ts +1 -0
  66. package/dist/utils/connectNativeJsBridge.ts +1 -1
  67. package/dist/utils/h5Utils.ts +1 -1
  68. package/dist/utils/index.h5.ts +1 -1
  69. package/dist/utils/index.ts +1 -1
  70. package/dist/utils/index.weapp.ts +1 -1
  71. package/dist/utils/intersectionObserver.ts +1 -1
  72. package/dist/utils/jumpExtMapUtil.ts +1 -0
  73. package/dist/utils/log.ts +1 -0
  74. package/dist/utils/utils.ts +1 -1
  75. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  76. package/dist/wxapp/common/user_info.js +1 -1
  77. package/package.json +51 -31
  78. /package/dist/utils/{jumpExtMapUtil.js → jumpExtMapUtil.h5.ts} +0 -0
@@ -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
  languageNowType,
507
507
  abTestLabels: {},
508
508
  nonSellableSkuids: {},
509
509
  loginState: jdUserLoginState,
510
510
  cookiesStr: '',
511
511
  userInfo: userPinKey,
512
512
  isImmersive: false,
513
513
  pageInfo: {
514
514
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
515
515
  address: '',
516
516
  addressCommaStr: '',
517
517
  un_area: '',
518
518
  userLbsAddress: '',
519
519
  vapptype: '1',
520
520
  pageType: 'home',
521
521
  dataType: BUSINESS_TYPE.ONLINE,
522
522
  floorExposureInfo: {},
523
523
  floorVideInfo: {},
524
524
  productVideInfo: {},
525
525
  tabsLoadAllDataInfo: {
526
526
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
527
527
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
528
528
  },
529
529
  updateShopInfosAllState: false,
530
530
  isVipShop: false,
531
531
  isJdShowNativeImmersivePlayer: false,
532
532
  ...shopConfig,
533
533
  pageScrollTop: 0,
534
534
  pageIdxHeightInfo: {
535
535
  list: [],
536
536
  },
537
537
  shopNavBarHeight: 0,
538
538
  },
539
539
  defaultQueryLogInfo: {
540
540
  sourceType: 'JDshop',
541
541
  sourceValue: '',
542
542
  moduleId: 'none',
543
543
  entrance: 'none',
544
544
  },
545
545
  originQueryInfo: {},
546
546
  sysInfo: {
547
547
  windowWidth: 0,
548
548
  windowHeight: 0,
549
549
  eid: appEid,
550
550
  netWorkType: '4g',
551
551
  jdBottomBarHeight: 0,
552
552
  jdNativeHeaderHeight: 0,
553
553
  },
554
554
  queryInfo: {},
555
555
  shopInfo: {},
556
556
  openAppData: {},
557
557
  public info: CommonInterFace.BaseConfigInfo;
558
558
  public config: {
559
559
  [key: string]: any;
560
560
  };
561
561
  public lazyContainer: CommonInterFace.lazyContainer;
562
562
  public rootEleNode: HTMLElement | null;
563
563
  public miniApplogUtil: CommonInterFace.MiniApplogUtil;
564
564
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
565
565
  public checkStatusAndLoginPromise: object | null;
566
566
  public wxAppLoginInstance: CommonInterFace.WxAppLogin;
567
567
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
568
568
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
569
569
  public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
570
570
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
571
571
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
572
572
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
573
573
  public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
574
574
  public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
575
575
  public loadJsSdkList: Array<any>;
576
576
  public loadJsSdkListCachePromise: any;
577
577
  public languageJsonData: any | null;
578
578
  constructor(opt) {
579
579
  this.info = this._getConfig(opt);
580
580
  this.config = {};
581
581
  this.lazyContainer = {
582
582
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
583
583
  appLazyContainerList: [],
584
584
  appLazyFinishContainerList: [],
585
585
  },
586
586
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
587
587
  appLazyContainerList: [],
588
588
  appLazyFinishContainerList: [],
589
589
  },
590
590
  };
591
591
  this.loadJsSdkList = [];
592
592
  this.loadJsSdkListCachePromise = {};
593
593
  this.rootEleNode = null;
594
594
  this.miniApplogUtil = MiniAppLogUtil;
595
595
  this.miniAppLogInstance = null;
596
596
  this.checkStatusAndLoginPromise = null;
597
597
  this.wxAppLoginInstance = WXAPP_LOGIN;
598
598
  this.wxAppBizInstance = WXAPP_BIZ;
599
599
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
600
600
  this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
601
601
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
602
602
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
603
603
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
604
604
  this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT ? new WXAPP_FINGER_REPORT() : {};
605
605
  this.wxAppSubsGuider = null;
606
606
  this.languageJsonData = langeJsonDataForCn;
607
607
  }
608
608
  _getConfig(opt) {
609
609
  return Object.assign({}, DefaultConfig, opt);
610
610
  }
611
611
 
612
612
  taskTimeoutPromise(callBack, timeout = 2000) {
613
613
  return new Promise((resolve) => {
614
614
  setTimeout(() => {
615
615
  const getCallBackRes = typeof callBack === 'function' && callBack();
616
616
  return resolve(getCallBackRes || false);
617
617
  }, timeout);
618
618
  });
619
619
  }
620
620
 
621
621
  updateBusinessDomainAndApi(domain, api) {
622
622
  }
623
623
 
624
624
  getFullScreenHeight(systemInfo) {
625
625
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
626
626
  let result = screenHeight;
627
627
  if (statusBarHeight > 20 && isAndroid) {
628
628
  result = screenHeight + statusBarHeight;
629
629
  }
630
630
  return result;
631
631
  }
632
632
 
633
633
  getTabBarHeight(systemInfo) {
634
634
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
635
635
  let result = 50;
636
636
  if (statusBarHeight > 20) {
637
637
  if (isIOS) {
638
638
  result = 84;
639
639
  } else if (isAndroid) {
640
640
  result = 53;
641
641
  }
642
642
  }
643
643
  return result;
644
644
  }
645
645
 
646
646
  getSystemInfo() {
647
647
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
648
648
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
649
649
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
650
650
  const fullScreenHeight = this.getFullScreenHeight(info);
651
651
  const tabBarHeight = this.getTabBarHeight(info);
652
652
  const safeContentHeight = fullScreenHeight - headerHeight;
653
653
  this.info.sysInfo = {
654
654
  ...this.info.sysInfo,
655
655
  ...info,
656
656
  actualNavBarHeight,
657
657
  headerHeight,
658
658
  fullScreenHeight,
659
659
  tabBarHeight,
660
660
  safeContentHeight,
661
661
  languageType: languageNowType,
662
662
  };
663
663
  this.getEid().then((res: { eid: string }) => {
664
664
  res && res.eid && (this.info.sysInfo['eid'] = res.eid);
665
665
  });
666
666
  if (this.info.sysInfo['hostVersionName']) {
667
667
  this.info.sysInfo['hostAppVersion'] = Number(
668
668
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
669
669
  );
670
670
  }
671
671
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
672
672
  this.getNetWorkType();
673
673
  }
674
674
  async updateMPaasConfig() {}
675
675
 
676
676
  getNetWorkType() {
677
677
  Taro.getNetworkType().then((getRes) => {
678
678
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
679
679
  });
680
680
  }
681
681
  getAPPUseStraightCorner() {
682
682
  return Promise.resolve(false);
683
683
  }
684
684
 
685
685
  checkStatusAndLogin(options = {}) {
686
686
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
687
687
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
688
688
  this.toLogin(options)
689
689
  .then((res) => {
690
690
  console.log('微信小程序登录状态结果,成功', res);
691
691
  this.info.loginState = true;
692
692
  resolve(res);
693
693
  })
694
694
  .catch((err) => {
695
695
  console.log('微信小程序登录异常状态结果', err);
696
696
  this.doLogin(options)
697
697
  .then((res2) => {
698
698
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
699
699
  this.info.loginState = true;
700
700
  resolve(res2);
701
701
  })
702
702
  .catch((err2) => {
703
703
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
704
704
  this.checkStatusAndLoginPromise = null;
705
705
  reject(err2);
706
706
  });
707
707
  });
708
708
  });
709
709
  return this.checkStatusAndLoginPromise;
710
710
  }
711
711
 
712
712
  checkJdStatusAndLogin(options) {
713
713
  return this.checkStatusAndLogin(options);
714
714
  }
715
715
 
716
716
 
717
717
  doLoginForJdPin(options = {}) {
718
718
  return this.doLogin(options);
719
719
  }
720
720
 
721
721
  getEid() {
722
722
  if (typeof jd !== 'undefined' && jd.getEid) {
723
723
  return new Promise((resolve, reject) => {
724
724
  jd.getEid({
725
725
  success: (res: { eid: string }) => {
726
726
  resolve(res);
727
727
  },
728
728
  fail: (err: any) => {
729
729
  reject(err);
730
730
  },
731
731
  });
732
732
  });
733
733
  } else {
734
734
  return Promise.resolve(false);
735
735
  }
736
736
  }
737
737
 
738
738
  toLogin(options = {}): Promise<any> {
739
739
  return this.wxAppLoginInstance
740
740
  .getLoginPromise({
741
741
  mode: 'silent',
742
742
  loginColor: {
743
743
  biz: WXAPP_BIZ_KEY,
744
744
  dpin: 0,
745
745
  },
746
746
  ...options,
747
747
  })
748
748
  .then((res) => {
749
749
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
750
750
  setTimeout(() => {
751
751
  console.log(
752
752
  '微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
753
753
  );
754
754
  this.getLoginCookie(`${Date.now()}`);
755
755
  }, 500);
756
756
  })
757
757
  .catch((err) => {
758
758
  console.log('微信app登录异常返回信息,也获取cookie', err);
759
759
  this.getLoginCookie(`${Date.now()}`);
760
760
  });
761
761
  }
762
762
 
763
763
  doLogin(options) {
764
764
  console.log('触发松果小程序 doLogin() new new');
765
765
  return new Promise((resolve, reject) => {
766
766
  jd.login({
767
767
  success: (res) => {
768
768
  if (res.code) {
769
769
  console.log('[common]松果小程序登录成功', res.code);
770
770
  jd.redirectTo({
771
771
  url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
772
772
  ...this.info.originQueryInfo,
773
773
  })}`,
774
774
  });
775
775
  resolve(res);
776
776
  } else {
777
777
  console.error('[common]松果小程序登录失败', res.errMsg);
778
778
  reject();
779
779
  }
780
780
  },
781
781
  fail: (res) => {
782
782
  console.error('[common]松果小程序登录失败', res.errMsg);
783
783
  reject();
784
784
  },
785
785
  });
786
786
  });
787
787
  }
788
788
 
789
789
  getLoginCookie(updateKey = 'wxapp') {
790
790
  return new Promise((resolve) => {
791
791
  console.log('开始获取更新wxapp中的cookie信息', updateKey);
792
792
  if (
793
793
  this.config.wqCookie &&
794
794
  this.config.wqCookieStr &&
795
795
  this.config.getWqCookieKey === updateKey
796
796
  ) {
797
797
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
798
798
  resolve({
799
799
  wqCookie: this.config.wqCookie,
800
800
  wqCookieStr: this.config.wqCookieStr,
801
801
  });
802
802
  } else {
803
803
  if (isPublishToWxapp) {
804
804
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
805
805
  if (getWxappCookieObj) {
806
806
  const getCookieObj = getWxappCookieObj['_data'];
807
807
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
808
808
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
809
809
  this.info.loginState = true;
810
810
  this.info.userInfo.wqCookie = wqCookieStr;
811
811
  this.info.userInfo.wqVisitkey = visitkey;
812
812
  console.log('获取用户完整cookie信息', getCookieObj);
813
813
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
814
814
  console.log('获取微信用户地址信息', getUserAddress);
815
815
  if (getUserAddress) {
816
816
  this.info.pageInfo.address = getUserAddress?.areaId;
817
817
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
818
818
  ? this.info.pageInfo.address.replace(/_/g, ',')
819
819
  : '';
820
820
  this.info.pageInfo.un_area = this.info.pageInfo.address;
821
821
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
822
822
  area: this.info.pageInfo.address,
823
823
  });
824
824
  }
825
825
  if (this.miniAppLogInstance) {
826
826
  this.miniAppLogInstance.set({
827
827
  account: pin,
828
828
  unionid: wq_unionid,
829
829
  openid: wxapp_openid,
830
830
  });
831
831
  }
832
832
  this.config.wqCookie = wqCookie;
833
833
  this.config.wqCookieStr = wqCookieStr;
834
834
  this.config.getWqCookieKey = updateKey;
835
835
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
836
836
  resolve({
837
837
  wqCookie,
838
838
  wqCookieStr,
839
839
  });
840
840
  } else {
841
841
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
842
842
  resolve({
843
843
  wqCookie: false,
844
844
  wqCookieStr: false,
845
845
  });
846
846
  }
847
847
  } else {
848
848
  resolve({
849
849
  wqCookie: false,
850
850
  wqCookieStr: false,
851
851
  });
852
852
  }
853
853
  }
854
854
  });
855
855
  }
856
856
 
857
857
 
858
858
  checkLoginStatus() {
859
859
  return this.getLoginCookie();
860
860
  }
861
861
 
862
862
  getAddressCachePromise() {
863
863
  return Promise.reject('该方法只在APP内适用');
864
864
  }
865
865
 
866
866
  getLbsAddressCachePromise() {
867
867
  return Promise.resolve({
868
868
  status: '-1005',
869
869
  msg: '暂未实现,获取失败',
870
870
  });
871
871
  }
872
872
 
873
873
  getDynamicConfig(key: string) {
874
874
  console.warn('调用松果小程序的 getDynamicConfig(),注意,此方法还未实现!');
875
875
  return null;
876
876
  }
877
877
 
878
878
  updatePageAndLogInfo(updateQuery = {}) {
879
879
  const createUpdateQueryInfo: {
880
880
  query: {
881
881
  shopId?: string | number;
882
882
  venderId?: string | number;
883
883
  };
884
884
  updateShopInfoState: boolean;
885
885
  } = Object.assign(
886
886
  {},
887
887
  {
888
888
  query: {},
889
889
  updateShopInfoState: false,
890
890
  },
891
891
  updateQuery,
892
892
  );
893
893
  console.log(
894
894
  '获取当前下发的店铺查询参数',
895
895
  updateQuery,
896
896
  '获取之前保存的shopInfo店铺查询参数',
897
897
  this.info?.shopInfo,
898
898
  );
899
899
  const { query, updateShopInfoState } = createUpdateQueryInfo;
900
900
  const { shopId, venderId } = query;
901
901
  if (updateShopInfoState) {
902
902
  this.info.queryInfo = {
903
903
  ...this.info.queryInfo,
904
904
  ...query,
905
905
  };
906
906
  if (shopId && venderId) {
907
907
  this.info.shopInfo = {
908
908
  shopId: `${shopId}`,
909
909
  venderId: `${venderId}`,
910
910
  };
911
911
  }
912
912
  } else {
913
913
  this.info.queryInfo = {
914
914
  ...query,
915
915
  };
916
916
  this.info.originQueryInfo = {
917
917
  ...query,
918
918
  };
919
919
  if (
920
920
  this.info.shopInfo?.shopId &&
921
921
  this.info.shopInfo?.venderId &&
922
922
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
923
923
  ) {
924
924
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
925
925
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
926
926
  console.log(
927
927
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
928
928
  this.info.queryInfo,
929
929
  );
930
930
  }
931
931
  }
932
932
  this.info.queryInfo['shopId'] &&
933
933
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
934
934
  this.info.queryInfo['venderId'] &&
935
935
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
936
936
  console.log(
937
937
  'weapp===获取店铺下发查询参数\n',
938
938
  query,
939
939
  '\n获取店铺最后查询参数\n',
940
940
  this.info.queryInfo,
941
941
  '\n是否为更新店铺状态\n',
942
942
  updateShopInfoState,
943
943
  );
944
944
  }
945
945
  renderNextTickLoadSdk() {
946
946
  console.warn('暂未实现 index.jd.ts');
947
947
  }
948
948
  loadOtherSdk() {
949
949
  console.warn('暂未实现 index.jd.ts');
950
950
  }
951
951
  loadItemSdkPromise(jsInfo = {}) {
952
952
  console.warn('暂未实现 index.jd.ts');
953
953
  }
954
954
  createLanguageProimse() {
955
955
  return Promise.reject({
956
956
  msg: '暂未实现',
957
957
  });
958
958
  }