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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import 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
  getNativePageScrollRes,
265
265
  latestFromNativeMsgStorage,
266
266
  "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=";
267
267
  "https://img14.360buyimg.com/imagetools/jfs/t1/222907/25/7012/5824/61c4797cEbcd17c7f/6c76fc71e4fdb5a5.png";
268
268
  const {
269
269
  src = null,
270
270
  lazyLoad = true,
271
271
  imagRenderingSet = true,
272
272
  width = null,
273
273
  height = null,
274
274
  className = null,
275
275
  isSkuImage = false,
276
276
  hideErrorImage = false,
277
277
  style = null,
278
278
  backgroundColor = null,
279
279
  errorSrc = null,
280
280
  onLoad = null,
281
281
  onError = null,
282
282
  ...otherOption
283
283
  } = props;
284
284
  getNetWorkType === NetWorkTypeQuality.default &&
285
285
  (getNetWorkType = global.info.sysInfo.netWorkType);
286
286
  const [loadSuccess, setLoadSuccess] = useState(false);
287
287
  const [imageErrState, setImageErrState] = useState(false);
288
288
  const [componentShowState, setComponentShowState] = useState(false);
289
289
  const measureRef = useRef<HTMLElement | null>(null);
290
290
  const [measureComplete, setMeasureComplete] = useState(false);
291
291
  const [imgSrc, setImgSrc] = useState(src);
292
292
  const [hasRetrySuccess, setHasRetrySuccess] = useState(false);
293
293
  const hasRetryRef = useRef(false);
294
294
  const componentShowStateRef = useRef(false);
295
295
  const requestSrcRef = useRef(src);
296
296
  const needShowHighVersion =
297
297
  isH5AndJdShopViewH5Scroll &&
298
298
  !(
299
299
  global.info.queryInfo?.downgraded &&
300
300
  global.info.queryInfo.downgraded === "true"
301
301
  );
302
302
  const enableAvifOptimize = isImageOptimizeEnable();
303
303
 
304
304
  const getRequestSrc = useCallback(
305
305
  (src) => {
306
306
  const requestSrc = getQualityImage(imgSrc, {
307
307
  isSkuImage,
308
308
  size: measureRef?.current?.offsetWidth,
309
309
  });
310
310
  requestSrcRef.current = requestSrc;
311
311
  return requestSrc;
312
312
  },
313
313
  [src]
314
314
  );
315
315
 
316
316
  const imageErrorRetry = (src) => {
317
317
  return new Promise((resolve, reject) => {
318
318
  if (fetch && window && window.Image) {
319
319
  fetch(src)
320
320
  .then((response) => {
321
321
  const { ok, status } = response;
322
322
  if (ok) {
323
323
  response.blob().then((blob) => {
324
324
  const url = URL.createObjectURL(blob);
325
325
  const img = new window.Image();
326
326
  img.src = url;
327
327
  img.onload = () => {
328
328
  resolve({
329
329
  ok: true,
330
330
  url,
331
331
  });
332
332
  setTimeout(() => {
333
333
  URL.revokeObjectURL(url);
334
334
  }, 1000);
335
335
  };
336
336
  img.onerror = () => {
337
337
  resolve({
338
338
  ok: false,
339
339
  text: "图片解析异常",
340
340
  type: "imageParseError",
341
341
  });
342
342
  URL.revokeObjectURL(url);
343
343
  };
344
344
  });
345
345
  } else {
346
346
  if (status === 404) {
347
347
  resolve({
348
348
  ok: false,
349
349
  text: "访问图片不存在",
350
350
  type: "noSuchUrlImage",
351
351
  });
352
352
  } else {
353
353
  resolve({
354
354
  ok: false,
355
355
  status: status,
356
356
  text: "其它图片问题",
357
357
  type: "otherImageError",
358
358
  });
359
359
  }
360
360
  }
361
361
  })
362
362
  .catch((error) => {
363
363
  resolve({
364
364
  ok: false,
365
365
  text: "网络异常",
366
366
  type: "networkError",
367
367
  });
368
368
  console.error("LazyLoadImage imageErrorRetry() error:", error);
369
369
  });
370
370
  } else {
371
371
  resolve({
372
372
  ok: false,
373
373
  text: "不支持重试",
374
374
  type: "notSupportRetry",
375
375
  });
376
376
  }
377
377
  });
378
378
  };
379
379
  const imageErrorHandle = useCallback(
380
380
  (e) => {
381
381
  console.log(" ==============> 图片加载错误", e);
382
382
  if (!hasRetryRef.current) {
383
383
  hasRetryRef.current = true;
384
384
  if (src) {
385
385
  try {
386
386
  imageErrorRetry(requestSrcRef.current).then((result) => {
387
387
  const { status, ok, text, type, url } = result || {};
388
388
  if (ok) {
389
389
  setImgSrc(url);
390
390
  setHasRetrySuccess(true);
391
391
  } else {
392
392
  errorSrc && setImgSrc(errorSrc);
393
393
  hideErrorImage && setImageErrState(true);
394
394
  typeof onError === "function" && onError(e, src, props);
395
395
  const { shopId, venderId } = global.info.queryInfo || {};
396
396
  sgmCustomReport({
397
397
  code: getSgmCustomCode(`${SgmCustomCode.IMAGE_LOAD}_${type}`),
398
398
  msg: {
399
399
  shopId,
400
400
  venderId,
401
401
  originSrc: src,
402
402
  requestSrc: requestSrcRef.current,
403
403
  status,
404
404
  text,
405
405
  },
406
406
  });
407
407
  }
408
408
  });
409
409
  } catch (e) {
410
410
  console.error("LazyLoadImage imageErrorHandle() error:", e);
411
411
  errorSrc && setImgSrc(errorSrc);
412
412
  hideErrorImage && setImageErrState(true);
413
413
  typeof onError === "function" && onError(e, src, props);
414
414
  }
415
415
  }
416
416
  }
417
417
  },
418
418
  [src, hasRetryRef.current]
419
419
  );
420
420
 
421
421
  const imageLoad = useCallback(
422
422
  (_src, event) => {
423
423
  setLoadSuccess(true);
424
424
  typeof onLoad === "function" && onLoad(event, src, props);
425
425
  },
426
426
  [src]
427
427
  );
428
428
 
429
429
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
430
430
  const changeStyle = {};
431
431
  width && (changeStyle["width"] = width);
432
432
  height && (changeStyle["height"] = height);
433
433
  backgroundColor && (changeStyle["backgroundColor"] = backgroundColor);
434
434
  return changeStyle;
435
435
  };
436
436
  useEffect(() => {
437
437
  setMeasureComplete(true);
438
438
  if (needShowHighVersion) return;
439
439
  const latestRes =
440
440
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {};
441
441
  !componentShowStateRef.current && dealPageScrollInfo(latestRes);
442
442
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
443
443
  !componentShowStateRef.current && dealPageScrollInfo(res);
444
444
  });
445
445
  }, []);
446
446
 
447
447
  const dealPageScrollInfo = (res) => {
448
448
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {};
449
449
  if (typeof displayHeight === "undefined" || typeof offSetY === "undefined")
450
450
  return;
451
451
  if (measureRef.current) {
452
452
  const eleClientRect = measureRef.current.getBoundingClientRect();
453
453
  const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY;
454
454
  const eleOffsetTop = Math.ceil(eleClientRect.top);
455
455
  const eleOffsetHeight = Math.ceil(eleClientRect.height);
456
456
  if (!componentShowStateRef.current) {
457
457
  if (getContainerHeightOffSetY > eleOffsetTop) {
458
458
  componentShowStateRef.current = true;
459
459
  setComponentShowState(true);
460
460
  }
461
461
  }
462
462
  }
463
463
  };
464
464
  return isH5AndJdShopView &&
465
465
  global?.config?.needImageLazy !== false &&
466
466
  !needShowHighVersion &&
467
467
  !isAppStowShop ? (
468
468
  <View
469
469
  ref={measureRef}
470
470
  className={classNames(
471
471
  imageStyle["d-app-lazy-image"],
472
472
  {
473
473
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
474
474
  },
475
475
  {
476
476
  [imageStyle["d-hide-image-error"]]: imageErrState,
477
477
  },
478
478
  {
479
479
  [imageStyle["d-load-completed"]]: loadSuccess,
480
480
  },
481
481
  {
482
482
  "d-imag-rendering-crisp-edges":
483
483
  !global.info.pageInfo.isVipShop && imagRenderingSet,
484
484
  },
485
485
  "J_html5ImageBg",
486
486
  className
487
487
  )}
488
488
  style={{
489
489
  ...style,
490
490
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
491
491
  }}
492
492
  {...otherOption}
493
493
  >
494
494
  {(componentShowState || lazyLoad === false) && (
495
495
  <img
496
496
  src={getQualityImage(
497
497
  imgSrc,
498
498
  global.info.pageInfo.isVipShop
499
499
  ? NetWorkTypeQuality["perfect"]
500
500
  : NetWorkTypeQuality[getNetWorkType]
501
501
  )}
502
502
  onLoad={imageLoad.bind(this, imgSrc)}
503
503
  onError={imageErrorHandle}
504
504
  />
505
505
  )}
506
506
  </View>
507
507
  ) : enableAvifOptimize ? (
508
508
  [
509
509
  measureComplete ? (
510
510
  <Image
511
511
  key={hasRetrySuccess ? "realImageRetry" : "realImage"}
512
512
  style={{
513
513
  ...style,
514
514
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
515
515
  }}
516
516
  className={classNames(
517
517
  imageStyle["d-lazy-image"],
518
518
  {
519
519
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
520
520
  },
521
521
  {
522
522
  [imageStyle["d-hide-image-error"]]: imageErrState,
523
523
  },
524
524
  {
525
525
  [imageStyle["d-load-completed"]]: loadSuccess,
526
526
  },
527
527
  {
528
528
  "d-imag-rendering-crisp-edges": imagRenderingSet,
529
529
  },
530
530
  className
531
531
  )}
532
532
  src={hasRetrySuccess ? imgSrc : getRequestSrc(imgSrc)}
533
533
  lazyLoad={isChartH5 ? false : lazyLoad}
534
534
  onError={imageErrorHandle}
535
535
  onLoad={imageLoad.bind(this, imgSrc)}
536
536
  {...otherOption}
537
537
  />
538
538
  ) : (
539
539
  <Image
540
540
  key={"defaultImage"}
541
541
  style={{
542
542
  ...style,
543
543
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
544
544
  }}
545
545
  className={classNames(
546
546
  imageStyle["d-lazy-image"],
547
547
  {
548
548
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
549
549
  },
550
550
  {
551
551
  [imageStyle["d-hide-image-error"]]: imageErrState,
552
552
  },
553
553
  {
554
554
  [imageStyle["d-load-completed"]]: loadSuccess,
555
555
  },
556
556
  {
557
557
  "d-imag-rendering-crisp-edges": imagRenderingSet,
558
558
  },
559
559
  className
560
560
  )}
561
561
  src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
562
562
  />
563
563
  ),
564
564
  loadSuccess ? null : <View key={"measureRef"} ref={measureRef}></View>,
565
565
  ]
566
566
  ) : (
567
567
  <Image
568
568
  style={{
569
569
  ...style,
570
570
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
571
571
  }}
572
572
  className={classNames(
573
573
  imageStyle["d-lazy-image"],
574
574
  {
575
575
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
576
576
  },
577
577
  {
578
578
  [imageStyle["d-hide-image-error"]]: imageErrState,
579
579
  },
580
580
  {
581
581
  [imageStyle["d-load-completed"]]: loadSuccess,
582
582
  },
583
583
  {
584
584
  "d-imag-rendering-crisp-edges": imagRenderingSet,
585
585
  },
586
586
  className
587
587
  )}
588
588
  src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
589
589
  lazyLoad={isChartH5 ? false : lazyLoad}
590
590
  onError={imageErrorHandle}
591
591
  onLoad={imageLoad.bind(this, imgSrc)}
592
592
  {...otherOption}
593
593
  />
594
594
  );
@@ -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
+ }