@conecli/cone-render 0.10.1-beta.3 → 0.10.1-beta.5

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 (56) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.h5.ts +1 -1
  4. package/dist/common/index.weapp.ts +1 -1
  5. package/dist/common/sgmCustomCode.ts +1 -1
  6. package/dist/components/ErrorBoundary.tsx +1 -1
  7. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  8. package/dist/components/base/CustomVideo/index.tsx +1 -1
  9. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  10. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  11. package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
  12. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  13. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  14. package/dist/components/base/LazyLoadImage/index.h5.module.scss +3 -0
  15. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  16. package/dist/components/base/MobileCommonHeader/index.module.scss +8 -0
  17. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  18. package/dist/components/base/NetworkDataError/index.module.scss +3 -0
  19. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  20. package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
  21. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  22. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  23. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  24. package/dist/components/floorItem.tsx +1 -1
  25. package/dist/components/remoteFloorItem.tsx +1 -1
  26. package/dist/interface/common.ts +1 -1
  27. package/dist/interface/component.ts +1 -1
  28. package/dist/interface/jumpEventReport.ts +1 -1
  29. package/dist/interface/service.ts +1 -1
  30. package/dist/jumpEventReport/base.ts +1 -1
  31. package/dist/jumpEventReport/const.ts +1 -1
  32. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  33. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  34. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  35. package/dist/jumpEventReport/web.base.ts +1 -1
  36. package/dist/jumpEventReport/web.jd.ts +1 -1
  37. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  38. package/dist/modules/ContainerFloorList/index.h5.module.scss +1 -0
  39. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  40. package/dist/open/api/device.ts +1 -1
  41. package/dist/open/api/request.ts +1 -1
  42. package/dist/open/api/shopMember.ts +1 -1
  43. package/dist/open/api/util.ts +1 -1
  44. package/dist/open/components/index.ts +1 -1
  45. package/dist/sass/app.h5.scss +5 -0
  46. package/dist/sass/base.scss +45 -0
  47. package/dist/service/requestServer.ts +1 -1
  48. package/dist/utils/connectNativeJsBridge.ts +1 -1
  49. package/dist/utils/h5Utils.ts +1 -1
  50. package/dist/utils/index.h5.ts +1 -1
  51. package/dist/utils/index.ts +1 -1
  52. package/dist/utils/index.weapp.ts +1 -1
  53. package/dist/utils/sgmCodeUtils.ts +1 -1
  54. package/dist/utils/taroRenderUtil.ts +1 -1
  55. package/dist/utils/utils.ts +1 -1
  56. package/package.json +24 -23
@@ -1 +1 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react'
2
1
  getQualityImage,
3
2
  isH5AndJdShopView,
4
3
  isJdApp,
5
4
  isChartH5,
6
5
  isH5AndJdShopViewH5Scroll,
7
6
  isAppStowShop,
8
7
  sgmCustomReport,
9
8
  isImageOptimizeEnable,
10
9
  getNativePageScrollRes,
11
10
  latestFromNativeMsgStorage,
12
11
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAAeCAMAAABT0xOcAAAAe1BMVEUAAADx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fELy0NOAAAAKHRSTlMApwmfFtYm9rWveHDm70yJHYJaD2k8IeIr6pY2X0HHfsGRZDHdu1XNmO+CqgAAAu9JREFUSMfNlNmymzAQRAchkCUhdrMZbLze/v8vjIRMKN8kRR7ykFNeVIPV9Ewj039P1TR8+eILjL7RdLFFJUO8QMS7ZmyDJvZ0nDYGY+aKKDSJpY3OwWX6uFUEY/peCNEbY4Rp6AABixFYkLQRAK3VOmAjUrawMt1GrfWtXD7rlFF3uiA6HV/p0TF1tBECEVskYe+7qqW08mqT1jruneu21/72JfHoSZ7faj2bJu6mOlgEa3qjEXKeL/ACV1s5YSbqYP6stXUeX2FZnV3wuBSZqnVWqDNCIvaFRzZIiGAIw+CS/1brQCslgOQdUBoW10C2EFJei7AkygOlAnmGeMprJq/NjhZpAIrepOpOte2Oq9EXjupIMVoiXduQ9rTo7KsODhxJYaAGuJPjgRvdkRD1KP9CawRwettyF5SbVLZ49ZbuMJxGW93XisXPKA/oXNMDEReJT6N0OfZ2V4RqX4tFQPbOQbntwrl8oXCOQmu2hVosSr6j5QcW+uvukZJP37CWzL7tQs2lH8B53Nd6eq192N/72mdfa52XhdXPx6zcXKYgikLXbaNP66M27edoAO2X+RkQ9tVRhoWC6IZkCZAbHHa1SgDHNdHDsbrLr0ojKTkfDWp6+WPh1APakMAXbVrb6B/Mn+311zlETJZOCJYChttWxedUIyvyi9bLt+J4IPcLvVYypBNaDG5TguCzmct3rUkAPSdHJRLyDEjXQ6Un3GZQBamxaU09gJg+/r+4gqV0uzixXjBfLnDzixrjhDJGNoDXXqvK76OEJaO3L1bx/FQOCSxqcfJVUWiXCydEPowHeIqaZnf3wmvNRsBiC28ttEnS+1oy+lNtOMVAzayZCwsQ5ESNREgvKKuNjjI/ewNHr9Y4N5Is98llx2U8iOQXcKczhDwAM6ObayaanfWDDwhJcMvpU8ucr6+cPji5a8+UEVMCMNo97tLm0MU2uoMmi850yrc8s8Khyzuj7+Q6U7GPMCt8mOtGljP6l/wAUcBZ6lceL/8AAAAASUVORK5CYII='
13
12
  'https://img14.360buyimg.com/imagetools/jfs/t1/222907/25/7012/5824/61c4797cEbcd17c7f/6c76fc71e4fdb5a5.png'
14
13
  const {
15
14
  src = null,
16
15
  lazyLoad = true,
17
16
  imagRenderingSet = true,
18
17
  width = null,
19
18
  height = null,
20
19
  className = null,
21
20
  isSkuImage = false,
22
21
  hideErrorImage = false,
23
22
  style = null,
24
23
  backgroundColor = null,
25
24
  errorSrc = null,
26
25
  onLoad = null,
27
26
  onError = null,
28
27
  ...otherOption
29
28
  } = props
30
29
  getNetWorkType === NetWorkTypeQuality.default &&
31
30
  (getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
32
31
  const [loadSuccess, setLoadSuccess] = useState(false)
33
32
  const [imageErrState, setImageErrState] = useState(false)
34
33
  const [componentShowState, setComponentShowState] = useState(false)
35
34
  const measureRef = useRef<HTMLElement | null>(null)
36
35
  const [measureComplete, setMeasureComplete] = useState(false)
37
36
  const [imgSrc, setImgSrc] = useState(src)
38
37
  const componentLazyRef = useRef<HTMLElement | null>(null)
39
38
  const componentShowStateRef = useRef(false)
40
39
  const requestSrcRef = useRef(src)
41
40
  const needShowHighVersion =
42
41
  isH5AndJdShopViewH5Scroll &&
43
42
  !(
44
43
  global.info.queryInfo?.downgraded &&
45
44
  global.info.queryInfo.downgraded === 'true'
46
45
  )
47
46
  const enableAvifOptimize = isImageOptimizeEnable()
48
47
 
49
48
  const getRequestSrc = useCallback(
50
49
  (src) => {
51
50
  const requestSrc = getQualityImage(imgSrc, {
52
51
  isSkuImage,
53
52
  size: measureRef?.current?.offsetWidth,
54
53
  })
55
54
  requestSrcRef.current = requestSrc
56
55
  return requestSrc
57
56
  },
58
57
  [src],
59
58
  )
60
59
  const imageError = useCallback(
61
60
  (e) => {
62
61
  console.log(' ==============> 图片加载错误', e)
63
62
  errorSrc && setImgSrc(errorSrc)
64
63
  hideErrorImage && setImageErrState(true)
65
64
  typeof onError === 'function' && onError(e, src, props)
66
65
  const { shopId, venderId } = global.info.queryInfo || {}
67
66
  sgmCustomReport({
68
67
  code: 'jshopViewImageLoadError',
69
68
  msg: {
70
69
  shopId,
71
70
  venderId,
72
71
  buildType,
73
72
  originSrc: src,
74
73
  requestSrc: requestSrcRef.current,
75
74
  },
76
75
  })
77
76
  },
78
77
  [src],
79
78
  )
80
79
 
81
80
  const imageLoad = useCallback(
82
81
  (_src, event) => {
83
82
  setLoadSuccess(true)
84
83
  typeof onLoad === 'function' && onLoad(event, src, props)
85
84
  },
86
85
  [src],
87
86
  )
88
87
 
89
88
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
90
89
  const changeStyle = {}
91
90
  width && (changeStyle['width'] = width)
92
91
  height && (changeStyle['height'] = height)
93
92
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
94
93
  return changeStyle
95
94
  }
96
95
  useEffect(() => {
97
96
  setMeasureComplete(true)
98
97
  if (needShowHighVersion) return
99
98
  const latestRes =
100
99
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
101
100
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
102
101
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
103
102
  !componentShowStateRef.current && dealPageScrollInfo(res)
104
103
  })
105
104
  }, [])
106
105
 
107
106
  const dealPageScrollInfo = (res) => {
108
107
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
109
108
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
110
109
  return
111
110
  if (measureRef.current) {
112
111
  const eleClientRect = measureRef.current.getBoundingClientRect()
113
112
  const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY
114
113
  const eleOffsetTop = Math.ceil(eleClientRect.top)
115
114
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
116
115
  if (!componentShowStateRef.current) {
117
116
  if (getContainerHeightOffSetY > eleOffsetTop) {
118
117
  componentShowStateRef.current = true
119
118
  setComponentShowState(true)
120
119
  }
121
120
  }
122
121
  }
123
122
  }
124
123
  return isH5AndJdShopView &&
125
124
  global?.config?.needImageLazy !== false &&
126
125
  !needShowHighVersion &&
127
126
  !isAppStowShop ? (
128
127
  <View
129
128
  ref={measureRef}
130
129
  className={classNames(
131
130
  imageStyle['d-app-lazy-image'],
132
131
  {
133
132
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
134
133
  },
135
134
  {
136
135
  [imageStyle['d-hide-image-error']]: imageErrState,
137
136
  },
138
137
  {
139
138
  [imageStyle['d-load-completed']]: loadSuccess,
140
139
  },
141
140
  {
142
141
  'd-imag-rendering-crisp-edges':
143
142
  !taroJdBaseInfo.info.pageInfo.isVipShop && imagRenderingSet,
144
143
  },
145
144
  'J_html5ImageBg',
146
145
  className,
147
146
  )}
148
147
  style={{
149
148
  ...style,
150
149
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
151
150
  }}
152
151
  {...otherOption}
153
152
  >
154
153
  {(componentShowState || lazyLoad === false) && (
155
154
  <img
156
155
  src={getQualityImage(
157
156
  imgSrc,
158
157
  taroJdBaseInfo.info.pageInfo.isVipShop
159
158
  ? NetWorkTypeQuality['perfect']
160
159
  : NetWorkTypeQuality[getNetWorkType],
161
160
  )}
162
161
  onLoad={imageLoad.bind(this, imgSrc)}
163
162
  onError={imageError}
164
163
  />
165
164
  )}
166
165
  </View>
167
166
  ) : enableAvifOptimize ? (
168
167
  [
169
168
  measureComplete ? (
170
169
  <Image
171
170
  key={'realImage'}
172
171
  style={{
173
172
  ...style,
174
173
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
175
174
  }}
176
175
  className={classNames(
177
176
  imageStyle['d-lazy-image'],
178
177
  {
179
178
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
180
179
  },
181
180
  {
182
181
  [imageStyle['d-hide-image-error']]: imageErrState,
183
182
  },
184
183
  {
185
184
  [imageStyle['d-load-completed']]: loadSuccess,
186
185
  },
187
186
  {
188
187
  'd-imag-rendering-crisp-edges': imagRenderingSet,
189
188
  },
190
189
  className,
191
190
  )}
192
191
  src={getRequestSrc(imgSrc)}
193
192
  lazyLoad={isChartH5 ? false : lazyLoad}
194
193
  onError={imageError}
195
194
  onLoad={imageLoad.bind(this, imgSrc)}
196
195
  {...otherOption}
197
196
  />
198
197
  ) : (
199
198
  <Image
200
199
  key={'defaultImage'}
201
200
  style={{
202
201
  ...style,
203
202
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
204
203
  }}
205
204
  className={classNames(
206
205
  imageStyle['d-lazy-image'],
207
206
  {
208
207
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
209
208
  },
210
209
  {
211
210
  [imageStyle['d-hide-image-error']]: imageErrState,
212
211
  },
213
212
  {
214
213
  [imageStyle['d-load-completed']]: loadSuccess,
215
214
  },
216
215
  {
217
216
  'd-imag-rendering-crisp-edges': imagRenderingSet,
218
217
  },
219
218
  className,
220
219
  )}
221
220
  src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
222
221
  />
223
222
  ),
224
223
  loadSuccess ? null : <View key={'measureRef'} ref={measureRef}></View>,
225
224
  ]
226
225
  ) : (
227
226
  <Image
228
227
  style={{
229
228
  ...style,
230
229
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
231
230
  }}
232
231
  className={classNames(
233
232
  imageStyle['d-lazy-image'],
234
233
  {
235
234
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
236
235
  },
237
236
  {
238
237
  [imageStyle['d-hide-image-error']]: imageErrState,
239
238
  },
240
239
  {
241
240
  [imageStyle['d-load-completed']]: loadSuccess,
242
241
  },
243
242
  {
244
243
  'd-imag-rendering-crisp-edges': imagRenderingSet,
245
244
  },
246
245
  className,
247
246
  )}
248
247
  src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
249
248
  lazyLoad={isChartH5 ? false : lazyLoad}
250
249
  onError={imageError}
251
250
  onLoad={imageLoad.bind(this, imgSrc)}
252
251
  {...otherOption}
253
252
  />
254
253
  )
254
+ import React, { useCallback, useEffect, useRef, useState } from 'react'
255
255
  getQualityImage,
256
256
  isH5AndJdShopView,
257
257
  isJdApp,
258
258
  isChartH5,
259
259
  isH5AndJdShopViewH5Scroll,
260
260
  isAppStowShop,
261
261
  getSgmCustomCode,
262
262
  sgmCustomReport,
263
263
  isImageOptimizeEnable,
264
264
  getAvifSupport,
265
265
  getWebpSupport,
266
266
  getNativePageScrollRes,
267
267
  latestFromNativeMsgStorage,
268
268
  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAAAAp3o92gAAAAF0Uk5TAEDm2GYAAAAKSURBVHicY2QAAAAEAAIhZK1qAAAAAElFTkSuQmCC";
269
269
  'https://img14.360buyimg.com/imagetools/jfs/t1/222907/25/7012/5824/61c4797cEbcd17c7f/6c76fc71e4fdb5a5.png'
270
270
  const {
271
271
  src = null,
272
272
  lazyLoad = true,
273
273
  imagRenderingSet = true,
274
274
  width = null,
275
275
  height = null,
276
276
  className = null,
277
277
  isSkuImage = false,
278
278
  hideErrorImage = false,
279
279
  style = null,
280
280
  backgroundColor = null,
281
281
  errorSrc = null,
282
282
  onLoad = null,
283
283
  onError = null,
284
284
  ...otherOption
285
285
  } = props
286
286
  getNetWorkType === NetWorkTypeQuality.default &&
287
287
  (getNetWorkType = global.info.sysInfo.netWorkType)
288
288
  const [loadSuccess, setLoadSuccess] = useState(false)
289
289
  const [imageErrState, setImageErrState] = useState(false)
290
290
  const [componentShowState, setComponentShowState] = useState(false)
291
291
  const measureRef = useRef<HTMLElement | null>(null)
292
292
  const [measureComplete, setMeasureComplete] = useState(false)
293
293
  const [imgSrc, setImgSrc] = useState(src)
294
294
  const [hasRetrySuccess, setHasRetrySuccess] = useState(false)
295
295
  const hasRetryRef = useRef(false)
296
296
  const componentShowStateRef = useRef(false)
297
297
  const requestSrcRef = useRef(src)
298
298
  const needShowHighVersion =
299
299
  isH5AndJdShopViewH5Scroll &&
300
300
  !(
301
301
  global.info.queryInfo?.downgraded &&
302
302
  global.info.queryInfo.downgraded === 'true'
303
303
  )
304
304
  const enableAvifOptimize = isImageOptimizeEnable()
305
305
  const avifSupport = getAvifSupport();
306
306
  const webpSupport = getWebpSupport();
307
307
 
308
308
  const getRequestSrc = useCallback(
309
309
  (src) => {
310
310
  const requestSrc = getQualityImage(imgSrc, {
311
311
  isSkuImage,
312
312
  size: measureRef?.current?.offsetWidth,
313
313
  })
314
314
  requestSrcRef.current = requestSrc
315
315
  return requestSrc
316
316
  },
317
317
  [src],
318
318
  )
319
319
 
320
320
  const imageErrorRetry = (src) => {
321
321
  return new Promise((resolve, reject) => {
322
322
  if (fetch && window && window.Image) {
323
323
  fetch(src)
324
324
  .then((response) => {
325
325
  const { ok, status } = response
326
326
  if (ok) {
327
327
  const originUrl = src.replace(/\.(jpe?g|png).*/, ".$1");
328
328
  response
329
329
  .blob()
330
330
  .then((blob) => {
331
331
  if (URL) {
332
332
  const url = URL.createObjectURL(blob);
333
333
  const img = new window.Image();
334
334
  img.src = url;
335
335
  img.onload = () => {
336
336
  reportSGM({
337
337
  status,
338
338
  text: "再次请求并且onload了",
339
339
  type: "retryAndOnload",
340
340
  requestSrc: src,
341
341
  resolveUrl: url,
342
342
  });
343
343
  resolve({
344
344
  ok: true,
345
345
  url,
346
346
  });
347
347
  setTimeout(() => {
348
348
  URL.revokeObjectURL(url);
349
349
  }, 2000);
350
350
  };
351
351
  img.onerror = () => {
352
352
  reportSGM({
353
353
  status,
354
354
  text: "图片解析异常",
355
355
  type: "imageParseError",
356
356
  requestSrc: src,
357
357
  });
358
358
  URL.revokeObjectURL(url);
359
359
  resolve({
360
360
  ok: true,
361
361
  url: originUrl,
362
362
  });
363
363
  };
364
364
  } else {
365
365
  resolve({
366
366
  ok: true,
367
367
  url: originUrl,
368
368
  });
369
369
  }
370
370
  })
371
371
  .catch((error) => {
372
372
  resolve({
373
373
  ok: true,
374
374
  url: originUrl,
375
375
  });
376
376
  console.error(
377
377
  "LazyLoadImage imageErrorRetry() error:",
378
378
  error
379
379
  );
380
380
  });
381
381
  } else {
382
382
  if (status === 404) {
383
383
  resolve({
384
384
  ok: false,
385
385
  text: '访问图片不存在',
386
386
  type: 'noSuchUrlImage',
387
387
  })
388
388
  } else {
389
389
  resolve({
390
390
  ok: false,
391
391
  status: status,
392
392
  text: '其它图片问题',
393
393
  type: 'otherImageError',
394
394
  })
395
395
  }
396
396
  }
397
397
  })
398
398
  .catch((error) => {
399
399
  resolve({
400
400
  ok: false,
401
401
  text: '网络异常',
402
402
  type: 'networkError',
403
403
  })
404
404
  console.error('LazyLoadImage imageErrorRetry() error:', error)
405
405
  })
406
406
  } else {
407
407
  resolve({
408
408
  ok: false,
409
409
  text: '不支持重试',
410
410
  type: 'notSupportRetry',
411
411
  })
412
412
  }
413
413
  })
414
414
  }
415
415
 
416
416
  const reportSGM = ({
417
417
  status,
418
418
  text,
419
419
  type,
420
420
  requestSrc = imgSrc,
421
421
  resolveUrl = "",
422
422
  }) => {
423
423
  const { shopId, venderId } = global.info.queryInfo || {};
424
424
  sgmCustomReport({
425
425
  code: getSgmCustomCode(`${SgmCustomCode.IMAGE_LOAD}_${type}`),
426
426
  msg: {
427
427
  avifSupport,
428
428
  webpSupport,
429
429
  shopId,
430
430
  venderId,
431
431
  originSrc: src,
432
432
  requestSrc,
433
433
  resolveUrl,
434
434
  status,
435
435
  text,
436
436
  },
437
437
  });
438
438
  };
439
439
  const imageErrorHandle = useCallback(
440
440
  (e) => {
441
441
  console.log(' ==============> 图片加载错误', e)
442
442
  if (!hasRetryRef.current) {
443
443
  hasRetryRef.current = true
444
444
  if (src) {
445
445
  try {
446
446
  imageErrorRetry(requestSrcRef.current).then((result) => {
447
447
  const { status, ok, text, type, url } = result || {}
448
448
  if (ok) {
449
449
  setImgSrc(url)
450
450
  setHasRetrySuccess(true)
451
451
  } else {
452
452
  errorSrc && setImgSrc(errorSrc)
453
453
  hideErrorImage && setImageErrState(true)
454
454
  typeof onError === 'function' && onError(e, src, props)
455
455
  reportSGM({
456
456
  status,
457
457
  text,
458
458
  type,
459
459
  requestSrc: requestSrcRef.current,
460
460
  });
461
461
  }
462
462
  })
463
463
  } catch (e) {
464
464
  console.error('LazyLoadImage imageErrorHandle() error:', e)
465
465
  errorSrc && setImgSrc(errorSrc)
466
466
  hideErrorImage && setImageErrState(true)
467
467
  typeof onError === 'function' && onError(e, src, props)
468
468
  }
469
469
  }
470
470
  } else {
471
471
  reportSGM({
472
472
  status: "",
473
473
  text: "渲染原始图片渲染异常",
474
474
  type: "renderOriginImageError",
475
475
  });
476
476
  if (imgSrc.includes("blob:")) {
477
477
  reportSGM({
478
478
  status: "",
479
479
  text: "渲染本地blob图片异常",
480
480
  type: "renderBlobImageError",
481
481
  });
482
482
  } else {
483
483
  reportSGM({
484
484
  status: "",
485
485
  text: "渲染本地非blob图片异常",
486
486
  type: "renderNoBlobImageError",
487
487
  });
488
488
  }
489
489
  }
490
490
  },
491
491
  [src, hasRetryRef.current],
492
492
  )
493
493
 
494
494
  const imageLoad = useCallback(
495
495
  (_src, event) => {
496
496
  setLoadSuccess(true)
497
497
  typeof onLoad === 'function' && onLoad(event, src, props)
498
498
  },
499
499
  [src],
500
500
  )
501
501
 
502
502
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
503
503
  const changeStyle = {}
504
504
  width && (changeStyle['width'] = width)
505
505
  height && (changeStyle['height'] = height)
506
506
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
507
507
  return changeStyle
508
508
  }
509
509
  useEffect(() => {
510
510
  setMeasureComplete(true)
511
511
  if (needShowHighVersion) return
512
512
  const latestRes =
513
513
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
514
514
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
515
515
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
516
516
  !componentShowStateRef.current && dealPageScrollInfo(res)
517
517
  })
518
518
  }, [])
519
519
 
520
520
  const dealPageScrollInfo = (res) => {
521
521
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
522
522
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
523
523
  return
524
524
  if (measureRef.current) {
525
525
  const eleClientRect = measureRef.current.getBoundingClientRect()
526
526
  const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY
527
527
  const eleOffsetTop = Math.ceil(eleClientRect.top)
528
528
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
529
529
  if (!componentShowStateRef.current) {
530
530
  if (getContainerHeightOffSetY > eleOffsetTop) {
531
531
  componentShowStateRef.current = true
532
532
  setComponentShowState(true)
533
533
  }
534
534
  }
535
535
  }
536
536
  }
537
537
  return isH5AndJdShopView &&
538
538
  global?.config?.needImageLazy !== false &&
539
539
  !needShowHighVersion &&
540
540
  !isAppStowShop ? (
541
541
  <View
542
542
  ref={measureRef}
543
543
  className={classNames(
544
544
  imageStyle['d-app-lazy-image'],
545
545
  {
546
546
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
547
547
  },
548
548
  {
549
549
  [imageStyle['d-hide-image-error']]: imageErrState,
550
550
  },
551
551
  {
552
552
  [imageStyle['d-load-completed']]: loadSuccess,
553
553
  },
554
554
  {
555
555
  'd-imag-rendering-crisp-edges':
556
556
  !global.info.pageInfo.isVipShop && imagRenderingSet,
557
557
  },
558
558
  'J_html5ImageBg',
559
559
  className,
560
560
  )}
561
561
  style={{
562
562
  ...style,
563
563
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
564
564
  }}
565
565
  {...otherOption}
566
566
  >
567
567
  {(componentShowState || lazyLoad === false) && (
568
568
  <img
569
569
  src={getQualityImage(
570
570
  imgSrc,
571
571
  global.info.pageInfo.isVipShop
572
572
  ? NetWorkTypeQuality['perfect']
573
573
  : NetWorkTypeQuality[getNetWorkType],
574
574
  )}
575
575
  onLoad={imageLoad.bind(this, imgSrc)}
576
576
  onError={imageErrorHandle}
577
577
  />
578
578
  )}
579
579
  </View>
580
580
  ) : enableAvifOptimize ? (
581
581
  [
582
582
  measureComplete ? (
583
583
  <Image
584
584
  key={hasRetrySuccess ? 'realImageRetry' : 'realImage'}
585
585
  style={{
586
586
  ...style,
587
587
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
588
588
  }}
589
589
  className={classNames(
590
590
  imageStyle['d-lazy-image'],
591
591
  {
592
592
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
593
593
  },
594
594
  {
595
595
  [imageStyle['d-hide-image-error']]: imageErrState,
596
596
  },
597
597
  {
598
598
  [imageStyle['d-load-completed']]: loadSuccess,
599
599
  },
600
600
  {
601
601
  'd-imag-rendering-crisp-edges': imagRenderingSet,
602
602
  },
603
603
  className,
604
604
  )}
605
605
  src={hasRetrySuccess ? imgSrc : getRequestSrc(imgSrc)}
606
606
  lazyLoad={isChartH5 ? false : lazyLoad}
607
607
  onError={imageErrorHandle}
608
608
  onLoad={imageLoad.bind(this, imgSrc)}
609
609
  {...otherOption}
610
610
  />
611
611
  ) : (
612
612
  <Image
613
613
  key={'defaultImage'}
614
614
  style={{
615
615
  ...style,
616
616
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
617
617
  }}
618
618
  className={classNames(
619
619
  imageStyle['d-lazy-image'],
620
620
  {
621
621
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
622
622
  },
623
623
  {
624
624
  [imageStyle['d-hide-image-error']]: imageErrState,
625
625
  },
626
626
  {
627
627
  [imageStyle['d-load-completed']]: loadSuccess,
628
628
  },
629
629
  {
630
630
  'd-imag-rendering-crisp-edges': imagRenderingSet,
631
631
  },
632
632
  className,
633
633
  )}
634
634
  src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
635
635
  />
636
636
  ),
637
637
  loadSuccess ? null : <View key={'measureRef'} ref={measureRef}></View>,
638
638
  ]
639
639
  ) : (
640
640
  <Image
641
641
  style={{
642
642
  ...style,
643
643
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
644
644
  }}
645
645
  className={classNames(
646
646
  imageStyle['d-lazy-image'],
647
647
  {
648
648
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
649
649
  },
650
650
  {
651
651
  [imageStyle['d-hide-image-error']]: imageErrState,
652
652
  },
653
653
  {
654
654
  [imageStyle['d-load-completed']]: loadSuccess,
655
655
  },
656
656
  {
657
657
  'd-imag-rendering-crisp-edges': imagRenderingSet,
658
658
  },
659
659
  className,
660
660
  )}
661
661
  src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
662
662
  lazyLoad={isChartH5 ? false : lazyLoad}
663
663
  onError={imageErrorHandle}
664
664
  onLoad={imageLoad.bind(this, imgSrc)}
665
665
  {...otherOption}
666
666
  />
667
667
  )
@@ -7,3 +7,11 @@
7
7
  position: relative;
8
8
  }
9
9
  }
10
+ :global {
11
+ .d-mobile-header-sticky {
12
+ position: fixed;
13
+ top: 0;
14
+ width: 100%;
15
+ z-index: 999;
16
+ }
17
+ }