@conecli/cone-render 0.9.1-shop2.7 → 0.9.1-shop2.9

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 (62) 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/sgmCustomCode.ts +1 -0
  9. package/dist/common/token/token.ts +1 -1
  10. package/dist/common/wxappApi.jd.ts +1 -0
  11. package/dist/components/ErrorBoundary.tsx +1 -1
  12. package/dist/components/base/CountDown/index.tsx +1 -1
  13. package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
  14. package/dist/components/base/CustomScrollView/index.module.scss +7 -0
  15. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  16. package/dist/components/base/Dialog/index.module.scss +5 -0
  17. package/dist/components/base/Dialog/index.tsx +1 -1
  18. package/dist/components/base/ExposureSmart/index.tsx +1 -1
  19. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  20. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  21. package/dist/components/floorItem.jd.tsx +1 -1
  22. package/dist/components/floorItem.weapp.tsx +1 -1
  23. package/dist/components/remoteFloorItem.tsx +1 -1
  24. package/dist/interface/common.ts +1 -1
  25. package/dist/interface/component.ts +1 -1
  26. package/dist/interface/jumpEventReport.ts +1 -1
  27. package/dist/interface/service.ts +1 -1
  28. package/dist/interface/utils.ts +1 -1
  29. package/dist/jumpEventReport/base.ts +1 -1
  30. package/dist/jumpEventReport/const.ts +1 -1
  31. package/dist/jumpEventReport/createReportFloorData.ts +1 -1
  32. package/dist/jumpEventReport/index.h5.ts +1 -1
  33. package/dist/jumpEventReport/index.jd.ts +1 -1
  34. package/dist/jumpEventReport/index.weapp.ts +1 -1
  35. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  36. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  37. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  38. package/dist/jumpEventReport/web/report.ts +1 -1
  39. package/dist/jumpEventReport/web.base.ts +1 -1
  40. package/dist/jumpEventReport/web.jd.ts +1 -1
  41. package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
  42. package/dist/jumpEventReport/web.tjapp.ts +1 -0
  43. package/dist/jumpEventReport/web.tjm.ts +1 -0
  44. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  45. package/dist/open/api/environment.ts +1 -1
  46. package/dist/open/api/jump copy.ts +1 -1
  47. package/dist/open/api/shopMember.ts +1 -1
  48. package/dist/open/api/track.ts +1 -1
  49. package/dist/open/api/util.ts +1 -1
  50. package/dist/sass/app.h5.scss +39 -3
  51. package/dist/service/requestServer.ts +1 -1
  52. package/dist/utils/connectNativeJsBridge.ts +1 -1
  53. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  54. package/dist/utils/draExceptionAndProfile.ts +1 -1
  55. package/dist/utils/h5Utils.ts +1 -1
  56. package/dist/utils/index.h5.ts +1 -1
  57. package/dist/utils/index.ts +1 -1
  58. package/dist/utils/index.weapp.ts +1 -1
  59. package/dist/utils/jm-common.js +1 -1
  60. package/dist/utils/sgmCodeUtils.ts +1 -0
  61. package/dist/utils/utils.ts +1 -1
  62. package/package.json +1 -1
@@ -1 +1 @@
1
- import Taro, { useRouter } from "@tarojs/taro";
2
1
  SECTION_HOME_TAB_TYPE,
3
2
  SECTION_HOME_TAB_NAME_TYPE,
4
3
  TaroEventType,
5
4
  latestFromNativeMsgStorage,
6
5
  nativePageRegisterMessage,
7
6
  Message_Type,
8
7
  getNativePageScrollRes,
9
8
  const {
10
9
  children,
11
10
  containerId,
12
11
  type,
13
12
  placeholder,
14
13
  height,
15
14
  floorData = {},
16
15
  sectionType,
17
16
  lazyNodeClassName,
18
17
  } = props;
19
18
  const getRouterInfo = useRouter();
20
19
  const getQueryData = getRouterInfo?.params || {};
21
20
  const [componentShowState, setComponentShowState] = useState(false);
22
21
  const [componentRenderShowState, setComponentRenderShowState] =
23
22
  useState(false);
24
23
  const componentLazyRef = useRef<HTMLElement | null>(null);
25
24
  const componentShowStateRef = useRef(false);
26
25
  const needShowHighVersion =
27
26
  isH5AndJdShopViewH5Scroll &&
28
27
  !(
29
28
  global.info.queryInfo?.downgraded &&
30
29
  global.info.queryInfo.downgraded === "true"
31
30
  );
32
31
  const rootDom =
33
32
  isH5AndJdShopView && needShowHighVersion
34
33
  ? null
35
34
  : document.querySelector("#J_shopHomeRoot");
36
35
  const { ref, inView } = useInView({
37
36
  threshold: 0,
38
37
  triggerOnce: true,
39
38
  root: rootDom,
40
39
  rootMargin: `0px 0px ${window.innerHeight}px 0px`,
41
40
  });
42
41
  useEffect(() => {
43
42
  if(needShowHighVersion || !isH5AndJdShopView) return
44
43
  if (type === LazyType.FLOOR) {
45
44
  const latestRes =
46
45
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {};
47
46
  !componentShowStateRef.current && dealPageScrollInfo(latestRes);
48
47
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
49
48
  !componentShowStateRef.current && dealPageScrollInfo(res);
50
49
  });
51
50
  }
52
51
  }, []);
53
52
  useEffect(() => {
54
53
  if (
55
54
  (!needShowHighVersion && componentShowState === true) ||
56
55
  (needShowHighVersion && inView && isH5AndJdShopView)
57
56
  ) {
58
57
  console.log(
59
58
  ">>>>>>>>>>>>>>>>>>> 楼层【id=" + containerId + "】已经渲染!"
60
59
  );
61
60
  const modularPackResultObj = formatPackResult(
62
61
  floorData?.floorExtInfo?.modularPackResult
63
62
  );
64
63
  const bundleUrl = getBundleUrl(modularPackResultObj);
65
64
  if (bundleUrl) {
66
65
  nativePageRegisterMessage(Message_Type.NATIVE_INJECT_JS_FILE, {
67
66
  data: {
68
67
  bundleUrl: [bundleUrl],
69
68
  },
70
69
  });
71
70
  }
72
71
  }
73
72
  }, [componentShowState, inView]);
74
73
 
75
74
  const dealPageScrollInfo = (res) => {
76
75
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {};
77
76
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') {
78
77
  const shopId = floorData?.floorExtInfo?.shopId
79
78
  if(!lazyLayoutLoadErrorShopId[`${shopId}`]) {
80
79
  const opt = {
81
80
  msg: `店铺楼层懒加载失败。楼层顺序-floorIdx: ${floorData?.floorIdx}。`,
82
81
  uid: floorData?.uid,
83
82
  floorIdx: floorData?.floorIdx,
84
83
  shopId: shopId,
85
84
  moduleId: floorData?.moduleId,
86
85
  moduleName: floorData?.moduleName,
87
86
  middleTemplateId: floorData?.middleTemplateId,
88
87
  modularPackResult: typeof floorData?.floorExtInfo?.modularPackResult == 'string' ? JSON.parse(floorData?.floorExtInfo?.modularPackResult) : floorData?.floorExtInfo?.modularPackResult,
89
88
  }
90
89
  sgmCustomReport({
91
90
  code: 'lazyLayoutLoadError',
92
91
  msg: opt,
93
92
  })
94
93
  lazyLayoutLoadErrorShopId[`${shopId}`] = true
95
94
  }
96
95
  return
97
96
  }
98
97
  if (componentLazyRef.current) {
99
98
  const eleClientRect = componentLazyRef.current.getBoundingClientRect();
100
99
  const getContainerHeightOffSetY = displayHeight + offSetY;
101
100
  const eleOffsetTop = Math.ceil(eleClientRect.top);
102
101
  const eleOffsetHeight = Math.ceil(eleClientRect.height);
103
102
  const eleOffsetTopHeight = eleOffsetTop + eleOffsetHeight;
104
103
  if (!componentShowStateRef.current) {
105
104
  if (getContainerHeightOffSetY > eleOffsetTop) {
106
105
  componentShowStateRef.current = true;
107
106
  setComponentShowState(true);
108
107
  Taro.nextTick(() => {
109
108
  setComponentRenderShowState(true);
110
109
  });
111
110
  }
112
111
  }
113
112
  }
114
113
  };
115
114
  return isH5AndJdShopView && !needShowHighVersion ? (
116
115
  <div
117
116
  id={`${containerId}_lazy`}
118
117
  ref={componentLazyRef}
119
118
  className={classNames(
120
119
  lazyLayoutLoadStyle["d-app-floor-lazy-layout-load"],
121
120
  "d-app-floor-lazy-load"
122
121
  )}
123
122
  style={{
124
123
  minHeight: `${componentRenderShowState ? "auto" : height + "px"}`,
125
124
  backgroundColor: componentRenderShowState ? "transparent" : "#ffffff",
126
125
  }}
127
126
  >
128
127
  {componentShowState ? children : placeholder}
129
128
  </div>
130
129
  ) : (
131
130
  <div
132
131
  id={`${containerId}_lazy`}
133
132
  className={classNames(
134
133
  lazyLayoutLoadStyle["d-mobile-floor-lazy-layout-load"],
135
134
  "d-mobile-floor-lazy-load",
136
135
  lazyNodeClassName,
137
136
  )}
138
137
  ref={ref}
139
138
  style={{
140
139
  minHeight: `${inView ? "auto" : height + "px"}`,
141
140
  backgroundColor: inView ? "transparent" : "#ffffff",
142
141
  }}
143
142
  >
144
143
  {inView ? children : placeholder}
145
144
  </div>
146
145
  );
147
146
  sectionType:
148
147
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
149
148
  type: LazyType.FLOOR,
150
149
  children: null,
151
150
  placeholder: null,
152
151
  height: 200,
153
152
  className: "",
154
153
  lazyNodeClassName: "",
154
+ import Taro, { useRouter } from "@tarojs/taro";
155
155
  SECTION_HOME_TAB_TYPE,
156
156
  SECTION_HOME_TAB_NAME_TYPE,
157
157
  TaroEventType,
158
158
  latestFromNativeMsgStorage,
159
159
  nativePageRegisterMessage,
160
160
  Message_Type,
161
161
  getNativePageScrollRes,
162
162
  const {
163
163
  children,
164
164
  containerId,
165
165
  type,
166
166
  placeholder,
167
167
  height,
168
168
  floorData = {},
169
169
  sectionType,
170
170
  lazyNodeClassName,
171
171
  } = props
172
172
  const getRouterInfo = useRouter()
173
173
  const getQueryData = getRouterInfo?.params || {}
174
174
  const [componentShowState, setComponentShowState] = useState(false)
175
175
  const [componentRenderShowState, setComponentRenderShowState] =
176
176
  useState(false)
177
177
  const componentLazyRef = useRef<HTMLElement | null>(null)
178
178
  const componentShowStateRef = useRef(false)
179
179
  const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
180
180
  const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector('#J_shopHomeRoot')
181
181
  const { ref, inView } = useInView({
182
182
  threshold: 0,
183
183
  triggerOnce: true,
184
184
  root: rootDom,
185
185
  rootMargin: `0px 0px ${window.innerHeight}px 0px`,
186
186
  })
187
187
  useEffect(() => {
188
188
  if(needShowHighVersion || !isH5AndJdShopView) return
189
189
  if (type === LazyType.FLOOR) {
190
190
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
191
191
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
192
192
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
193
193
  !componentShowStateRef.current && dealPageScrollInfo(res)
194
194
  })
195
195
  }
196
196
  }, [])
197
197
  useEffect(() => {
198
198
  if((!needShowHighVersion && componentShowState === true) ||
199
199
  (needShowHighVersion && inView && isH5AndJdShopView)
200
200
  ) {
201
201
  console.log('>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!')
202
202
  const modularPackResult = floorData?.floorExtInfo?.modularPackResult
203
203
  const modularPackResultObj = typeof modularPackResult === 'string' ? JSON.parse(modularPackResult) : modularPackResult
204
204
  if (modularPackResultObj && modularPackResultObj.bundleUrl) {
205
205
  const { bundleUrl } = modularPackResultObj
206
206
  nativePageRegisterMessage(
207
207
  Message_Type.NATIVE_INJECT_JS_FILE,
208
208
  {
209
209
  data: {
210
210
  "bundleUrl": [bundleUrl]
211
211
  },
212
212
  },
213
213
  )
214
214
  }
215
215
  }
216
216
  }, [componentShowState,inView])
217
217
 
218
218
  const dealPageScrollInfo = (res) => {
219
219
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {};
220
220
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') {
221
221
  const shopId = floorData?.floorExtInfo?.shopId
222
222
  if(!lazyLayoutLoadErrorShopId[`${shopId}`]) {
223
223
  const opt = {
224
224
  msg: `店铺楼层懒加载失败。楼层顺序-floorIdx: ${floorData?.floorIdx}。`,
225
225
  uid: floorData?.uid,
226
226
  floorIdx: floorData?.floorIdx,
227
227
  shopId: shopId,
228
228
  moduleId: floorData?.moduleId,
229
229
  moduleName: floorData?.moduleName,
230
230
  middleTemplateId: floorData?.middleTemplateId,
231
231
  modularPackResult: typeof floorData?.floorExtInfo?.modularPackResult == 'string' ? JSON.parse(floorData?.floorExtInfo?.modularPackResult) : floorData?.floorExtInfo?.modularPackResult,
232
232
  }
233
233
  sgmCustomReport({
234
234
  code: 'lazyLayoutLoadError',
235
235
  msg: opt,
236
236
  })
237
237
  lazyLayoutLoadErrorShopId[`${shopId}`] = true
238
238
  }
239
239
  return
240
240
  }
241
241
  if (componentLazyRef.current) {
242
242
  const eleClientRect =
243
243
  componentLazyRef.current.getBoundingClientRect()
244
244
  const getContainerHeightOffSetY = displayHeight + offSetY
245
245
  const eleOffsetTop = Math.ceil(eleClientRect.top)
246
246
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
247
247
  const eleOffsetTopHeight = eleOffsetTop + eleOffsetHeight
248
248
  if (!componentShowStateRef.current) {
249
249
  if (getContainerHeightOffSetY > eleOffsetTop) {
250
250
  componentShowStateRef.current = true
251
251
  setComponentShowState(true)
252
252
  Taro.nextTick(() => {
253
253
  setComponentRenderShowState(true)
254
254
  })
255
255
  }
256
256
  }
257
257
  }
258
258
  }
259
259
  return isH5AndJdShopView && !needShowHighVersion ? (
260
260
  <div
261
261
  id={`${containerId}_lazy`}
262
262
  ref={componentLazyRef}
263
263
  className={classNames(
264
264
  lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
265
265
  'd-app-floor-lazy-load',
266
266
  )}
267
267
  style={{
268
268
  minHeight: `${
269
269
  componentRenderShowState ? 'auto' : height + 'px'
270
270
  }`,
271
271
  backgroundColor: componentRenderShowState
272
272
  ? 'transparent'
273
273
  : '#ffffff',
274
274
  }}
275
275
  >
276
276
  {componentShowState ? children : placeholder}
277
277
  </div>
278
278
  ) : (
279
279
  <div
280
280
  id={`${containerId}_lazy`}
281
281
  className={classNames(
282
282
  lazyLayoutLoadStyle["d-mobile-floor-lazy-layout-load"],
283
283
  "d-mobile-floor-lazy-load",
284
284
  lazyNodeClassName,
285
285
  )}
286
286
  ref={ref}
287
287
  style={{
288
288
  minHeight: `${inView ? 'auto' : height + 'px'}`,
289
289
  backgroundColor: inView ? 'transparent' : '#ffffff',
290
290
  }}
291
291
  >
292
292
  {inView ? children : placeholder}
293
293
  </div>
294
294
  );
295
295
  sectionType:
296
296
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
297
297
  type: LazyType.FLOOR,
298
298
  children: null,
299
299
  placeholder: null,
300
300
  height: 200,
301
301
  className: '',
302
302
  lazyNodeClassName: '',
@@ -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
  getNativePageScrollRes,
9
8
  latestFromNativeMsgStorage,
10
9
  const {
11
10
  src,
12
11
  lazyLoad,
13
12
  imagRenderingSet,
14
13
  width,
15
14
  height,
16
15
  className,
17
16
  isSkuImage,
18
17
  hideErrorImage,
19
18
  style,
20
19
  backgroundColor,
21
20
  errorSrc,
22
21
  onLoad,
23
22
  onError,
24
23
  ...otherOption
25
24
  } = props
26
25
  getNetWorkType === NetWorkTypeQuality.default &&
27
26
  (getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
28
27
  const [loadSuccess, setLoadSuccess] = useState(false)
29
28
  const [imageErrState, setImageErrState] = useState(false)
30
29
  const [componentShowState, setComponentShowState] = useState(false)
31
30
  const [imgSrc, setImgSrc] = useState(src)
32
31
  const componentLazyRef = useRef<HTMLElement | null>(null)
33
32
  const componentShowStateRef = useRef(false)
34
33
  const needShowHighVersion =
35
34
  isH5AndJdShopViewH5Scroll &&
36
35
  !(
37
36
  global.info.queryInfo?.downgraded &&
38
37
  global.info.queryInfo.downgraded === 'true'
39
38
  )
40
39
  const imageError = useCallback(
41
40
  (e) => {
42
41
  console.log('图片加载错误', e)
43
42
  errorSrc && setImgSrc(errorSrc)
44
43
  hideErrorImage && setImageErrState(true)
45
44
  typeof onError === 'function' && onError(e, src, props)
46
45
  },
47
46
  [src],
48
47
  )
49
48
 
50
49
  const imageLoad = useCallback(
51
50
  (_src, event) => {
52
51
  setLoadSuccess(true)
53
52
  typeof onLoad === 'function' && onLoad(event, src, props)
54
53
  },
55
54
  [src],
56
55
  )
57
56
 
58
57
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
59
58
  const changeStyle = {}
60
59
  width && (changeStyle['width'] = width)
61
60
  height && (changeStyle['height'] = height)
62
61
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
63
62
  return changeStyle
64
63
  }
65
64
  useEffect(() => {
66
65
  if (needShowHighVersion) return
67
66
  const latestRes =
68
67
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
69
68
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
70
69
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
71
70
  !componentShowStateRef.current && dealPageScrollInfo(res)
72
71
  })
73
72
  }, [])
74
73
 
75
74
  const dealPageScrollInfo = (res) => {
76
75
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
77
76
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
78
77
  return
79
78
  if (componentLazyRef.current) {
80
79
  const eleClientRect = componentLazyRef.current.getBoundingClientRect()
81
80
  const getContainerHeightOffSetY = displayHeight * 1.5 + offSetY
82
81
  const eleOffsetTop = Math.ceil(eleClientRect.top)
83
82
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
84
83
  if (!componentShowStateRef.current) {
85
84
  if (getContainerHeightOffSetY > eleOffsetTop) {
86
85
  componentShowStateRef.current = true
87
86
  setComponentShowState(true)
88
87
  }
89
88
  }
90
89
  }
91
90
  }
92
91
  return (
93
92
  (isH5AndJdShopView && global?.config?.needImageLazy !== false && !needShowHighVersion && !isAppStowShop) ? (
94
93
  <View
95
94
  ref={ componentLazyRef }
96
95
  className={classNames(
97
96
  imageStyle['d-app-lazy-image'],
98
97
  {
99
98
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
100
99
  },
101
100
  {
102
101
  [imageStyle['d-hide-image-error']]: imageErrState,
103
102
  },
104
103
  {
105
104
  [imageStyle['d-load-completed']]: loadSuccess,
106
105
  },
107
106
  {
108
107
  'd-imag-rendering-crisp-edges':
109
108
  !taroJdBaseInfo.info.pageInfo.isVipShop &&
110
109
  imagRenderingSet,
111
110
  },
112
111
  'J_html5ImageBg',
113
112
  className,
114
113
  )}
115
114
  style={{
116
115
  ...style,
117
116
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
118
117
  }}
119
118
  {...otherOption}
120
119
  >
121
120
  {(componentShowState || lazyLoad === false) && <img
122
121
  src={getQualityImage(
123
122
  imgSrc,
124
123
  taroJdBaseInfo.info.pageInfo.isVipShop
125
124
  ? NetWorkTypeQuality['perfect']
126
125
  : NetWorkTypeQuality[getNetWorkType],
127
126
  )}
128
127
  onLoad={imageLoad.bind(this, imgSrc)}
129
128
  onError={imageError}
130
129
  />}
131
130
  </View>
132
131
  ) : (
133
132
  <Image
134
133
  style={{
135
134
  ...style,
136
135
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
137
136
  }}
138
137
  className={classNames(
139
138
  imageStyle['d-lazy-image'],
140
139
  {
141
140
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
142
141
  },
143
142
  {
144
143
  [imageStyle['d-hide-image-error']]: imageErrState,
145
144
  },
146
145
  {
147
146
  [imageStyle['d-load-completed']]: loadSuccess,
148
147
  },
149
148
  {
150
149
  'd-imag-rendering-crisp-edges': imagRenderingSet,
151
150
  },
152
151
  className,
153
152
  )}
154
153
  src={getQualityImage(
155
154
  imgSrc,
156
155
  NetWorkTypeQuality[getNetWorkType],
157
156
  )}
158
157
  lazyLoad={isChartH5 ? false : lazyLoad}
159
158
  onError={imageError}
160
159
  onLoad={imageLoad.bind(this, imgSrc)}
161
160
  {...otherOption}
162
161
  />
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
  getQualityImage,
180
180
  isH5AndJdShopView,
181
181
  isJdApp,
182
182
  isChartH5,
183
183
  isH5AndJdShopViewH5Scroll,
184
184
  isAppStowShop
185
185
  getNativePageScrollRes,
186
186
  latestFromNativeMsgStorage,
187
187
  const {
188
188
  src,
189
189
  lazyLoad,
190
190
  imagRenderingSet,
191
191
  width,
192
192
  height,
193
193
  className,
194
194
  isSkuImage,
195
195
  hideErrorImage,
196
196
  style,
197
197
  backgroundColor,
198
198
  errorSrc,
199
199
  onLoad,
200
200
  onError,
201
201
  ...otherOption
202
202
  } = props
203
203
  getNetWorkType === NetWorkTypeQuality.default &&
204
204
  (getNetWorkType = taroJdBaseInfo.info.sysInfo.netWorkType)
205
205
  const [loadSuccess, setLoadSuccess] = useState(false)
206
206
  const [imageErrState, setImageErrState] = useState(false)
207
207
  const [componentShowState, setComponentShowState] = useState(false)
208
208
  const [imgSrc, setImgSrc] = useState(src)
209
209
  const componentLazyRef = useRef<HTMLElement | null>(null)
210
210
  const componentShowStateRef = useRef(false)
211
211
  const needShowHighVersion =
212
212
  isH5AndJdShopViewH5Scroll &&
213
213
  !(
214
214
  global.info.queryInfo?.downgraded &&
215
215
  global.info.queryInfo.downgraded === 'true'
216
216
  )
217
217
  const imageError = useCallback(
218
218
  (e) => {
219
219
  console.log('图片加载错误', e)
220
220
  errorSrc && setImgSrc(errorSrc)
221
221
  hideErrorImage && setImageErrState(true)
222
222
  typeof onError === 'function' && onError(e, src, props)
223
223
  },
224
224
  [src],
225
225
  )
226
226
 
227
227
  const imageLoad = useCallback(
228
228
  (_src, event) => {
229
229
  setLoadSuccess(true)
230
230
  typeof onLoad === 'function' && onLoad(event, src, props)
231
231
  },
232
232
  [src],
233
233
  )
234
234
 
235
235
  const changeStyleIncludeWidthAndHeightAndBgColor = () => {
236
236
  const changeStyle = {}
237
237
  width && (changeStyle['width'] = width)
238
238
  height && (changeStyle['height'] = height)
239
239
  backgroundColor && (changeStyle['backgroundColor'] = backgroundColor)
240
240
  return changeStyle
241
241
  }
242
242
  useEffect(() => {
243
243
  if(needShowHighVersion) return
244
244
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
245
245
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
246
246
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
247
247
  !componentShowStateRef.current && dealPageScrollInfo(res)
248
248
  })
249
249
  }, [])
250
250
 
251
251
  const dealPageScrollInfo = (res) => {
252
252
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
253
253
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
254
254
  if (componentLazyRef.current) {
255
255
  const eleClientRect =
256
256
  componentLazyRef.current.getBoundingClientRect()
257
257
  const getContainerHeightOffSetY =
258
258
  displayHeight * 1.5 + offSetY
259
259
  const eleOffsetTop = Math.ceil(eleClientRect.top)
260
260
  const eleOffsetHeight = Math.ceil(eleClientRect.height)
261
261
  if (!componentShowStateRef.current) {
262
262
  if (getContainerHeightOffSetY > eleOffsetTop) {
263
263
  componentShowStateRef.current = true
264
264
  setComponentShowState(true)
265
265
  }
266
266
  }
267
267
  }
268
268
  }
269
269
  return (
270
270
  (isH5AndJdShopView && global?.config?.needImageLazy !== false && !needShowHighVersion && !isAppStowShop) ? (
271
271
  <View
272
272
  ref={ componentLazyRef }
273
273
  className={classNames(
274
274
  imageStyle['d-app-lazy-image'],
275
275
  {
276
276
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
277
277
  },
278
278
  {
279
279
  [imageStyle['d-hide-image-error']]: imageErrState,
280
280
  },
281
281
  {
282
282
  [imageStyle['d-load-completed']]: loadSuccess,
283
283
  },
284
284
  {
285
285
  'd-imag-rendering-crisp-edges':
286
286
  !taroJdBaseInfo.info.pageInfo.isVipShop &&
287
287
  imagRenderingSet,
288
288
  },
289
289
  'J_html5ImageBg',
290
290
  className,
291
291
  )}
292
292
  style={{
293
293
  ...style,
294
294
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
295
295
  }}
296
296
  {...otherOption}
297
297
  >
298
298
  {(componentShowState || lazyLoad === false) && <img
299
299
  src={getQualityImage(
300
300
  imgSrc,
301
301
  taroJdBaseInfo.info.pageInfo.isVipShop
302
302
  ? NetWorkTypeQuality['perfect']
303
303
  : NetWorkTypeQuality[getNetWorkType],
304
304
  )}
305
305
  onLoad={imageLoad.bind(this, imgSrc)}
306
306
  onError={imageError}
307
307
  />}
308
308
  </View>
309
309
  ) : (
310
310
  <Image
311
311
  style={{
312
312
  ...style,
313
313
  ...changeStyleIncludeWidthAndHeightAndBgColor(),
314
314
  }}
315
315
  className={classNames(
316
316
  imageStyle['d-lazy-image'],
317
317
  {
318
318
  [imageStyle['d-lazy-sku-image']]: isSkuImage,
319
319
  },
320
320
  {
321
321
  [imageStyle['d-hide-image-error']]: imageErrState,
322
322
  },
323
323
  {
324
324
  [imageStyle['d-load-completed']]: loadSuccess,
325
325
  },
326
326
  {
327
327
  'd-imag-rendering-crisp-edges': imagRenderingSet,
328
328
  },
329
329
  className,
330
330
  )}
331
331
  src={getQualityImage(
332
332
  imgSrc,
333
333
  NetWorkTypeQuality[getNetWorkType],
334
334
  )}
335
335
  lazyLoad={isChartH5 ? false : lazyLoad}
336
336
  onError={imageError}
337
337
  onLoad={imageLoad.bind(this, imgSrc)}
338
338
  {...otherOption}
339
339
  />
340
340
  )
341
341
  )
342
342
  lazyLoad: true,
343
343
  isSkuImage: false,
344
344
  hideErrorImage: false,
345
345
  imagRenderingSet: true,
346
346
  src: null,
347
347
  style: null,
348
348
  width: null,
349
349
  height: null,
350
350
  backgroundColor: null,
351
351
  className: null,
352
352
  errorSrc: null,
353
353
  onLoad: null,
354
354
  onError: null,
@@ -1 +1 @@
1
- import { ComponentInterFace } from '../interface/component'
2
1
  const { floorData, builtInComponents = {} } = props
3
2
  const floorModuleType = floorData?.floorExtInfo?.moduleFlag
4
3
  const FloorContentItem =
5
4
  (floorModuleType && builtInComponents[floorModuleType]) || null
6
5
  const dataDefines = getFloorDataToDataDefines(floorData)
7
6
  return FloorContentItem ? (
8
7
  <ErrorBoundary {...props}>
9
8
  <FloorContentItem {...props} dataDefines={dataDefines} />
10
9
  </ErrorBoundary>
11
10
  ) : null
12
11
  renderSourceType: BUSINESS_TYPE.ONLINE,
13
12
  switch (moduleId) {
14
13
  case 83158:
15
14
  return 'freeLayout'
16
15
  case 99654:
17
16
  return 'activeText'
18
17
  case 100382:
19
18
  return 'superGoods'
20
19
  }
21
20
  floorList.map((item) => {
22
21
  if (!item.floorExtInfo) {
23
22
  return null
24
23
  }
25
24
  const moduleFlag = item.floorExtInfo.moduleFlag
26
25
  if (!moduleFlag) {
27
26
  const newModuleFlag = moduleId2ModuleFlag(item.moduleId)
28
27
  if (newModuleFlag) {
29
28
  item.floorExtInfo.moduleFlag = newModuleFlag
30
29
  }
31
30
  }
32
31
  })
32
+ import React from 'react'
33
33
  return FloorContentItem ? (
34
34
  <FloorContentItem {...props} dataDefines={dataDefines} />
35
35
  ) : isDevMode ? (
36
36
  renderDecorateDefaultModule()
37
37
  ) : null