@conecli/cone-render 0.9.1-shop2.2 → 0.9.1-shop2.20

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 (103) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/environmentType.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/jdplayerSdk.ts +1 -0
  9. package/dist/common/jssdk.ts +1 -0
  10. package/dist/common/pageType.ts +1 -0
  11. package/dist/common/sgmCustomCode.ts +1 -0
  12. package/dist/common/token/index.h5.ts +1 -1
  13. package/dist/common/token/token.jd.ts +1 -1
  14. package/dist/common/token/token.ts +1 -1
  15. package/dist/common/wxappApi.jd.ts +1 -0
  16. package/dist/components/ErrorBoundary.tsx +1 -1
  17. package/dist/components/base/CountDown/index.tsx +1 -1
  18. package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
  19. package/dist/components/base/CustomScrollView/index.module.scss +7 -0
  20. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  21. package/dist/components/base/CustomVideo/index.tsx +1 -1
  22. package/dist/components/base/Dialog/index.module.scss +5 -0
  23. package/dist/components/base/Dialog/index.tsx +1 -1
  24. package/dist/components/base/Exposure/index.h5.tsx +1 -1
  25. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  26. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  27. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  28. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  29. package/dist/components/base/InViewRender/index.tsx +1 -1
  30. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  31. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  32. package/dist/components/base/LazyLoadImage/const.ts +1 -1
  33. package/dist/components/base/LazyLoadImage/index.h5.module.scss +23 -20
  34. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  35. package/dist/components/base/MobileCommonHeader/index.module.scss +17 -0
  36. package/dist/components/base/MobileCommonHeader/index.tsx +1 -0
  37. package/dist/components/base/NetworkDataError/const.ts +1 -1
  38. package/dist/components/base/NetworkDataError/index.module.scss +7 -0
  39. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  40. package/dist/components/base/Price/Double/index.tsx +1 -1
  41. package/dist/components/base/Price/index.tsx +1 -1
  42. package/dist/components/decorate/DecorateFloorModule/index.module.scss +32 -2
  43. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  44. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  45. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  46. package/dist/components/floorItem.jd.tsx +1 -1
  47. package/dist/components/floorItem.tsx +1 -1
  48. package/dist/components/floorItem.weapp.tsx +1 -1
  49. package/dist/components/isv/Floor/index.tsx +1 -1
  50. package/dist/components/remoteFloorItem.tsx +1 -1
  51. package/dist/interface/common.ts +1 -1
  52. package/dist/interface/component.ts +1 -1
  53. package/dist/interface/jumpEventReport.ts +1 -1
  54. package/dist/interface/service.ts +1 -1
  55. package/dist/interface/utils.ts +1 -1
  56. package/dist/jumpEventReport/base.ts +1 -1
  57. package/dist/jumpEventReport/const.ts +1 -1
  58. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  59. package/dist/jumpEventReport/index.h5.ts +1 -1
  60. package/dist/jumpEventReport/index.jd.ts +1 -1
  61. package/dist/jumpEventReport/index.weapp.ts +1 -1
  62. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  63. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  64. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  65. package/dist/jumpEventReport/web/report.ts +1 -1
  66. package/dist/jumpEventReport/web.base.ts +1 -1
  67. package/dist/jumpEventReport/web.jd.ts +1 -1
  68. package/dist/jumpEventReport/web.jdb.ts +1 -1
  69. package/dist/jumpEventReport/web.jdjch.ts +1 -1
  70. package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
  71. package/dist/jumpEventReport/web.tjapp.ts +1 -0
  72. package/dist/jumpEventReport/web.tjm.ts +1 -0
  73. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  74. package/dist/modules/ContainerFloorList/index.h5.module.scss +18 -1
  75. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  76. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  77. package/dist/open/api/device.ts +1 -1
  78. package/dist/open/api/environment.ts +1 -1
  79. package/dist/open/api/index.ts +1 -1
  80. package/dist/open/api/jump copy.ts +1 -1
  81. package/dist/open/api/request.ts +1 -1
  82. package/dist/open/api/shopMember.ts +1 -1
  83. package/dist/open/api/track.ts +1 -1
  84. package/dist/open/api/util.ts +1 -1
  85. package/dist/open/components/index.ts +1 -1
  86. package/dist/sass/app.h5.scss +49 -3
  87. package/dist/sass/base.scss +57 -0
  88. package/dist/service/fetchGateway.ts +1 -1
  89. package/dist/service/http/const.ts +1 -1
  90. package/dist/service/requestServer.ts +1 -1
  91. package/dist/utils/connectNativeJsBridge.ts +1 -1
  92. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  93. package/dist/utils/draExceptionAndProfile.ts +1 -1
  94. package/dist/utils/h5Utils.ts +1 -1
  95. package/dist/utils/index.h5.ts +1 -1
  96. package/dist/utils/index.ts +1 -1
  97. package/dist/utils/index.weapp.ts +1 -1
  98. package/dist/utils/jm-common.js +1 -1
  99. package/dist/utils/sgmCodeUtils.ts +1 -0
  100. package/dist/utils/taroRenderUtil.ts +1 -1
  101. package/dist/utils/utils.ts +1 -1
  102. package/package.json +1 -1
  103. package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
@@ -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
  getNativePageScrollRes,
8
7
  latestFromNativeMsgStorage,
9
8
  const {
10
9
  src,
11
10
  lazyLoad,
12
11
  imagRenderingSet,
13
12
  width,
14
13
  height,
15
14
  className,
16
15
  isSkuImage,
17
16
  hideErrorImage,
18
17
  style,
19
18
  backgroundColor,
20
19
  errorSrc,
21
20
  onLoad,
22
21
  onError,
23
22
  ...otherOption
24
23
  } = props
25
24
  getNetWorkType === NetWorkTypeQuality.default &&
26
25
  (getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
27
26
  const [loadSuccess, setLoadSuccess] = useState(false)
28
27
  const [imageErrState, setImageErrState] = useState(false)
29
28
  const [componentShowState, setComponentShowState] = useState(false)
30
29
  const [imgSrc, setImgSrc] = useState(src)
31
30
  const componentLazyRef = useRef<HTMLElement | null>(null)
32
31
  const componentShowStateRef = useRef(false)
33
32
  const needShowHighVersion =
34
33
  isH5AndJdShopViewH5Scroll &&
35
34
  !(
36
35
  global.info.queryInfo?.downgraded &&
37
36
  global.info.queryInfo.downgraded === 'true'
38
37
  )
39
38
  const { ref, inView } = useInView({
40
39
  threshold: 0,
41
40
  triggerOnce: true,
42
41
  root: null,
43
42
  rootMargin: `0px 0px ${window.innerHeight * 0.5}px 0px`,
44
43
  })
45
44
  const imageError = useCallback(
46
45
  (e) => {
47
46
  console.log('图片加载错误', e)
48
47
  errorSrc && setImgSrc(errorSrc)
49
48
  hideErrorImage && setImageErrState(true)
50
49
  typeof onError === 'function' && onError(e, src, props)
51
50
  },
52
51
  [src],
53
52
  )
54
53
 
55
54
  const imageLoad = useCallback(
56
55
  (_src, event) => {
57
56
  setLoadSuccess(true)
58
57
  typeof onLoad === 'function' && onLoad(event, src, props)
59
58
  },
60
59
  [src],
61
60
  )
62
61
 
63
62
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
64
63
  const changeStyle = {}
65
64
  width && (changeStyle['width'] = width)
66
65
  height && (changeStyle['height'] = height)
67
66
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
68
67
  return changeStyle
69
68
  }
70
69
  useEffect(() => {
71
70
  if (needShowHighVersion) return
72
71
  const latestRes =
73
72
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
74
73
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
75
74
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
76
75
  !componentShowStateRef.current && dealPageScrollInfo(res)
77
76
  })
78
77
  }, [])
79
78
 
80
79
  const dealPageScrollInfo = (res) => {
81
80
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
82
81
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
83
82
  return
84
83
  if (componentLazyRef.current) {
85
84
  const eleClientRect = componentLazyRef.current.getBoundingClientRect()
86
85
  const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY
87
86
  const eleOffsetTop = Math.ceil(eleClientRect.top)
88
87
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
89
88
  if (!componentShowStateRef.current) {
90
89
  if (getContainerHeightOffSetY > eleOffsetTop) {
91
90
  componentShowStateRef.current = true
92
91
  setComponentShowState(true)
93
92
  }
94
93
  }
95
94
  }
96
95
  }
97
96
  <View
98
97
  ref={ componentLazyRef }
99
98
  className={classNames(
100
99
  imageStyle['d-app-lazy-image'],
101
100
  {
102
101
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
103
102
  },
104
103
  {
105
104
  [imageStyle['d-hide-image-error']]: imageErrState,
106
105
  },
107
106
  {
108
107
  [imageStyle['d-load-completed']]: loadSuccess,
109
108
  },
110
109
  {
111
110
  'd-imag-rendering-crisp-edges':
112
111
  !taroJdBaseInfo.info.pageInfo.isVipShop &&
113
112
  imagRenderingSet,
114
113
  },
115
114
  'J_html5ImageBg',
116
115
  className,
117
116
  )}
118
117
  style={{
119
118
  ...style,
120
119
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
121
120
  >
122
121
  {(componentShowState || lazyLoad === false) && <img
123
122
  src={getQualityImage(
124
123
  imgSrc,
125
124
  taroJdBaseInfo.info.pageInfo.isVipShop
126
125
  ? NetWorkTypeQuality['perfect']
127
126
  : NetWorkTypeQuality[getNetWorkType],
128
127
  )}
129
128
  onLoad={imageLoad.bind(this, imgSrc)}
130
129
  onError={imageError}
131
130
  />}
132
131
  </View>
133
132
  ) : (
134
133
  <Image
135
134
  style={{
136
135
  ...style,
137
136
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
138
137
  }}
139
138
  className={classNames(
140
139
  imageStyle['d-lazy-image'],
141
140
  {
142
141
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
143
142
  },
144
143
  {
145
144
  [imageStyle['d-hide-image-error']]: imageErrState,
146
145
  },
147
146
  {
148
147
  [imageStyle['d-load-completed']]: loadSuccess,
149
148
  },
150
149
  {
151
150
  'd-imag-rendering-crisp-edges': imagRenderingSet,
152
151
  },
153
152
  className,
154
153
  )}
155
154
  src={getQualityImage(
156
155
  imgSrc,
157
156
  NetWorkTypeQuality[getNetWorkType],
158
157
  )}
159
158
  lazyLoad={isChartH5 ? false : lazyLoad}
160
159
  onError={imageError}
161
160
  onLoad={imageLoad.bind(this, imgSrc)}
162
161
  {...otherOption}
163
162
  />
164
163
  )
165
164
  lazyLoad: true,
166
165
  isSkuImage: false,
167
166
  hideErrorImage: false,
168
167
  imagRenderingSet: true,
169
168
  src: null,
170
169
  style: null,
171
170
  width: null,
172
171
  height: null,
173
172
  backgroundColor: null,
174
173
  className: null,
175
174
  errorSrc: null,
176
175
  onLoad: null,
177
176
  onError: null,
177
+ import React, { useCallback, useEffect, useRef, useState } from 'react'
178
178
  TaroEventType,
179
179
  const {
180
180
  src,
181
181
  lazyLoad,
182
182
  imagRenderingSet,
183
183
  width,
184
184
  height,
185
185
  className,
186
186
  isSkuImage,
187
187
  hideErrorImage,
188
188
  style,
189
189
  backgroundColor,
190
190
  errorSrc,
191
191
  onLoad,
192
192
  onError,
193
193
  ...otherOption
194
194
  } = props
195
195
  getNetWorkType === NetWorkTypeQuality.default &&
196
196
  (getNetWorkType = global.info.sysInfo.netWorkType)
197
197
  const [loadSuccess, setLoadSuccess] = useState(false)
198
198
  const [imageErrState, setImageErrState] = useState(false)
199
199
  const [componentShowState, setComponentShowState] = useState(false)
200
200
  const measureRef = useRef < HTMLElement | null > (null)
201
201
  const [measureComplete, setMeasureComplete] = useState(false)
202
202
  const [imgSrc, setImgSrc] = useState(src)
203
203
  const [hasRetrySuccess, setHasRetrySuccess] = useState(false)
204
204
  const hasRetryRef = useRef(false)
205
205
  const componentShowStateRef = useRef(false)
206
206
  const requestSrcRef = useRef(src)
207
207
  const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
208
208
  const enableAvifOptimize = isImageOptimizeEnable()
209
209
  const avifSupport = getAvifSupport()
210
210
  const webpSupport = getWebpSupport()
211
211
 
212
212
 
213
213
  const getRequestSrc = useCallback((src) => {
214
214
  const requestSrc = getQualityImage(
215
215
  imgSrc,
216
216
  { isSkuImage, size: measureRef?.current?.offsetWidth }
217
217
  )
218
218
  requestSrcRef.current = requestSrc
219
219
  return requestSrc
220
220
  }, [src])
221
221
  const imageErrorRetry = (src) => {
222
222
  return new Promise((resolve, reject) => {
223
223
  if(fetch && window && window.Image){
224
224
  fetch(src)
225
225
  .then(response => {
226
226
  const {ok, status} = response
227
227
  if (ok) {
228
228
  const originUrl = src.replace(/\.(jpe?g|png).*/, '.$1')
229
229
  response.blob().then(blob => {
230
230
  if(URL){
231
231
  const url = URL.createObjectURL(blob)
232
232
  const img = new window.Image()
233
233
  img.src = url;
234
234
  img.onload = () => {
235
235
  reportSGM({status, text: '再次请求并且onload了', type: 'retryAndOnload', requestSrc: src, resolveUrl: url})
236
236
  resolve({
237
237
  ok: true,
238
238
  url
239
239
  })
240
240
  setTimeout(() => {
241
241
  URL.revokeObjectURL(url)
242
242
  }, 2000)
243
243
  };
244
244
  img.onerror = () => {
245
245
  reportSGM({status, text: '图片解析异常', type: 'imageParseError', requestSrc: src})
246
246
  URL.revokeObjectURL(url)
247
247
  resolve({
248
248
  ok: true,
249
249
  url: originUrl
250
250
  })
251
251
  };
252
252
  }else{
253
253
  resolve({
254
254
  ok: true,
255
255
  url: originUrl
256
256
  })
257
257
  }
258
258
  }).catch(error => {
259
259
  resolve({
260
260
  ok: true,
261
261
  url: originUrl
262
262
  })
263
263
  console.error('LazyLoadImage imageErrorRetry() error:', error)
264
264
  });
265
265
  }else {
266
266
  if(status === 404){
267
267
  resolve({
268
268
  ok: false,
269
269
  text: '访问图片不存在',
270
270
  type: 'noSuchUrlImage',
271
271
  })
272
272
  }else{
273
273
  resolve({
274
274
  ok: false,
275
275
  status: status,
276
276
  text: '其它图片问题',
277
277
  type: 'otherImageError',
278
278
  })
279
279
  }
280
280
  }
281
281
  })
282
282
  .catch(error => {
283
283
  resolve({
284
284
  ok: false,
285
285
  text: '网络异常',
286
286
  type: 'networkError',
287
287
  })
288
288
  console.error('LazyLoadImage imageErrorRetry() error:', error)
289
289
  });
290
290
  }else{
291
291
  resolve({
292
292
  ok: false,
293
293
  text: '不支持重试',
294
294
  type: 'notSupportRetry',
295
295
  })
296
296
  }
297
297
  })
298
298
 
299
299
 
300
300
  const reportSGM = ({status, text, type, requestSrc = imgSrc, resolveUrl = ''}) => {
301
301
  const { shopId, venderId } = global.info.queryInfo || {}
302
302
  sgmCustomReport({
303
303
  code: getSgmCustomCode(`${SgmCustomCode.IMAGE_LOAD}_${type}`),
304
304
  msg: {
305
305
  avifSupport,
306
306
  webpSupport,
307
307
  shopId,
308
308
  venderId,
309
309
  originSrc: src,
310
310
  requestSrc,
311
311
  resolveUrl,
312
312
  status,
313
313
  text
314
314
  },
315
315
  })
316
316
  }
317
317
  const imageErrorHandle = useCallback(
318
318
  (e) => {
319
319
  console.log(' ==============> 图片加载错误', e)
320
320
  if (!hasRetryRef.current) {
321
321
  hasRetryRef.current = true
322
322
  if(src){
323
323
  try{
324
324
  imageErrorRetry(requestSrcRef.current).then((result) => {
325
325
  const { status, ok, text, type, url } = result || {}
326
326
  if(ok){
327
327
  setImgSrc(url)
328
328
  setHasRetrySuccess(true)
329
329
  }else{
330
330
  errorSrc && setImgSrc(errorSrc)
331
331
  hideErrorImage && setImageErrState(true)
332
332
  typeof onError === 'function' && onError(e, src, props)
333
333
  reportSGM({status, text, type, requestSrc: requestSrcRef.current})
334
334
  }
335
335
  })
336
336
  }catch(e){
337
337
  console.error('LazyLoadImage imageErrorHandle() error:', e)
338
338
  errorSrc && setImgSrc(errorSrc)
339
339
  hideErrorImage && setImageErrState(true)
340
340
  typeof onError === 'function' && onError(e, src, props)
341
341
  }
342
342
  }
343
343
  }else{
344
344
  reportSGM({status: '', text: '渲染原始图片渲染异常', type: 'renderOriginImageError'})
345
345
  if(imgSrc.includes('blob:')){
346
346
  reportSGM({status: '', text: '渲染本地blob图片异常', type: 'renderBlobImageError'})
347
347
  }else{
348
348
  reportSGM({status: '', text: '渲染本地非blob图片异常', type: 'renderNoBlobImageError'})
349
349
  }
350
350
  }
351
351
  },
352
352
  [src, hasRetryRef.current],
353
353
  )
354
354
 
355
355
 
356
356
  const imageLoad = useCallback(
357
357
  (_src, event) => {
358
358
  setLoadSuccess(true)
359
359
  typeof onLoad === 'function' && onLoad(event, src, props)
360
360
  },
361
361
  [src],
362
362
  )
363
363
 
364
364
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
365
365
  const changeStyle = {}
366
366
  width && (changeStyle['width'] = width)
367
367
  height && (changeStyle['height'] = height)
368
368
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
369
369
  return changeStyle
370
370
  }
371
371
  useEffect(() => {
372
372
  setMeasureComplete(true)
373
373
  if (needShowHighVersion) return
374
374
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
375
375
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
376
376
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
377
377
  !componentShowStateRef.current && dealPageScrollInfo(res)
378
378
  })
379
379
  }, [])
380
380
 
381
381
  const dealPageScrollInfo = (res) => {
382
382
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
383
383
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
384
384
  if (measureRef.current) {
385
385
  const eleClientRect =
386
386
  measureRef.current.getBoundingClientRect()
387
387
  const getContainerHeightOffSetY =
388
388
  displayHeight * 1.5 + offSetY
389
389
  const eleOffsetTop = Math.ceil(eleClientRect.top)
390
390
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
391
391
  if (!componentShowStateRef.current) {
392
392
  if (getContainerHeightOffSetY > eleOffsetTop) {
393
393
  componentShowStateRef.current = true
394
394
  setComponentShowState(true)
395
395
  }
396
396
  }
397
397
  }
398
398
  }
399
399
  return (
400
400
  isH5AndJdShopView &&
401
401
  global?.config?.needImageLazy !== false &&
402
402
  !needShowHighVersion &&
403
403
  !isAppStowShop ? (
404
404
  <View
405
405
  ref={measureRef}
406
406
  className={classNames(
407
407
  imageStyle["d-app-lazy-image"],
408
408
  {
409
409
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
410
410
  },
411
411
  {
412
412
  [imageStyle["d-hide-image-error"]]: imageErrState,
413
413
  },
414
414
  {
415
415
  [imageStyle["d-load-completed"]]: loadSuccess,
416
416
  },
417
417
  {
418
418
  "d-imag-rendering-crisp-edges":
419
419
  !global.info.pageInfo.isVipShop && imagRenderingSet,
420
420
  },
421
421
  "J_html5ImageBg",
422
422
  className
423
423
  )}
424
424
  style={{
425
425
  ...style,
426
426
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
427
427
  }}
428
428
  {...otherOption}
429
429
  >
430
430
  {(componentShowState || lazyLoad === false) && (
431
431
  <img
432
432
  src={getQualityImage(
433
433
  imgSrc,
434
434
  global.info.pageInfo.isVipShop
435
435
  ? NetWorkTypeQuality["perfect"]
436
436
  : NetWorkTypeQuality[getNetWorkType]
437
437
  )}
438
438
  onLoad={imageLoad.bind(this, imgSrc)}
439
439
  onError={imageErrorHandle}
440
440
  />
441
441
  )}
442
442
  </View>
443
443
  ) : enableAvifOptimize ? (
444
444
  [
445
445
  measureComplete ? (
446
446
  <Image
447
447
  key={hasRetrySuccess? "realImageRetry": "realImage"}
448
448
  style={{
449
449
  ...style,
450
450
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
451
451
  }}
452
452
  className={classNames(
453
453
  imageStyle["d-lazy-image"],
454
454
  {
455
455
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
456
456
  },
457
457
  {
458
458
  [imageStyle["d-hide-image-error"]]: imageErrState,
459
459
  },
460
460
  {
461
461
  [imageStyle["d-load-completed"]]: loadSuccess,
462
462
  },
463
463
  {
464
464
  "d-imag-rendering-crisp-edges": imagRenderingSet,
465
465
  },
466
466
  className
467
467
  )}
468
468
  src={hasRetrySuccess? imgSrc: getRequestSrc(imgSrc)}
469
469
  lazyLoad={isChartH5 ? false : lazyLoad}
470
470
  onError={imageErrorHandle}
471
471
  onLoad={imageLoad.bind(this, imgSrc)}
472
472
  {...otherOption}
473
473
  />
474
474
  ) : (
475
475
  <Image
476
476
  key={"defaultImage"}
477
477
  style={{
478
478
  ...style,
479
479
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
480
480
  }}
481
481
  className={classNames(
482
482
  imageStyle["d-lazy-image"],
483
483
  {
484
484
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
485
485
  },
486
486
  {
487
487
  [imageStyle["d-hide-image-error"]]: imageErrState,
488
488
  },
489
489
  {
490
490
  [imageStyle["d-load-completed"]]: loadSuccess,
491
491
  },
492
492
  {
493
493
  "d-imag-rendering-crisp-edges": imagRenderingSet,
494
494
  },
495
495
  className
496
496
  )}
497
497
  src={isSkuImage ? DEFAULT_SKU_SRC : DEFAULT_SRC}
498
498
  />
499
499
  ),
500
500
  loadSuccess ? null : <View key={"measureRef"} ref={measureRef}></View>,
501
501
  ]
502
502
  ) : (
503
503
  <Image
504
504
  style={{
505
505
  ...style,
506
506
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
507
507
  }}
508
508
  className={classNames(
509
509
  imageStyle["d-lazy-image"],
510
510
  {
511
511
  [imageStyle["d-lazy-sku-image"]]: isSkuImage,
512
512
  },
513
513
  {
514
514
  [imageStyle["d-hide-image-error"]]: imageErrState,
515
515
  },
516
516
  {
517
517
  [imageStyle["d-load-completed"]]: loadSuccess,
518
518
  },
519
519
  {
520
520
  "d-imag-rendering-crisp-edges": imagRenderingSet,
521
521
  },
522
522
  className
523
523
  )}
524
524
  src={getQualityImage(imgSrc, NetWorkTypeQuality[getNetWorkType])}
525
525
  lazyLoad={isChartH5 ? false : lazyLoad}
526
526
  onError={imageErrorHandle}
527
527
  onLoad={imageLoad.bind(this, imgSrc)}
528
528
  {...otherOption}
529
529
  />
530
530
  )
531
531
  )
532
532
  lazyLoad: true,
533
533
  isSkuImage: false,
534
534
  hideErrorImage: false,
535
535
  imagRenderingSet: true,
536
536
  src: null,
537
537
  style: null,
538
538
  width: null,
539
539
  height: null,
540
540
  backgroundColor: null,
541
541
  className: null,
542
542
  errorSrc: null,
543
543
  onLoad: null,
544
544
  onError: null,
@@ -0,0 +1,17 @@
1
+
2
+ .d-mobile-header-layout {
3
+ position: relative;
4
+ z-index: 12;
5
+ .d-mobile-common-tip,
6
+ .d-mobile-common-header {
7
+ position: relative;
8
+ }
9
+ }
10
+ :global {
11
+ .d-mobile-header-sticky {
12
+ position: fixed;
13
+ top: 0;
14
+ width: 100%;
15
+ z-index: 999;
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ import React, {useEffect, useRef} from 'react'
2
  const { title, openAppParams, style, hasCommonHeader = true, hasDownloadTips = true, headerParams } = props
1
3
  const headerRef:any = useRef(null)
2
4
  useEffect(() => {
3
5
  hasCommonHeader && initCommonHeader()
4
6
  hasDownloadTips && initDownloadAppLayerConfigData()
5
7
  }, [])
6
8
  const isScrolledToTop = () => {
7
9
  return window.scrollY !== undefined ? window.scrollY === 0 :
8
10
  document.documentElement.scrollTop === 0 || document.body.scrollTop === 0;
9
11
  }
10
12
  const scrollEventFunc = () => {
11
13
  if(!headerRef.current) return
12
14
  const stickyTop = headerRef.current?.getBoundingClientRect()?.top || 0;
13
15
  if(Math.trunc(stickyTop) <= 0 && !isScrolledToTop()) {
14
16
  console.log('scroll 添加class',Math.trunc(stickyTop), isScrolledToTop())
15
17
  headerRef.current.classList.add('d-mobile-header-sticky');
16
18
  }else {
17
19
  console.log('scroll 移除class',Math.trunc(stickyTop), isScrolledToTop())
18
20
  headerRef.current.classList.remove('d-mobile-header-sticky');
19
21
  }
20
22
  }
21
23
  useEffect(() => {
22
24
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL,() => {
23
25
  scrollEventFunc()
24
26
  })
25
27
  },[])
26
28
  const initCommonHeader = () => {
27
29
  if (window?.MCommonHeaderBottom) {
28
30
  const mchb = new MCommonHeaderBottom()
29
31
  const headerArg = {
30
32
  moduleName: 'shop',
31
33
  hrederId: 'm_common_header',
32
34
  title,
33
35
  stype: 1,
34
36
  onClickJdkey: function () {
35
37
  console.log('==>m_common_header jdkey click.')
36
38
  },
37
39
  ...headerParams
38
40
  }
39
41
  mchb.header(headerArg)
40
42
  }
41
43
  }
42
44
  const initDownloadAppLayerConfigData = () => {
43
45
  const getEle = document.getElementById('m_common_tip')
44
46
  getEle &&
45
47
  window.$ &&
46
48
  window.$.downloadAppLayerConfigData &&
47
49
  window.$.downloadAppLayerConfigData({
48
50
  tipId: 'm_common_tip',
49
51
  M_sourceFrom: 'jshop',
50
52
  bottom: 74,
51
53
  onClickTipX: () => {
52
54
  Taro.eventCenter.trigger(
53
55
  TaroEventType.DOWN_LOAD_APP_CLOSE_CHANGE,
54
56
  true,
55
57
  )
56
58
  },
57
59
  downloadAppPlugIn: {
58
60
  M_sourceFrom: 'jshop',
59
61
  openAppBtnId: 'download_openapp',
60
62
  downAppURl: '//conecli.com/downloadApp/download.html?channel=jd-m',
61
63
  inteneUrl: 'openapp.jdmobile://virtual?',
62
64
  inteneUrlParams: {
63
65
  category: 'jump',
64
66
  des: 'jshopMain',
65
67
  shopId: `${global.info.queryInfo.shopId || ''}`,
66
68
  venderId: `${global.info.queryInfo.venderId || ''}`,
67
69
  sourceType: global.info.queryInfo?.sourceType || 'M-H5',
68
70
  sourceValue: global.info.queryInfo?.sourceValue || 'Mshop',
69
71
  ...openAppParams,
70
72
  },
71
73
  },
72
74
  })
73
75
  }
74
76
  return !isWxMiniH5View && !isJdApp ? (
75
77
  <View
76
78
  className={mobileCommonHeaderStyle['d-mobile-header-layout']}
77
79
  style={style}
78
80
  ref={headerRef}
79
81
  >
80
82
  <View
81
83
  id="m_common_tip"
82
84
  className={mobileCommonHeaderStyle['d-mobile-common-tip']}
83
85
  />
84
86
  {hasCommonHeader && (
85
87
  <View
86
88
  id="m_common_header"
87
89
  className={mobileCommonHeaderStyle['d-mobile-common-header']}
88
90
  />
89
91
  )}
90
92
  </View>
91
93
  ) : null
92
94
  title: '店铺',
93
95
  openAppParams: {},
@@ -1 +1 @@
1
- import { NETWORK_DATA_TYPE } from '../../../common/const'
2
1
  [NETWORK_DATA_TYPE.NO_NET_WORK]: '网络连接已断开',
3
2
  [NETWORK_DATA_TYPE.DATA_ERROR]: '数据加载失败',
4
3
  [NETWORK_DATA_TYPE.NO_DATA]: '你访问的内容飞到太空了',
5
4
  [NETWORK_DATA_TYPE.RISK]: '活动太火爆',
6
5
  [NETWORK_DATA_TYPE.NO_NET_WORK]: '请检查您的网络设置',
7
6
  [NETWORK_DATA_TYPE.DATA_ERROR]: '请稍后重试',
8
7
  [NETWORK_DATA_TYPE.NO_DATA]: '',
9
8
  [NETWORK_DATA_TYPE.RISK]: '页面加载失败,请稍后再试',
10
9
  NETWORK_DATA_TYPE.NO_NET_WORK,
11
10
  NETWORK_DATA_TYPE.DATA_ERROR,
12
11
  NETWORK_DATA_TYPE.NO_DATA,
13
12
  NETWORK_DATA_TYPE.RISK,
14
13
  No_Data_Bmall:'no-data-bmall',
14
+ import { NETWORK_DATA_TYPE } from '../../../common/const'
15
15
  [NETWORK_DATA_TYPE.NO_NET_WORK]: '网络连接已断开',
16
16
  [NETWORK_DATA_TYPE.DATA_ERROR]: '数据加载失败',
17
17
  [NETWORK_DATA_TYPE.NO_DATA]: '你访问的内容飞到太空了',
18
18
  [NETWORK_DATA_TYPE.RISK]: '活动太火爆',
19
19
  [NETWORK_DATA_TYPE.NO_NET_WORK]: '请检查您的网络设置',
20
20
  [NETWORK_DATA_TYPE.DATA_ERROR]: '请稍后重试',
21
21
  [NETWORK_DATA_TYPE.NO_DATA]: '',
22
22
  [NETWORK_DATA_TYPE.RISK]: '页面加载失败,请稍后再试',
23
23
  NETWORK_DATA_TYPE.NO_NET_WORK,
24
24
  NETWORK_DATA_TYPE.DATA_ERROR,
25
25
  NETWORK_DATA_TYPE.NO_DATA,
26
26
  NETWORK_DATA_TYPE.RISK,
27
27
  No_Data_Bmall:'no-data-bmall',