@conecli/cone-render 0.8.38 → 0.8.39

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 (61) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/index.h5.ts +1 -1
  4. package/dist/common/index.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/jssdk.ts +1 -0
  8. package/dist/common/pageType.ts +1 -0
  9. package/dist/common/token/index.h5.ts +1 -1
  10. package/dist/common/token/token.jd.ts +1 -1
  11. package/dist/common/wxappApi.ts +1 -1
  12. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  13. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  14. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  15. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  16. package/dist/components/base/MobileCommonHeader/index.module.scss +9 -0
  17. package/dist/components/base/MobileCommonHeader/index.tsx +1 -0
  18. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  19. package/dist/components/base/Price/Double/index.tsx +1 -1
  20. package/dist/components/base/Price/index.tsx +1 -1
  21. package/dist/components/decorate/DecorateFloorModule/index.module.scss +21 -2
  22. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  23. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  24. package/dist/components/floorItem.tsx +1 -1
  25. package/dist/components/isv/Floor/index.tsx +1 -1
  26. package/dist/components/remoteFloorItem.tsx +1 -1
  27. package/dist/interface/common.ts +1 -1
  28. package/dist/interface/component.ts +1 -1
  29. package/dist/interface/jumpEventReport.ts +1 -1
  30. package/dist/interface/service.ts +1 -1
  31. package/dist/jumpEventReport/base.ts +1 -1
  32. package/dist/jumpEventReport/const.ts +1 -1
  33. package/dist/jumpEventReport/index.h5.ts +1 -1
  34. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  35. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  36. package/dist/jumpEventReport/web.base.ts +1 -1
  37. package/dist/jumpEventReport/web.jd.ts +1 -1
  38. package/dist/jumpEventReport/web.pc.ts +1 -0
  39. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  40. package/dist/open/api/environment.ts +1 -1
  41. package/dist/open/api/index.ts +1 -1
  42. package/dist/open/components/index.ts +1 -1
  43. package/dist/service/fetchGateway.ts +1 -1
  44. package/dist/service/http/const.ts +1 -1
  45. package/dist/service/requestServer.ts +1 -1
  46. package/dist/utils/h5Utils.ts +1 -1
  47. package/dist/utils/index.h5.ts +1 -1
  48. package/dist/utils/index.ts +1 -1
  49. package/dist/utils/index.weapp.ts +1 -1
  50. package/dist/utils/utils.ts +1 -1
  51. package/dist/wxapp/api/helper.js +1 -0
  52. package/dist/wxapp/components/launch-app/index.js +1 -0
  53. package/dist/wxapp/components/launch-app/index.json +5 -0
  54. package/dist/wxapp/components/launch-app/index.wxml +0 -0
  55. package/dist/wxapp/components/launch-app/index.wxss +0 -0
  56. package/dist/wxapp/components/subscribe-guider/helper.js +1 -0
  57. package/dist/wxapp/components/subscribe-guider/index.js +1 -0
  58. package/dist/wxapp/components/subscribe-guider/index.json +5 -0
  59. package/dist/wxapp/components/subscribe-guider/index.wxml +0 -0
  60. package/dist/wxapp/components/subscribe-guider/index.wxss +0 -0
  61. package/package.json +1 -1
@@ -1 +1 @@
1
- import React, { useMemo } from 'react'
1
+ import React, { useMemo } from 'react'
2
2
  key: 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
  START: 'start',
50
50
  END: 'end'
51
51
  const rootEleNode = isH5 && document ? document.querySelector('body') : null
52
52
  const needShowHighVersion = isH5AndJdShopViewH5Scroll && !(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === "true")
53
53
  const iosDeviceStopNativeScrollEvent = (e, touchType) => {
54
54
  e && e.stopPropagation()
55
55
  iosDeviceSendRouter(touchType)
56
56
  }
57
57
  const iosDeviceSendRouter = (state) => {
58
58
  window.webkit.messageHandlers.MobileNavi.postMessage?.({
59
59
  method: 'callRouterModuleWithParams',
60
60
  params: {
61
61
  routerURL: 'router://JDShopModule/processShoph5SlideState',
62
62
  routerParam: { slideDirection: 'horizontal', state },
63
63
  callBackId: new Date().getTime(),
64
64
  }
65
65
  });
66
66
  }
67
67
  isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType)
68
68
  const GetSlideAngle = (dx,dy) => {
69
69
  return Math.atan2(dy,dx) * 180 / Math.PI;
70
70
  }
71
71
  const GetSlideDirection = (startX,startY,endX,endY) => {
72
72
  const dy = startY - endY;
73
73
  const dx = endX - startX;
74
74
  let result = 0;
75
75
  if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
76
76
  return result;
77
77
  }
78
78
  const angle = GetSlideAngle(dx, dy);
79
79
  if (angle >= -45 && angle < 45) {
80
80
  result = 4;
81
81
  }else if (angle >= 45 && angle < 135) {
82
82
  result = 1;
83
83
  }else if (angle >= -135 && angle < -45) {
84
84
  result = 2;
85
85
  }else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
86
86
  result = 3;
87
87
  }
88
88
  return result;
89
89
  }
90
90
  needShowHighVersion && rootEleNode && rootEleNode.classList.add('over-hidden')
91
91
  stopNativeScrollEvent(e,TouchType.END)
92
92
  const touchEvent =
93
93
  e?.originalEvent?.targetTouches[0] || e?.targetTouches[0]
94
94
  const xDiff = Math.abs(
95
95
  touchEvent.clientX - mLastClientPosRef.current.mLastClientX,
96
96
  ).toFixed(2)
97
97
  const yDiff = Math.abs(
98
98
  touchEvent.clientY - mLastClientPosRef.current.mLastClientY,
99
99
  ).toFixed(2)
100
100
  if(isAndroidDevice) {
101
101
  if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
102
102
  console.log(
103
103
  '横向滚动触发',
104
104
  xDiff,
105
105
  touchEvent,
106
106
  window.JDJshopViewInfo.androidTouchSlop,
107
107
  )
108
108
  } else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
109
109
  console.log(
110
110
  '纵向滚动触发',
111
111
  yDiff,
112
112
  touchEvent,
113
113
  window.JDJshopViewInfo.androidTouchSlop,
114
114
  )
115
115
  stopNativeScrollEvent(e,TouchType.END)
116
116
  }
117
117
  }
118
118
  if(needShowHighVersion) {
119
119
  const direction = GetSlideDirection(mLastClientPosRef.current.mLastClientX, mLastClientPosRef.current.mLastClientY, touchEvent.clientX, touchEvent.clientY);
120
120
  if(direction === 1 || direction === 2) {
121
121
  rootEleNode && rootEleNode.classList.remove('over-hidden')
122
122
  }
123
123
  }
124
124
  <ScrollView
125
125
  scrollX
126
126
  onTouchStart={changeTouchStart}
127
127
  onTouchEnd={changeTouchEnd}
128
128
  onTouchCancel={changeTouchEnd}
129
129
  onTouchMove={changeTouchMove}
130
130
  enhanced
131
131
  showScrollbar={false}
132
132
  style={style}
133
133
  className={classNames(className, {
134
134
  [customScrollViewStyle[
135
135
  'd-custom-ios-h5-extend-border-radius'
136
136
  ]]: isIosDevice,
137
137
  },'J_customScroll')}
138
138
  {...otherProps}
139
139
  >
140
140
  {children}
141
141
  </ScrollView>
@@ -1 +1 @@
1
- import track from '../../../open/api/track'
2
1
  const {arr : arrTask, startWaitTime} = floorTask
3
2
  const isTimeout = startWaitTime != 0 && (Date.now() - startWaitTime >= 1000)
4
3
  const arrTaskNum = arrTask.length;
5
4
  const isOverMax = arrTaskNum >= 10
6
5
  const hasData = arrTaskNum > 0
7
6
  if(hasData && (isTimeout || isOverMax)){
8
7
  const reduceData = connactData(arrTask)
9
8
  track.reportExposureEventLog(reduceData)
10
9
  floorTask.arr = []
11
10
  floorTask.startWaitTime = 0
12
11
  clearTimeout(floorTask.timer)
13
12
  }
14
13
  const initData = JSON.parse(JSON.stringify(arr[0]))
15
14
  if(initData.jsonParam.etModelInfo) {
16
15
  initData.jsonParam.logBaseInfo = []
17
16
  initData.jsonParam.etModelInfo.lstms = []
18
17
  return arr.reduce((acc, cur) => {
19
18
  acc.jsonParam.logBaseInfo.push(cur.jsonParam.logBaseInfo)
20
19
  return acc
21
20
  }, initData)
22
21
  } else {
23
22
  return arr.reduce((acc) => {
24
23
  return acc
25
24
  })
26
25
  }
27
26
  if(!Array.isArray(data)){
28
27
  console.log('坑位曝光埋点原始数据参类型错误,期望是数组,实际是:', data)
29
28
  return
30
29
  }
31
30
  const [floorData, mInfo, etModelInfo] = data
32
31
  if(floorData && mInfo && etModelInfo){
33
32
  const isIsvReportModule = isvReportModuleTypeList.includes(floorData?.floorExtInfo?.moduleFlag)
34
33
  try {
35
34
  const reportJson = track.getExposureInfo(floorData, mInfo, etModelInfo,true, isIsvReportModule)
36
35
  console.log(`${floorData?.floorExtInfo?.moduleFlag}===reportJson===`,reportJson)
37
36
  const { floorIdx } = floorData
38
37
  if(!task[floorIdx]){
39
38
  task[floorIdx] = {
40
39
  arr: [],
41
40
  startWaitTime: 0,
42
41
  timer : 0
43
42
  }
44
43
  }
45
44
  const floorTask = task[floorIdx]
46
45
  if(floorTask.arr.length === 0){
47
46
  floorTask.startWaitTime = Date.now()
48
47
  }
49
48
  if(reportJson){
50
49
  floorTask.arr.push(reportJson)
51
50
  clearTimeout(floorTask.timer)
52
51
  floorTask.timer = setTimeout(() => {
53
52
  check(floorTask)
54
53
  }, 1000)
55
54
  check(floorTask)
56
55
  }
57
56
  }catch (e) {
58
57
  {
59
58
  console.log('坑位曝光埋点出错啦',e)
60
59
  }
61
60
  }
62
61
  }else{
63
62
  console.log('坑位曝光埋点原始数据参数缺失,期望是[floorData, mInfo, etModelInfo],实际是:', data)
64
63
  }
64
+ import track from '../../../open/api/track'
65
65
  const {arr : arrTask, startWaitTime} = floorTask
66
66
  const isTimeout = startWaitTime != 0 && (Date.now() - startWaitTime >= 1000)
67
67
  const arrTaskNum = arrTask.length;
68
68
  const isOverMax = arrTaskNum >= 10
69
69
  const hasData = arrTaskNum > 0
70
70
  if(hasData && (isTimeout || isOverMax)){
71
71
  const reduceData = connactData(arrTask)
72
72
  track.reportExposureEventLog(reduceData)
73
73
  floorTask.arr = []
74
74
  floorTask.startWaitTime = 0
75
75
  clearTimeout(floorTask.timer)
76
76
  }
77
77
  const initData = JSON.parse(JSON.stringify(arr[0]))
78
78
  if(initData.jsonParam.etModelInfo) {
79
79
  initData.jsonParam.logBaseInfo = []
80
80
  initData.jsonParam.etModelInfo.lstms = []
81
81
  return arr.reduce((acc, cur) => {
82
82
  acc.jsonParam.logBaseInfo.push(cur.jsonParam.logBaseInfo)
83
83
  return acc
84
84
  }, initData)
85
85
  } else {
86
86
  return arr.reduce((acc) => {
87
87
  return acc
88
88
  })
89
89
  }
90
90
  if(!Array.isArray(data)){
91
91
  console.log('坑位曝光埋点原始数据参类型错误,期望是数组,实际是:', data)
92
92
  return
93
93
  }
94
94
  const [floorData, mInfo, etModelInfo] = data
95
95
  if(floorData && mInfo && etModelInfo){
96
96
  const isIsvReportModule = isvReportModuleTypeList.includes(floorData?.floorExtInfo?.moduleFlag)
97
97
  try {
98
98
  const reportJson = track.getExposureInfo(floorData, mInfo, etModelInfo,true, isIsvReportModule)
99
99
  console.log(`${floorData?.floorExtInfo?.moduleFlag}===reportJson===`,reportJson)
100
100
  const { floorIdx } = floorData
101
101
  if(!task[floorIdx]){
102
102
  task[floorIdx] = {
103
103
  arr: [],
104
104
  startWaitTime: 0,
105
105
  timer : 0
106
106
  }
107
107
  }
108
108
  const floorTask = task[floorIdx]
109
109
  if(floorTask.arr.length === 0){
110
110
  floorTask.startWaitTime = Date.now()
111
111
  }
112
112
  if(reportJson){
113
113
  floorTask.arr.push(reportJson)
114
114
  clearTimeout(floorTask.timer)
115
115
  floorTask.timer = setTimeout(() => {
116
116
  check(floorTask)
117
117
  }, 1000)
118
118
  check(floorTask)
119
119
  }
120
120
  }catch (e) {
121
121
  {
122
122
  console.log('坑位曝光埋点出错啦',e)
123
123
  }
124
124
  }
125
125
  }else{
126
126
  console.log('坑位曝光埋点原始数据参数缺失,期望是[floorData, mInfo, etModelInfo],实际是:', data)
127
127
  }
@@ -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,
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1 @@
1
+ import React, { useEffect, useContext, useState } from 'react'
2
  const { title, openAppParams, style, hasCommonHeader = true, hasDownloadTips = true, headerParams } = props
1
3
  useEffect(() => {
2
4
  hasCommonHeader && initCommonHeader()
3
5
  hasDownloadTips && initDownloadAppLayerConfigData()
4
6
  }, [])
5
7
  const initCommonHeader = () => {
6
8
  if (window?.MCommonHeaderBottom) {
7
9
  const mchb = new MCommonHeaderBottom()
8
10
  const headerArg = {
9
11
  moduleName: 'shop',
10
12
  hrederId: 'm_common_header',
11
13
  title,
12
14
  stype: 1,
13
15
  onClickJdkey: function () {
14
16
  console.log('==>m_common_header jdkey click.')
15
17
  },
16
18
  ...headerParams
17
19
  }
18
20
  mchb.header(headerArg)
19
21
  }
20
22
  }
21
23
  const initDownloadAppLayerConfigData = () => {
22
24
  const getEle = document.getElementById('m_common_tip')
23
25
  getEle &&
24
26
  window.$ &&
25
27
  window.$.downloadAppLayerConfigData &&
26
28
  window.$.downloadAppLayerConfigData({
27
29
  tipId: 'm_common_tip',
28
30
  M_sourceFrom: 'jshop',
29
31
  bottom: 74,
30
32
  onClickTipX: () => {
31
33
  Taro.eventCenter.trigger(
32
34
  TaroEventType.DOWN_LOAD_APP_CLOSE_CHANGE,
33
35
  true,
34
36
  )
35
37
  },
36
38
  downloadAppPlugIn: {
37
39
  M_sourceFrom: 'jshop',
38
40
  openAppBtnId: 'download_openapp',
39
41
  downAppURl: '//conecli.com/downloadApp/download.html?channel=jd-m',
40
42
  inteneUrl: 'openapp.jdmobile://virtual?',
41
43
  inteneUrlParams: {
42
44
  category: 'jump',
43
45
  des: 'jshopMain',
44
46
  shopId: `${global.info.queryInfo.shopId || ''}`,
45
47
  venderId: `${global.info.queryInfo.venderId || ''}`,
46
48
  sourceType: global.info.queryInfo?.sourceType || 'M-H5',
47
49
  sourceValue: global.info.queryInfo?.sourceValue || 'Mshop',
48
50
  ...openAppParams,
49
51
  },
50
52
  },
51
53
  })
52
54
  }
53
55
  return !isWxMiniH5View && !isJdApp ? (
54
56
  <View
55
57
  className={mobileCommonHeaderStyle['d-mobile-header-layout']}
56
58
  style={style}
57
59
  >
58
60
  <View
59
61
  id="m_common_tip"
60
62
  className={mobileCommonHeaderStyle['d-mobile-common-tip']}
61
63
  />
62
64
  {hasCommonHeader && (
63
65
  <View
64
66
  id="m_common_header"
65
67
  className={mobileCommonHeaderStyle['d-mobile-common-header']}
66
68
  />
67
69
  )}
68
70
  </View>
69
71
  ) : null
70
72
  title: '店铺',
71
73
  openAppParams: {},