@conecli/cone-render 0.9.1-shop2.3 → 0.9.1-shop2.31

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 (114) 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 -0
  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/jdplayerSdk.ts +1 -0
  10. package/dist/common/jssdk.ts +1 -0
  11. package/dist/common/pageType.ts +1 -0
  12. package/dist/common/sgmCustomCode.ts +1 -0
  13. package/dist/common/token/index.h5.ts +1 -1
  14. package/dist/common/token/token.jd.ts +1 -1
  15. package/dist/common/token/token.ts +1 -1
  16. package/dist/common/wxappApi.jd.ts +1 -0
  17. package/dist/components/ErrorBoundary.tsx +1 -1
  18. package/dist/components/base/CountDown/index.tsx +1 -1
  19. package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
  20. package/dist/components/base/CustomScrollView/index.module.scss +7 -0
  21. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  22. package/dist/components/base/CustomVideo/common.ts +1 -0
  23. package/dist/components/base/CustomVideo/index.tsx +1 -1
  24. package/dist/components/base/Dialog/index.module.scss +5 -0
  25. package/dist/components/base/Dialog/index.tsx +1 -1
  26. package/dist/components/base/Exposure/index.h5.tsx +1 -1
  27. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  28. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  29. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  30. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  31. package/dist/components/base/InViewRender/index.tsx +1 -1
  32. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  33. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  34. package/dist/components/base/LazyLoadImage/const.ts +1 -1
  35. package/dist/components/base/LazyLoadImage/index.h5.module.scss +23 -20
  36. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  37. package/dist/components/base/MobileCommonHeader/index.module.scss +17 -0
  38. package/dist/components/base/MobileCommonHeader/index.tsx +1 -0
  39. package/dist/components/base/NetworkDataError/const.ts +1 -1
  40. package/dist/components/base/NetworkDataError/index.module.scss +7 -0
  41. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  42. package/dist/components/base/Price/Base/index.tsx +1 -1
  43. package/dist/components/base/Price/Double/index.tsx +1 -1
  44. package/dist/components/base/Price/index.tsx +1 -1
  45. package/dist/components/debug/DebugLayout/index.module.scss +67 -0
  46. package/dist/components/debug/DebugLayout/index.tsx +1 -0
  47. package/dist/components/debug/DebugLayout/utils.ts +1 -0
  48. package/dist/components/decorate/DecorateFloorModule/index.module.scss +32 -2
  49. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  50. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  51. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  52. package/dist/components/floorItem.jd.tsx +1 -1
  53. package/dist/components/floorItem.tsx +1 -1
  54. package/dist/components/floorItem.weapp.tsx +1 -1
  55. package/dist/components/isv/Floor/index.tsx +1 -1
  56. package/dist/components/remoteFloorItem.tsx +1 -1
  57. package/dist/interface/common.ts +1 -1
  58. package/dist/interface/component.ts +1 -1
  59. package/dist/interface/jumpEventReport.ts +1 -1
  60. package/dist/interface/service.ts +1 -1
  61. package/dist/interface/utils.ts +1 -1
  62. package/dist/jumpEventReport/base.ts +1 -1
  63. package/dist/jumpEventReport/const.ts +1 -1
  64. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  65. package/dist/jumpEventReport/index.h5.ts +1 -1
  66. package/dist/jumpEventReport/index.jd.ts +1 -1
  67. package/dist/jumpEventReport/index.weapp.ts +1 -1
  68. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  69. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  70. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  71. package/dist/jumpEventReport/web/report.ts +1 -1
  72. package/dist/jumpEventReport/web.base.ts +1 -1
  73. package/dist/jumpEventReport/web.jd.ts +1 -1
  74. package/dist/jumpEventReport/web.jdb.ts +1 -1
  75. package/dist/jumpEventReport/web.jdjch.ts +1 -1
  76. package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
  77. package/dist/jumpEventReport/web.tjapp.ts +1 -0
  78. package/dist/jumpEventReport/web.tjm.ts +1 -0
  79. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  80. package/dist/modules/ContainerFloorList/index.h5.module.scss +18 -1
  81. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  82. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  83. package/dist/open/api/device.ts +1 -1
  84. package/dist/open/api/environment.ts +1 -1
  85. package/dist/open/api/index.ts +1 -1
  86. package/dist/open/api/jump copy.ts +1 -1
  87. package/dist/open/api/request.ts +1 -1
  88. package/dist/open/api/shopMember.ts +1 -1
  89. package/dist/open/api/track.ts +1 -1
  90. package/dist/open/api/util.ts +1 -1
  91. package/dist/open/components/index.ts +1 -1
  92. package/dist/sass/app.h5.scss +49 -3
  93. package/dist/sass/base.scss +57 -0
  94. package/dist/service/fetchGateway.ts +1 -1
  95. package/dist/service/http/colorSign.ts +1 -1
  96. package/dist/service/http/const.ts +1 -1
  97. package/dist/service/http/h5Http.ts +1 -0
  98. package/dist/service/http/index.h5.ts +1 -0
  99. package/dist/service/requestServer.h5.ts +1 -0
  100. package/dist/service/requestServer.ts +1 -1
  101. package/dist/utils/connectNativeJsBridge.ts +1 -1
  102. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  103. package/dist/utils/draExceptionAndProfile.ts +1 -1
  104. package/dist/utils/h5Utils.ts +1 -1
  105. package/dist/utils/index.h5.ts +1 -1
  106. package/dist/utils/index.ts +1 -1
  107. package/dist/utils/index.weapp.ts +1 -1
  108. package/dist/utils/jm-common.js +1 -1
  109. package/dist/utils/sgmCodeUtils.ts +1 -0
  110. package/dist/utils/taroRenderUtil.ts +1 -1
  111. package/dist/utils/utils.ts +1 -1
  112. package/package.json +26 -3
  113. package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
  114. package/dist/utils/memberFormatUtils.js +0 -1
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  WXAPP_SUBS_GUIDER
3
2
  floorVideInfo: {},
4
3
  public config: {
5
4
  [key: string]: any
6
5
  }
7
6
  this.config = {}
8
7
  this.wxAppSubsGuider = WXAPP_SUBS_GUIDER
9
8
  console.log('=================>', 'updateBusinessDomainAndApi')
10
9
 
11
10
  setTimeout(() => {
12
11
  console.log("微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie")
13
12
  this.getLoginCookie(`${Date.now()}`)
14
13
  },500)
15
14
  this.getLoginCookie(`${Date.now()}`)
16
15
  setTimeout(() => {
17
16
  console.log("微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie")
18
17
  this.getLoginCookie(`${Date.now()}`)
19
18
  },500)
20
19
  return new Promise((resolve) => {
21
20
  console.log("开始获取更新wxapp中的cookie信息", updateKey)
22
21
  if(this.config.wqCookie && this.config.wqCookieStr && this.config.getWqCookieKey === updateKey){
23
22
  console.log("已有存储wxapp中的cookie信息,直接返回",this.config)
24
23
  resolve({
25
24
  wqCookie: this.config.wqCookie,
26
25
  wqCookieStr: this.config.wqCookieStr,
27
26
  })
28
27
  }else {
29
28
  if (isPublishToWxapp) {
30
29
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
31
30
  if (getWxappCookieObj) {
32
31
  const getCookieObj = getWxappCookieObj['_data']
33
32
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
34
33
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie
35
34
  this.info.loginState = true
36
35
  this.info.userInfo.wqCookie = wqCookieStr
37
36
  this.info.userInfo.wqVisitkey = visitkey
38
37
  console.log('获取用户完整cookie信息', getCookieObj)
39
38
  const getUserAddress = this.wxAppUserInfoInstance.getAddress()
40
39
  console.log('获取微信用户地址信息', getUserAddress)
41
40
  if (getUserAddress) {
42
41
  this.info.pageInfo.address = getUserAddress?.areaId
43
42
  this.info.pageInfo.addressCommaStr = this.info.pageInfo
44
43
  .address
45
44
  ? this.info.pageInfo.address.replace(/_/g, ',')
46
45
  : ''
47
46
  this.info.pageInfo.un_area = this.info.pageInfo.address
48
47
  Taro.eventCenter.trigger(
49
48
  TaroEventType.USER_AREA_UPDATE,
50
49
  this.info.pageInfo.address,
51
50
  )
52
51
  }
53
52
  if(this.miniAppLogInstance){
54
53
  this.miniAppLogInstance.set({
55
54
  account: pin,
56
55
  unionid: wq_unionid,
57
56
  openid: wxapp_openid,
58
57
  })
59
58
  }
60
59
  this.config.wqCookie = wqCookie
61
60
  this.config.wqCookieStr = wqCookieStr
62
61
  this.config.getWqCookieKey = updateKey
63
62
  console.log("解析wxapp中的cookie信息成功,返回后存储",this.config)
64
63
  resolve({
65
64
  wqCookie,
66
65
  wqCookieStr,
67
66
  })
68
67
  }else {
69
68
  console.log("解析wxapp中的cookie信息异常,返回异常结果",this.config)
70
69
  resolve({
71
70
  wqCookie: false,
72
71
  wqCookieStr: false,
73
72
  })
74
73
  }
75
74
  }else {
76
75
  resolve({
77
76
  wqCookie: false,
78
77
  wqCookieStr: false,
79
78
  })
80
79
  }
81
80
  }
82
81
  })
82
+ import Taro from "@tarojs/taro";
83
83
  WXAPP_LOGIN,
84
84
  WXAPP_BIZ,
85
85
  WXAPP_USER_INFO,
86
86
  WXAPP_NAVIGATOR,
87
87
  WXAPP_REPORT_GDT,
88
88
  WXAPP_PARAMS_SIGN,
89
89
  WXAPP_FINGER_REPORT,
90
90
  WXAPP_REPORT_MANAGE,
91
91
  WXAPP_SUBS_GUIDER,
92
92
  BUSINESS_TYPE,
93
93
  SHOP_MENU_ID_TYPE,
94
94
  SHOP_MENU_ID_NAME,
95
95
  SECTION_HOME_TAB_NAME_TYPE,
96
96
  SECTION_HOME_TAB_TYPE,
97
97
  TaroEventType,
98
98
  WX_BUSINESS_TYPE,
99
99
  WXAPP_BIZ_KEY,
100
100
  WXAPP_BIZ_SHOP_LIGHT_KEY,
101
101
  getSystemInfos,
102
102
  getTaroStorageKeyValue,
103
103
  getWxAppCookieStr,
104
104
  objectToUrlEncode,
105
105
  loginState: jdUserLoginState,
106
106
  cookiesStr: "",
107
107
  userInfo: userPinKey,
108
108
  pageInfo: {
109
109
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
110
110
  address: "",
111
111
  addressCommaStr: "",
112
112
  un_area: "",
113
113
  vapptype: "1",
114
114
  pageType: "home",
115
115
  dataType: BUSINESS_TYPE.ONLINE,
116
116
  floorExposureInfo: {},
117
117
  floorVideInfo: {},
118
118
  productVideInfo: {},
119
119
  tabsLoadAllDataInfo: {
120
120
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]:
121
121
  false,
122
122
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
123
123
  },
124
124
  updateShopInfosAllState: false,
125
125
  isVipShop: false,
126
126
  isJdShowNativeImmersivePlayer: false,
127
127
  ...shopConfig,
128
128
  pageScrollTop: 0,
129
129
  pageIdxHeightInfo: {
130
130
  list: [],
131
131
  },
132
132
  shopNavBarHeight: 0,
133
133
  },
134
134
  defaultQueryLogInfo: {
135
135
  sourceType: "JDshop",
136
136
  sourceValue: "",
137
137
  moduleId: "none",
138
138
  entrance: "none",
139
139
  },
140
140
  originQueryInfo: {},
141
141
  sysInfo: {
142
142
  windowWidth: 0,
143
143
  windowHeight: 0,
144
144
  netWorkType: "4g",
145
145
  jdBottomBarHeight: 0,
146
146
  jdNativeHeaderHeight: 0,
147
147
  },
148
148
  queryInfo: {},
149
149
  shopInfo: {},
150
150
  openAppData: {},
151
151
  public info: CommonInterFace.BaseConfigInfo;
152
152
  public config: {
153
153
  [key: string]: any;
154
154
  };
155
155
  public lazyContainer: CommonInterFace.lazyContainer;
156
156
  public rootEleNode: HTMLElement | null;
157
157
  public miniApplogUtil: CommonInterFace.MiniApplogUtil;
158
158
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
159
159
  public checkStatusAndLoginPromise: object | null;
160
160
  public wxAppLoginInstance: CommonInterFace.WxAppLogin;
161
161
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
162
162
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
163
163
  public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
164
164
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
165
165
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
166
166
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
167
167
  public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
168
168
  public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
169
169
  public loadJsSdkList: Array<any>
170
170
  public loadJsSdkListCachePromise: any
171
171
  constructor(opt) {
172
172
  this.info = this._getConfig(opt);
173
173
  this.config = {};
174
174
  this.lazyContainer = {
175
175
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
176
176
  appLazyContainerList: [],
177
177
  appLazyFinishContainerList: [],
178
178
  },
179
179
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
180
180
  appLazyContainerList: [],
181
181
  appLazyFinishContainerList: [],
182
182
  },
183
183
  };
184
184
  this.loadJsSdkList = []
185
185
  this.loadJsSdkListCachePromise = {}
186
186
  this.rootEleNode = null;
187
187
  this.miniApplogUtil = MiniAppLogUtil;
188
188
  this.miniAppLogInstance = null;
189
189
  this.checkStatusAndLoginPromise = null;
190
190
  this.wxAppLoginInstance = WXAPP_LOGIN;
191
191
  this.wxAppBizInstance = WXAPP_BIZ;
192
192
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
193
193
  this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
194
194
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
195
195
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
196
196
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
197
197
  this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT
198
198
  ? new WXAPP_FINGER_REPORT()
199
199
  : {};
200
200
  this.wxAppSubsGuider = WXAPP_SUBS_GUIDER;
201
201
  }
202
202
  _getConfig(opt) {
203
203
  return Object.assign({}, DefaultConfig, opt);
204
204
  }
205
205
 
206
206
  taskTimeoutPromise(callBack, timeout = 2000) {
207
207
  return new Promise((resolve) => {
208
208
  setTimeout(() => {
209
209
  const getCallBackRes = typeof callBack === "function" && callBack();
210
210
  return resolve(getCallBackRes || false);
211
211
  }, timeout);
212
212
  });
213
213
  }
214
214
 
215
215
  updateBusinessDomainAndApi(domain, api) {
216
216
  console.log("=================>", "updateBusinessDomainAndApi");
217
217
  }
218
218
 
219
219
  getFullScreenHeight(systemInfo) {
220
220
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
221
221
  let result = screenHeight;
222
222
  if (statusBarHeight > 20 && isAndroid) {
223
223
  result = screenHeight + statusBarHeight;
224
224
  }
225
225
  return result;
226
226
  }
227
227
 
228
228
  getTabBarHeight(systemInfo) {
229
229
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
230
230
  let result = 50;
231
231
  if (statusBarHeight > 20) {
232
232
  if (isIOS) {
233
233
  result = 84;
234
234
  } else if (isAndroid) {
235
235
  result = 53;
236
236
  }
237
237
  }
238
238
  return result;
239
239
  }
240
240
 
241
241
  getSystemInfo() {
242
242
  const info: UtilsInterFace.taroGetSystemInfoSyncRes =
243
243
  getSystemInfos() || {};
244
244
  const actualNavBarHeight =
245
245
  (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
246
246
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
247
247
  const fullScreenHeight = this.getFullScreenHeight(info);
248
248
  const tabBarHeight = this.getTabBarHeight(info);
249
249
  const safeContentHeight = fullScreenHeight - headerHeight;
250
250
  this.info.sysInfo = {
251
251
  ...this.info.sysInfo,
252
252
  ...info,
253
253
  actualNavBarHeight,
254
254
  headerHeight,
255
255
  fullScreenHeight,
256
256
  tabBarHeight,
257
257
  safeContentHeight,
258
258
  };
259
259
  if (this.info.sysInfo["hostVersionName"]) {
260
260
  this.info.sysInfo["hostAppVersion"] = Number(
261
261
  this.info.sysInfo["hostVersionName"].replace(/\./g, "")
262
262
  );
263
263
  }
264
264
  this.info.sysInfo["wifiVideoAutoPlay"] = false;
265
265
  this.getNetWorkType();
266
266
  console.log("获取系统信息", this.info.sysInfo);
267
267
  }
268
268
  async updateMPaasConfig() {}
269
269
 
270
270
  getNetWorkType() {
271
271
  Taro.getNetworkType().then((getRes) => {
272
272
  getRes &&
273
273
  getRes.networkType &&
274
274
  (this.info.sysInfo["netWorkType"] = getRes.networkType);
275
275
  });
276
276
  }
277
277
  getAPPUseStraightCorner () {
278
278
  return Promise.resolve(false)
279
279
  }
280
280
 
281
281
  checkStatusAndLogin(options = {}) {
282
282
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
283
283
  console.log(
284
284
  "微信小程序登录状态及获取cookie状态的promise,之前登录状态",
285
285
  this.info.loginState
286
286
  );
287
287
  this.toLogin(options)
288
288
  .then((res) => {
289
289
  console.log("微信小程序登录状态结果,成功", res);
290
290
  this.info.loginState = true;
291
291
  resolve(res);
292
292
  })
293
293
  .catch((err) => {
294
294
  console.log("微信小程序登录异常状态结果", err);
295
295
  this.doLogin(options)
296
296
  .then((res2) => {
297
297
  console.log("微信小程序wxDoLogin强制登陆成功:", res2);
298
298
  this.info.loginState = true;
299
299
  resolve(res2);
300
300
  })
301
301
  .catch((err2) => {
302
302
  console.log("微信小程序wxDoLogin强制登陆失败:", err2);
303
303
  this.checkStatusAndLoginPromise = null;
304
304
  reject(err2);
305
305
  });
306
306
  });
307
307
  });
308
308
  return this.checkStatusAndLoginPromise;
309
309
  }
310
310
 
311
311
  checkJdStatusAndLogin(
312
312
  options = {
313
313
  loginColor: {
314
314
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
315
315
  dpin: 0,
316
316
  },
317
317
  }
318
318
  ) {
319
319
  return this.checkStatusAndLogin(options);
320
320
  }
321
321
 
322
322
  toLogin(options = {}): Promise<any> {
323
323
  return this.wxAppLoginInstance
324
324
  .getLoginPromise({
325
325
  mode: "common",
326
326
  loginColor: {
327
327
  biz: WXAPP_BIZ_KEY,
328
328
  dpin: 1,
329
329
  },
330
330
  ...options,
331
331
  })
332
332
  .then((res) => {
333
333
  console.log("微信app登录返回信息,微信侧返回code为0表示成功", res);
334
334
  setTimeout(() => {
335
335
  console.log(
336
336
  "微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie"
337
337
  );
338
338
  this.getLoginCookie(`${Date.now()}`);
339
339
  }, 500);
340
340
  })
341
341
  .catch((err) => {
342
342
  console.log("微信app登录异常返回信息,也获取cookie", err);
343
343
  this.getLoginCookie(`${Date.now()}`);
344
344
  });
345
345
  }
346
346
 
347
347
  doLogin(options = {}) {
348
348
  const getParams = {
349
349
  loginColor: {
350
350
  biz: WXAPP_BIZ_KEY,
351
351
  dpin: 1,
352
352
  },
353
353
  ...options,
354
354
  };
355
355
  if (isPublishToWxapp) {
356
356
  getParams[
357
357
  "returnUrl"
358
358
  ] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
359
359
  ...this.info.originQueryInfo,
360
360
  loadShopxType: "redirect",
361
361
  })}`;
362
362
  }
363
363
  return this.wxAppLoginInstance.doLogin(getParams).then((res) => {
364
364
  console.log("微信小程序强制登录返回信息,微信侧返回code为0表示成功", res);
365
365
  setTimeout(() => {
366
366
  console.log(
367
367
  "微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie"
368
368
  );
369
369
  this.getLoginCookie(`${Date.now()}`);
370
370
  }, 500);
371
371
  return res;
372
372
  });
373
373
  }
374
374
 
375
375
  doLoginForJdPin(options = {}) {
376
376
  return this.doLogin({
377
377
  loginColor: {
378
378
  biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
379
379
  dpin: 0,
380
380
  },
381
381
  ...options,
382
382
  });
383
383
  }
384
384
 
385
385
  getLoginCookie(updateKey = "wxapp") {
386
386
  return new Promise((resolve) => {
387
387
  console.log("开始获取更新wxapp中的cookie信息", updateKey);
388
388
  if (
389
389
  this.config.wqCookie &&
390
390
  this.config.wqCookieStr &&
391
391
  this.config.getWqCookieKey === updateKey
392
392
  ) {
393
393
  console.log("已有存储wxapp中的cookie信息,直接返回", this.config);
394
394
  resolve({
395
395
  wqCookie: this.config.wqCookie,
396
396
  wqCookieStr: this.config.wqCookieStr,
397
397
  });
398
398
  } else {
399
399
  if (isPublishToWxapp) {
400
400
  const getWxappCookieObj = getTaroStorageKeyValue("cookies") || null;
401
401
  if (getWxappCookieObj) {
402
402
  const getCookieObj = getWxappCookieObj["_data"];
403
403
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
404
404
  const {
405
405
  pin = "",
406
406
  visitkey = "-1",
407
407
  wq_unionid = "",
408
408
  wxapp_openid = "",
409
409
  } = wqCookie;
410
410
  this.info.loginState = true;
411
411
  this.info.userInfo.wqCookie = wqCookieStr;
412
412
  this.info.userInfo.wqVisitkey = visitkey;
413
413
  console.log("获取用户完整cookie信息", getCookieObj);
414
414
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
415
415
  console.log("获取微信用户地址信息", getUserAddress);
416
416
  if (getUserAddress) {
417
417
  this.info.pageInfo.address = getUserAddress?.areaId;
418
418
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
419
419
  ? this.info.pageInfo.address.replace(/_/g, ",")
420
420
  : "";
421
421
  this.info.pageInfo.un_area = this.info.pageInfo.address;
422
422
  Taro.eventCenter.trigger(
423
423
  TaroEventType.USER_AREA_UPDATE,
424
424
  this.info.pageInfo.address
425
425
  );
426
426
  }
427
427
  if (this.miniAppLogInstance) {
428
428
  this.miniAppLogInstance.set({
429
429
  account: pin,
430
430
  unionid: wq_unionid,
431
431
  openid: wxapp_openid,
432
432
  });
433
433
  }
434
434
  this.config.wqCookie = wqCookie;
435
435
  this.config.wqCookieStr = wqCookieStr;
436
436
  this.config.getWqCookieKey = updateKey;
437
437
  console.log("解析wxapp中的cookie信息成功,返回后存储", this.config);
438
438
  resolve({
439
439
  wqCookie,
440
440
  wqCookieStr,
441
441
  });
442
442
  } else {
443
443
  console.log(
444
444
  "解析wxapp中的cookie信息异常,返回异常结果",
445
445
  this.config
446
446
  );
447
447
  resolve({
448
448
  wqCookie: false,
449
449
  wqCookieStr: false,
450
450
  });
451
451
  }
452
452
  } else {
453
453
  resolve({
454
454
  wqCookie: false,
455
455
  wqCookieStr: false,
456
456
  });
457
457
  }
458
458
  }
459
459
  });
460
460
  }
461
461
 
462
462
 
463
463
  checkLoginStatus() {
464
464
  return this.getLoginCookie();
465
465
  }
466
466
 
467
467
  getAddressCachePromise = () => {
468
468
  return Promise.reject("该方法只在APP内适用");
469
469
  };
470
470
 
471
471
  updatePageAndLogInfo(updateQuery = {}) {
472
472
  const createUpdateQueryInfo: {
473
473
  query: {
474
474
  shopId?: string | number;
475
475
  venderId?: string | number;
476
476
  };
477
477
  updateShopInfoState: boolean;
478
478
  } = Object.assign(
479
479
  {},
480
480
  {
481
481
  query: {},
482
482
  updateShopInfoState: false,
483
483
  },
484
484
  updateQuery
485
485
  );
486
486
  console.log(
487
487
  "获取当前下发的店铺查询参数",
488
488
  updateQuery,
489
489
  "获取之前保存的shopInfo店铺查询参数",
490
490
  this.info?.shopInfo
491
491
  );
492
492
  const { query, updateShopInfoState } = createUpdateQueryInfo;
493
493
  const { shopId, venderId } = query;
494
494
  if (updateShopInfoState) {
495
495
  this.info.queryInfo = {
496
496
  ...this.info.queryInfo,
497
497
  ...query,
498
498
  };
499
499
  if (shopId && venderId) {
500
500
  this.info.shopInfo = {
501
501
  shopId: `${shopId}`,
502
502
  venderId: `${venderId}`,
503
503
  };
504
504
  }
505
505
  } else {
506
506
  this.info.queryInfo = {
507
507
  ...query,
508
508
  };
509
509
  this.info.originQueryInfo = {
510
510
  ...query,
511
511
  };
512
512
  if (
513
513
  this.info.shopInfo?.shopId &&
514
514
  this.info.shopInfo?.venderId &&
515
515
  (this.info.shopInfo.shopId == shopId ||
516
516
  this.info.shopInfo.venderId == venderId)
517
517
  ) {
518
518
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
519
519
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
520
520
  console.log(
521
521
  "当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数",
522
522
  this.info.queryInfo
523
523
  );
524
524
  }
525
525
  }
526
526
  this.info.queryInfo["shopId"] &&
527
527
  (this.info.queryInfo["shopId"] = `${this.info.queryInfo["shopId"]}`);
528
528
  this.info.queryInfo["venderId"] &&
529
529
  (this.info.queryInfo["venderId"] = `${this.info.queryInfo["venderId"]}`);
530
530
  console.log(
531
531
  "weapp===获取店铺下发查询参数\n",
532
532
  query,
533
533
  "\n获取店铺最后查询参数\n",
534
534
  this.info.queryInfo,
535
535
  "\n是否为更新店铺状态\n",
536
536
  updateShopInfoState
537
537
  );
538
538
  }
539
539
 
540
540
  getDynamicConfig(key: string){
541
541
  console.warn('调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!')
542
542
  return null
543
543
  }
544
544
  renderNextTickLoadSdk(){
545
545
  console.warn("暂未实现 index.weapp.ts")
546
546
  }
547
547
  loadOtherSdk(){
548
548
  console.warn('暂未实现 index.weapp.ts')
549
549
  }
550
550
  loadItemSdkPromise() {
551
551
  console.warn('暂未实现 index.weapp.ts')
552
552
  }
@@ -0,0 +1 @@
1
+ import { dateFormat, getRandom, JSONParse } from '../utils/utils'
2
  const dateStr = dateFormat(new Date(), 'yyyyMMddHHmmss')
1
3
  const randomStr = getRandom(100000, 999999)
2
4
  const callbackName = `${prefix}_CallBack_${dateStr}_${randomStr}`
3
5
  return callbackName
4
6
  return new Promise((resolve, reject) => {
5
7
  if (window.XWebView && window.XWebView.callNative) {
6
8
  const callbackName = getCallBackName('hasBgAudio')
7
9
  window[callbackName] = function(result: any) {
8
10
  const parsedData = JSONParse(result)
9
11
  if (parsedData && parsedData.hasOwnProperty('data')) {
10
12
  resolve(parsedData.data)
11
13
  } else {
12
14
  console.log('hasBgAudio error result:', result)
13
15
  reject({
14
16
  code: -2,
15
17
  message: 'hasBgAudio error: result is not available',
16
18
  })
17
19
  }
18
20
  window[callbackName] = null
19
21
  delete window[callbackName]
20
22
  }
21
23
  let jsonStr = {}
22
24
  window.XWebView.callNative(
23
25
  'JDPlayerJSPlugin',
24
26
  'hasBgAudio',
25
27
  JSON.stringify(jsonStr),
26
28
  callbackName,
27
29
  '',
28
30
  )
29
31
  } else {
30
32
  reject({
31
33
  code: -1,
32
34
  message: 'hasBgAudio error: XWebView.callNative is not defined',
33
35
  })
34
36
  }
35
37
  })
36
38
  return new Promise((resolve, reject) => {
37
39
  if (window.XWebView && window.XWebView.callNative) {
38
40
  const callbackName = getCallBackName('pauseBgAudio')
39
41
  window[callbackName] = function(result: any) {
40
42
  const parsedData = JSONParse(result)
41
43
  if (parsedData && parsedData.hasOwnProperty('data')) {
42
44
  resolve(parsedData.data)
43
45
  } else {
44
46
  console.log('pauseBgAudio error result:', result)
45
47
  reject({
46
48
  code: -2,
47
49
  message: 'pauseBgAudio error: result is not available',
48
50
  })
49
51
  }
50
52
  window[callbackName] = null
51
53
  delete window[callbackName]
52
54
  }
53
55
  let jsonStr = {}
54
56
  window.XWebView.callNative(
55
57
  'JDPlayerJSPlugin',
56
58
  'pauseBgAudio',
57
59
  JSON.stringify(jsonStr),
58
60
  callbackName,
59
61
  '',
60
62
  )
61
63
  } else {
62
64
  reject({
63
65
  code: -1,
64
66
  message: 'pauseBgAudio error: XWebView.callNative is not defined',
65
67
  })
66
68
  }
67
69
  })
68
70
  return new Promise((resolve, reject) => {
69
71
  if (window.XWebView && window.XWebView.callNative) {
70
72
  const callbackName = getCallBackName('resumeBgAudio')
71
73
  window[callbackName] = function(result: any) {
72
74
  const parsedData = JSONParse(result)
73
75
  if (parsedData && parsedData.hasOwnProperty('data')) {
74
76
  resolve(parsedData.data)
75
77
  } else {
76
78
  console.log('resumeBgAudio error result:', result)
77
79
  reject({
78
80
  code: -2,
79
81
  message: 'resumeBgAudio error: result is not available',
80
82
  })
81
83
  }
82
84
  window[callbackName] = null
83
85
  delete window[callbackName]
84
86
  }
85
87
  let jsonStr = {}
86
88
  window.XWebView.callNative(
87
89
  'JDPlayerJSPlugin',
88
90
  'resumeBgAudio',
89
91
  JSON.stringify(jsonStr),
90
92
  callbackName,
91
93
  '',
92
94
  )
93
95
  } else {
94
96
  reject({
95
97
  code: -1,
96
98
  message: 'resumeBgAudio error: XWebView.callNative is not defined',
97
99
  })
98
100
  }
99
101
  })
100
102
  return new Promise((resolve, reject) => {
101
103
  if (window.XWebView && window.XWebView.callNative) {
102
104
  const callbackName = getCallBackName('getWifiVideoAutoPlay')
103
105
  window[callbackName] = function(result: any) {
104
106
  const parsedData = JSONParse(result)
105
107
  if (parsedData && parsedData.hasOwnProperty('data')) {
106
108
  resolve(parsedData.data)
107
109
  } else {
108
110
  console.log('getWifiVideoAutoPlay error result:', result)
109
111
  reject({
110
112
  code: -2,
111
113
  message: 'getWifiVideoAutoPlay error: result is not available',
112
114
  })
113
115
  }
114
116
  window[callbackName] = null
115
117
  delete window[callbackName]
116
118
  }
117
119
  let jsonStr = {}
118
120
  window.XWebView.callNative(
119
121
  'JDPlayerJSPlugin',
120
122
  'actionIsWifiVideoAutoPlay',
121
123
  JSON.stringify(jsonStr),
122
124
  callbackName,
123
125
  '',
124
126
  )
125
127
  } else {
126
128
  reject({
127
129
  code: -1,
128
130
  message:
129
131
  'getWifiVideoAutoPlay error: XWebView.callNative is not defined',
130
132
  })
131
133
  }
132
134
  })