@conecli/cone-render 0.8.36 → 0.9.1-isv2.0

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 (36) hide show
  1. package/README.md +7 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.h5.ts +1 -1
  4. package/dist/common/index.jd.ts +1 -1
  5. package/dist/common/index.ts +1 -1
  6. package/dist/common/index.weapp.ts +1 -1
  7. package/dist/common/wxappApi.ts +1 -1
  8. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  9. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  10. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  11. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  12. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  13. package/dist/components/base/Skeleton/index.tsx +1 -1
  14. package/dist/components/remoteFloorItem.tsx +1 -1
  15. package/dist/interface/common.ts +1 -1
  16. package/dist/jumpEventReport/base.ts +1 -1
  17. package/dist/jumpEventReport/web.base.ts +1 -1
  18. package/dist/jumpEventReport/web.jd.ts +1 -1
  19. package/dist/utils/h5Utils.ts +1 -1
  20. package/dist/utils/index.h5.ts +1 -1
  21. package/dist/utils/index.ts +1 -1
  22. package/dist/utils/index.weapp.ts +1 -1
  23. package/dist/utils/taroRenderUtil.ts +1 -0
  24. package/dist/utils/utils.ts +1 -1
  25. package/dist/wxapp/api/helper.js +1 -0
  26. package/dist/wxapp/components/launch-app/index.js +1 -0
  27. package/dist/wxapp/components/launch-app/index.json +5 -0
  28. package/dist/wxapp/components/launch-app/index.wxml +0 -0
  29. package/dist/wxapp/components/launch-app/index.wxss +0 -0
  30. package/dist/wxapp/components/subscribe-guider/helper.js +1 -0
  31. package/dist/wxapp/components/subscribe-guider/index.js +1 -0
  32. package/dist/wxapp/components/subscribe-guider/index.json +5 -0
  33. package/dist/wxapp/components/subscribe-guider/index.wxml +0 -0
  34. package/dist/wxapp/components/subscribe-guider/index.wxss +0 -0
  35. package/package.json +45 -32
  36. package/dist/components/base/Skeleton/old.tsx +0 -1
@@ -1 +1 @@
1
- import React, {useRef, useEffect} from 'react'
2
1
  isH5AndJdShopView,
3
2
  isAndroidDevice,
4
3
  isIosDevice,
5
4
  isJdApp,
6
5
  isWxMin,
7
6
  isH5AndJdShopViewH5Scroll,
8
7
  isH5,
9
8
  const rootEleNode = isH5 && document ? document.querySelector('body') : null
10
9
  const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
11
10
  e && e.stopPropagation()
12
11
  if(!verticalScrolling) {
13
12
  needShowHighVersion && rootEleNode && rootEleNode.classList.add('over-hidden')
14
13
  }
15
14
  e && e.stopPropagation()
16
15
  e && e.stopPropagation()
17
16
  if(!verticalScrolling) {
18
17
  needShowHighVersion && rootEleNode && rootEleNode.classList.add('over-hidden')
19
18
  }
20
19
  if(!verticalScrolling) {
21
20
  needShowHighVersion && rootEleNode && rootEleNode.classList.remove('over-hidden')
22
21
  }
23
22
  <ScrollView
24
23
  scrollX
25
24
  onTouchStart={changeTouchStart}
26
25
  onTouchEnd={changeTouchEnd}
27
26
  onTouchCancel={changeTouchEnd}
28
27
  onTouchMove={changeTouchMove}
29
28
  enhanced
30
29
  showScrollbar={false}
31
30
  style={style}
32
31
  className={classNames(className, {
33
32
  [customScrollViewStyle[
34
33
  'd-custom-ios-h5-extend-border-radius'
35
34
  ]]: isIosDevice,
36
35
  },'J_customScroll')}
37
36
  {...otherProps}
38
37
  >
39
38
  {children}
40
39
  </ScrollView>
41
40
  verticalScrolling: false,
41
+ import React, {useRef, useEffect} from 'react'
42
42
  isH5AndJdShopView,
43
43
  isAndroidDevice,
44
44
  isIosDevice,
45
45
  isJdApp,
46
46
  isWxMin,
47
47
  isH5AndJdShopViewH5Scroll,
48
48
  isH5,
49
49
  const rootEleNode = isH5 && document ? document.querySelector('body') : null
50
50
  const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
51
51
  const GetSlideAngle = (dx,dy) => {
52
52
  return Math.atan2(dy,dx) * 180 / Math.PI;
53
53
  }
54
54
  const GetSlideDirection = (startX,startY,endX,endY) => {
55
55
  const dy = startY - endY;
56
56
  const dx = endX - startX;
57
57
  let result = 0;
58
58
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
59
59
  return result;
60
60
  }
61
61
  const angle = GetSlideAngle(dx, dy);
62
62
  if (angle >= -45 && angle < 45) {
63
63
  result = 4;
64
64
  }else if (angle >= 45 && angle < 135) {
65
65
  result = 1;
66
66
  }else if (angle >= -135 && angle < -45) {
67
67
  result = 2;
68
68
  }else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
69
69
  result = 3;
70
70
  }
71
71
  return result;
72
72
  }
73
73
  needShowHighVersion && rootEleNode && rootEleNode.classList.add('over-hidden')
74
74
  const touchEvent =
75
75
  e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
76
76
  const xDiff = Math.abs(
77
77
  touchEvent.clientX - mLastClientPosRef.current.mLastClientX,
78
78
  ).toFixed(2)
79
79
  const yDiff = Math.abs(
80
80
  touchEvent.clientY - mLastClientPosRef.current.mLastClientY,
81
81
  ).toFixed(2)
82
82
  if(isAndroidDevice) {
83
83
  if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
84
84
  console.log(
85
85
  '横向滚动触发',
86
86
  xDiff,
87
87
  touchEvent,
88
88
  window.JDJshopViewInfo.androidTouchSlop,
89
89
  )
90
90
  } else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
91
91
  console.log(
92
92
  '纵向滚动触发',
93
93
  yDiff,
94
94
  touchEvent,
95
95
  window.JDJshopViewInfo.androidTouchSlop,
96
96
  )
97
97
  androidDeviceStopNativeScrollEvent(false)
98
98
  }
99
99
  }
100
100
  if(needShowHighVersion) {
101
101
  const direction = GetSlideDirection(mLastClientPosRef.current.mLastClientX, mLastClientPosRef.current.mLastClientY, touchEvent.clientX, touchEvent.clientY);
102
102
  if(direction === 1 || direction === 2) {
103
103
  rootEleNode && rootEleNode.classList.remove('over-hidden')
104
104
  }
105
105
  }
106
106
  <ScrollView
107
107
  scrollX
108
108
  onTouchStart={changeTouchStart}
109
109
  onTouchEnd={changeTouchEnd}
110
110
  onTouchCancel={changeTouchEnd}
111
111
  onTouchMove={changeTouchMove}
112
112
  enhanced
113
113
  showScrollbar={false}
114
114
  style={style}
115
115
  className={classNames(className, {
116
116
  [customScrollViewStyle[
117
117
  'd-custom-ios-h5-extend-border-radius'
118
118
  ]]: isIosDevice,
119
119
  },'J_customScroll')}
120
120
  {...otherProps}
121
121
  >
122
122
  {children}
123
123
  </ScrollView>
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  TaroEventType,
3
2
  WEBVIEW_STATE,
4
3
  M_H5_ROOT_ELE_NODE,
5
4
  latestFromNativeMsgStorage,
6
5
  getNativePageScrollRes,
7
6
  props: ComponentInterFace.InOrOutViewObserverProps,
8
7
  const {
9
8
  children,
10
9
  style,
11
10
  inViewCallback,
12
11
  outViewCallback,
13
12
  threshold = 0,
14
13
  } = props
15
14
  const [componentShowState, setComponentShowState] = useState(false)
16
15
  const componentObserverRef = useRef<HTMLElement | null>(null)
17
16
  const componentShowStateRef = useRef(false)
18
17
  const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
19
18
  const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
20
19
  if (isH5AndJdShopView && !needShowHighVersion) {
21
20
  useEffect(() => {
22
21
  const latestRes =
23
22
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
24
23
  dealPageScrollInfo(latestRes)
25
24
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
26
25
  dealPageScrollInfo(res)
27
26
  })
28
27
  Taro.eventCenter.on(
29
28
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
30
29
  (state) => {
31
30
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
32
31
  },
33
32
  )
34
33
  return function cleanup() {
35
34
  Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
36
35
  dealPageScrollInfo(res)
37
36
  })
38
37
  Taro.eventCenter.off(
39
38
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
40
39
  (state) => {
41
40
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
42
41
  },
43
42
  )
44
43
  }
45
44
  }, [])
46
45
  useEffect(() => {
47
46
  if (componentShowState) {
48
47
  typeof inViewCallback === 'function' && inViewCallback()
49
48
  console.log('app=>in可视区域')
50
49
  } else {
51
50
  typeof outViewCallback === 'function' && outViewCallback()
52
51
  console.log('app=>out可视区域')
53
52
  }
54
53
  }, [componentShowState])
55
54
 
56
55
  const handleInOrOutView = (type: boolean) => {
57
56
  componentShowStateRef.current = type
58
57
  setComponentShowState(type)
59
58
  console.log('handleInOrOutView', type)
60
59
  }
61
60
 
62
61
  const dealPageScrollInfo = (res) => {
63
62
  console.log('dealPageScrollInfo===', res)
64
63
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
65
64
  if (
66
65
  typeof displayHeight === 'undefined' ||
67
66
  typeof offSetY === 'undefined'
68
67
  )
69
68
  return
70
69
  console.log(
71
70
  '处理后dealPageScrollInfo===displayHeight=offSetY',
72
71
  displayHeight,
73
72
  offSetY,
74
73
  )
75
74
  if (componentObserverRef.current) {
76
75
  const eleClientRect =
77
76
  componentObserverRef.current.getBoundingClientRect()
78
77
  const eleOffsetTop = Math.ceil(eleClientRect.top)
79
78
  const eleHeight = Math.ceil(eleClientRect.height)
80
79
  console.log(
81
80
  '==========================eleOffsetTop, eleHeight',
82
81
  eleOffsetTop,
83
82
  eleHeight,
84
83
  )
85
84
  if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
86
85
  const isOutView =
87
86
  offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
88
87
  displayHeight - (eleOffsetTop - offSetY) <
89
88
  Math.ceil(eleHeight * threshold)
90
89
  console.log(
91
90
  '比较isOutView',
92
91
  isOutView,
93
92
  offSetY,
94
93
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
95
94
  displayHeight - (eleOffsetTop - offSetY),
96
95
  Math.ceil(eleHeight * threshold),
97
96
  )
98
97
  handleInOrOutView(!isOutView)
99
98
  } else {
100
99
  const isInView =
101
100
  offSetY >
102
101
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
103
102
  offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
104
103
  console.log(
105
104
  '比较isInView',
106
105
  isInView,
107
106
  offSetY,
108
107
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
109
108
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
110
109
  )
111
110
  handleInOrOutView(isInView)
112
111
  }
113
112
  }
114
113
  }
115
114
  return (
116
115
  <View ref={componentObserverRef} style={style}>
117
116
  {children}
118
117
  </View>
119
118
  )
120
119
  } else {
121
120
  const { ref, inView } = useInView({
122
121
  threshold,
123
122
  triggerOnce: false,
124
123
  root: rootDom || null,
125
124
  rootMargin: `0px 0px 0px 0px`,
126
125
  })
127
126
  useEffect(() => {
128
127
  if (inView) {
129
128
  typeof inViewCallback === 'function' && inViewCallback()
130
129
  console.log('其他h5=>in可视区域')
131
130
  } else {
132
131
  typeof outViewCallback === 'function' && outViewCallback()
133
132
  console.log('其他h5=>out可视区域')
134
133
  }
135
134
  }, [inView])
136
135
  return (
137
136
  <View ref={ref} style={style}>
138
137
  {children}
139
138
  </View>
140
139
  )
141
140
  }
142
141
  children: null,
143
142
  style: {},
144
143
  className: '',
145
144
  inViewCallback: null,
146
145
  outViewCallback: null,
147
146
  threshold: 0,
147
+ import Taro from '@tarojs/taro'
148
148
  TaroEventType,
149
149
  WEBVIEW_STATE,
150
150
  M_H5_ROOT_ELE_NODE,
151
151
  latestFromNativeMsgStorage,
152
152
  getNativePageScrollRes,
153
153
  props: ComponentInterFace.InOrOutViewObserverProps,
154
154
  const {
155
155
  children,
156
156
  style,
157
157
  inViewCallback,
158
158
  outViewCallback,
159
159
  threshold = 0,
160
160
  } = props
161
161
  const [componentShowState, setComponentShowState] = useState(false)
162
162
  const componentObserverRef = useRef<HTMLElement | null>(null)
163
163
  const componentShowStateRef = useRef(false)
164
164
  const needShowHighVersion = isAppClassifyPage || (isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true"))
165
165
  const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
166
166
  if (isH5AndJdShopView && !needShowHighVersion) {
167
167
  console.log('视频========属于app原生滚动')
168
168
  useEffect(() => {
169
169
  const latestRes =
170
170
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
171
171
  dealPageScrollInfo(latestRes)
172
172
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
173
173
  dealPageScrollInfo(res)
174
174
  })
175
175
  Taro.eventCenter.on(
176
176
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
177
177
  (state) => {
178
178
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
179
179
  },
180
180
  )
181
181
  return function cleanup() {
182
182
  Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, (res) => {
183
183
  dealPageScrollInfo(res)
184
184
  })
185
185
  Taro.eventCenter.off(
186
186
  TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
187
187
  (state) => {
188
188
  state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
189
189
  },
190
190
  )
191
191
  }
192
192
  }, [])
193
193
  useEffect(() => {
194
194
  if (componentShowState) {
195
195
  typeof inViewCallback === 'function' && inViewCallback()
196
196
  console.log('app=>in可视区域')
197
197
  } else {
198
198
  typeof outViewCallback === 'function' && outViewCallback()
199
199
  console.log('app=>out可视区域')
200
200
  }
201
201
  }, [componentShowState])
202
202
 
203
203
  const handleInOrOutView = (type: boolean) => {
204
204
  componentShowStateRef.current = type
205
205
  setComponentShowState(type)
206
206
  console.log('handleInOrOutView', type)
207
207
  }
208
208
 
209
209
  const dealPageScrollInfo = (res) => {
210
210
  console.log('dealPageScrollInfo===', res)
211
211
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
212
212
  if (
213
213
  typeof displayHeight === 'undefined' ||
214
214
  typeof offSetY === 'undefined'
215
215
  )
216
216
  return
217
217
  console.log(
218
218
  '处理后dealPageScrollInfo===displayHeight=offSetY',
219
219
  displayHeight,
220
220
  offSetY,
221
221
  )
222
222
  if (componentObserverRef.current) {
223
223
  const eleClientRect =
224
224
  componentObserverRef.current.getBoundingClientRect()
225
225
  const eleOffsetTop = Math.ceil(eleClientRect.top)
226
226
  const eleHeight = Math.ceil(eleClientRect.height)
227
227
  console.log(
228
228
  '==========================eleOffsetTop, eleHeight',
229
229
  eleOffsetTop,
230
230
  eleHeight,
231
231
  )
232
232
  if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
233
233
  const isOutView =
234
234
  offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
235
235
  displayHeight - (eleOffsetTop - offSetY) <
236
236
  Math.ceil(eleHeight * threshold)
237
237
  console.log(
238
238
  '比较isOutView',
239
239
  isOutView,
240
240
  offSetY,
241
241
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
242
242
  displayHeight - (eleOffsetTop - offSetY),
243
243
  Math.ceil(eleHeight * threshold),
244
244
  )
245
245
  handleInOrOutView(!isOutView)
246
246
  } else {
247
247
  const isInView =
248
248
  offSetY >
249
249
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
250
250
  offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
251
251
  console.log(
252
252
  '比较isInView',
253
253
  isInView,
254
254
  offSetY,
255
255
  eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
256
256
  eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
257
257
  )
258
258
  handleInOrOutView(isInView)
259
259
  }
260
260
  }
261
261
  }
262
262
  return (
263
263
  <View ref={componentObserverRef} style={style}>
264
264
  {children}
265
265
  </View>
266
266
  )
267
267
  } else {
268
268
  console.log('视频========h5滚动')
269
269
  const { ref, inView } = useInView({
270
270
  threshold,
271
271
  triggerOnce: false,
272
272
  root: rootDom || null,
273
273
  rootMargin: `0px 0px 0px 0px`,
274
274
  })
275
275
  useEffect(() => {
276
276
  if (inView) {
277
277
  typeof inViewCallback === 'function' && inViewCallback()
278
278
  console.log('其他h5=>in可视区域')
279
279
  } else {
280
280
  typeof outViewCallback === 'function' && outViewCallback()
281
281
  console.log('其他h5=>out可视区域')
282
282
  }
283
283
  }, [inView])
284
284
  return (
285
285
  <View ref={ref} style={style}>
286
286
  {children}
287
287
  </View>
288
288
  )
289
289
  }
290
290
  children: null,
291
291
  style: {},
292
292
  className: '',
293
293
  inViewCallback: null,
294
294
  outViewCallback: null,
295
295
  threshold: 0,
@@ -1 +1 @@
1
- import Taro, { useRouter } from '@tarojs/taro'
2
1
  floorData = {},
3
2
  const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
4
3
  const rootDom = isH5AndJdShopView && needShowHighVersion ? null : document.querySelector('#J_shopHomeRoot')
5
4
  root: rootDom,
6
5
  rootMargin: `0px 0px ${window.innerHeight}px 0px`,
7
6
  useEffect(() => {
8
7
  if(needShowHighVersion) return
9
8
  if (type === LazyType.FLOOR) {
10
9
  const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
11
10
  !componentShowStateRef.current && dealPageScrollInfo(latestRes)
12
11
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
13
12
  !componentShowStateRef.current && dealPageScrollInfo(res)
14
13
  })
15
14
  }
16
15
  }, [])
17
16
  useEffect(() => {
18
17
  if((!needShowHighVersion && componentShowState === true) ||
19
18
  (needShowHighVersion && inView && isH5AndJdShopView)
20
19
  ) {
21
20
  console.log('>>>>>>>>>>>>>>>>>>> 楼层【id=' + containerId + '】已经渲染!')
22
21
  const modularPackResult = floorData?.floorExtInfo?.modularPackResult
23
22
  nativePageRegisterMessage(
24
23
  Message_Type.NATIVE_INJECT_JS_FILE,
25
24
  {
26
25
  data: {
27
26
  "bundleUrl": [bundleUrl]
28
27
  },
29
28
  },
30
29
  )
31
30
  }
32
31
  }
33
32
  }, [componentShowState,inView])
34
33
  if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
35
34
  ref={ref}
35
+ import Taro, { useRouter } from "@tarojs/taro";
36
36
  SECTION_HOME_TAB_TYPE,
37
37
  SECTION_HOME_TAB_NAME_TYPE,
38
38
  TaroEventType,
39
39
  latestFromNativeMsgStorage,
40
40
  nativePageRegisterMessage,
41
41
  Message_Type,
42
42
  getNativePageScrollRes,
43
43
  const {
44
44
  children,
45
45
  containerId,
46
46
  type,
47
47
  placeholder,
48
48
  height,
49
49
  floorData = {},
50
50
  sectionType,
51
51
  lazyNodeClassName,
52
52
  } = props;
53
53
  const getRouterInfo = useRouter();
54
54
  const getQueryData = getRouterInfo?.params || {};
55
55
  const [componentShowState, setComponentShowState] = useState(false);
56
56
  const [componentRenderShowState, setComponentRenderShowState] =
57
57
  useState(false);
58
58
  const componentLazyRef = useRef<HTMLElement | null>(null);
59
59
  const componentShowStateRef = useRef(false);
60
60
  const needShowHighVersion =
61
61
  isH5AndJdShopViewH5Scroll &&
62
62
  !(
63
63
  global.info.queryInfo?.downgraded &&
64
64
  global.info.queryInfo.downgraded === "true"
65
65
  );
66
66
  const rootDom =
67
67
  isH5AndJdShopView && needShowHighVersion
68
68
  ? null
69
69
  : document.querySelector("#J_shopHomeRoot");
70
70
  const { ref, inView } = useInView({
71
71
  threshold: 0,
72
72
  triggerOnce: true,
73
73
  root: rootDom,
74
74
  rootMargin: `0px 0px ${window.innerHeight}px 0px`,
75
75
  });
76
76
  useEffect(() => {
77
77
  if (needShowHighVersion) return;
78
78
  if (type === LazyType.FLOOR) {
79
79
  const latestRes =
80
80
  latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {};
81
81
  !componentShowStateRef.current && dealPageScrollInfo(latestRes);
82
82
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
83
83
  !componentShowStateRef.current && dealPageScrollInfo(res);
84
84
  });
85
85
  }
86
86
  }, []);
87
87
  useEffect(() => {
88
88
  if (
89
89
  (!needShowHighVersion && componentShowState === true) ||
90
90
  (needShowHighVersion && inView && isH5AndJdShopView)
91
91
  ) {
92
92
  console.log(
93
93
  ">>>>>>>>>>>>>>>>>>> 楼层【id=" + containerId + "】已经渲染!"
94
94
  );
95
95
  const modularPackResultObj = formatPackResult(
96
96
  floorData?.floorExtInfo?.modularPackResult
97
97
  );
98
98
  const bundleUrl = getBundleUrl(modularPackResultObj);
99
99
  if (bundleUrl) {
100
100
  nativePageRegisterMessage(Message_Type.NATIVE_INJECT_JS_FILE, {
101
101
  data: {
102
102
  bundleUrl: [bundleUrl],
103
103
  },
104
104
  });
105
105
  }
106
106
  }
107
107
  }, [componentShowState, inView]);
108
108
 
109
109
  const dealPageScrollInfo = (res) => {
110
110
  const { displayHeight, offSetY } = getNativePageScrollRes(res) || {};
111
111
  if (typeof displayHeight === "undefined" || typeof offSetY === "undefined")
112
112
  return;
113
113
  if (componentLazyRef.current) {
114
114
  const eleClientRect = componentLazyRef.current.getBoundingClientRect();
115
115
  const getContainerHeightOffSetY = displayHeight + offSetY;
116
116
  const eleOffsetTop = Math.ceil(eleClientRect.top);
117
117
  const eleOffsetHeight = Math.ceil(eleClientRect.height);
118
118
  const eleOffsetTopHeight = eleOffsetTop + eleOffsetHeight;
119
119
  if (!componentShowStateRef.current) {
120
120
  if (getContainerHeightOffSetY > eleOffsetTop) {
121
121
  componentShowStateRef.current = true;
122
122
  setComponentShowState(true);
123
123
  Taro.nextTick(() => {
124
124
  setComponentRenderShowState(true);
125
125
  });
126
126
  }
127
127
  }
128
128
  }
129
129
  };
130
130
  return isH5AndJdShopView && !needShowHighVersion ? (
131
131
  <div
132
132
  id={`${containerId}_lazy`}
133
133
  ref={componentLazyRef}
134
134
  className={classNames(
135
135
  lazyLayoutLoadStyle["d-app-floor-lazy-layout-load"],
136
136
  "d-app-floor-lazy-load"
137
137
  )}
138
138
  style={{
139
139
  minHeight: `${componentRenderShowState ? "auto" : height + "px"}`,
140
140
  backgroundColor: componentRenderShowState ? "transparent" : "#ffffff",
141
141
  }}
142
142
  >
143
143
  {componentShowState ? children : placeholder}
144
144
  </div>
145
145
  ) : (
146
146
  <div
147
147
  id={`${containerId}_lazy`}
148
148
  className={classNames(
149
149
  lazyLayoutLoadStyle["d-mobile-floor-lazy-layout-load"],
150
150
  "d-mobile-floor-lazy-load"
151
151
  )}
152
152
  ref={ref}
153
153
  style={{
154
154
  minHeight: `${inView ? "auto" : height + "px"}`,
155
155
  backgroundColor: inView ? "transparent" : "#ffffff",
156
156
  }}
157
157
  >
158
158
  {inView ? children : placeholder}
159
159
  </div>
160
160
  );
161
161
  sectionType:
162
162
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
163
163
  type: LazyType.FLOOR,
164
164
  children: null,
165
165
  placeholder: null,
166
166
  height: 200,
167
167
  className: "",
168
168
  lazyNodeClassName: "",
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
1
+ import Taro from '@tarojs/taro'
2
2
  SECTION_HOME_TAB_TYPE,
3
3
  SECTION_HOME_TAB_NAME_TYPE,
4
4
  const {
5
5
  children,
6
6
  containerId,
7
7
  type,
8
8
  placeholder,
9
9
  height,
10
10
  sectionType,
11
11
  lazyNodeClassName,
12
12
  } = props
13
13
  const [componentShowState, setComponentShowState] = useState(false)
14
14
  const componentLazyRef = useRef<HTMLElement | null>(null)
15
15
  const lazyLayoutLoadFloor =
16
16
  'lazy-layout-load-floor' + Math.floor(Math.random() * 10000000)
17
17
  useEffect(() => {
18
18
  Taro.nextTick(() => {
19
19
  const createIntersectionObserver = new intersectionObserver({
20
20
  selector: `.${lazyLayoutLoadFloor}`,
21
21
  context: this,
22
22
  onFinal: () => {
23
23
  setComponentShowState(true)
24
24
  createIntersectionObserver.disconnect()
25
25
  },
26
26
  })
27
27
  createIntersectionObserver.connect()
28
28
  })
29
29
  }, [])
30
30
  return type === LazyType.IMAGE ? (
31
31
  children
32
32
  ) : (
33
33
  <View
34
34
  id={`${containerId}_lazy`}
35
35
  ref={componentLazyRef}
36
36
  className={classNames(
37
37
  lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
38
38
  'd-app-floor-lazy-load',
39
39
  lazyLayoutLoadFloor,
40
40
  )}
41
41
  style={{
42
42
  minHeight: `${componentShowState ? 'auto' : height + 'px'}`,
43
43
  backgroundColor: componentShowState ? 'transparent' : '#ffffff',
44
44
  }}
45
45
  >
46
46
  {componentShowState ? children : placeholder}
47
47
  </View>
48
48
  )
49
49
  sectionType:
50
50
  SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN],
51
51
  type: LazyType.FLOOR,
52
52
  children: null,
53
53
  placeholder: null,
54
54
  height: 200,
55
55
  className: '',
56
56
  lazyNodeClassName: '',