@conecli/cone-render 0.10.1-shop3.89 → 0.10.1-shop3.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  const { type, className, reportData, customReportDataKey, customReportDataFn, trackCallback } = props
3
2
  const isViewOnlineState =
4
3
  taroJdBaseInfo.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
5
4
  const isCustomReport = customReportDataKey && customReportDataFn
6
5
  const checkReportData = Array.isArray(reportData)
7
6
  const [floorData, mInfo] = checkReportData ? reportData : []
8
7
  const showRenderState = isCustomReport ? true : floorData && mInfo
9
8
  const getFloorPointClassName = isCustomReport ? `J_custom_${customReportDataKey}` : `J_floor_${floorData?.uid}_index_${mInfo?.pos}`
10
9
  const getTaroSelector = isCustomReport ? `#J_miniShopRoot >>> .${getFloorPointClassName}` : `#J_floor_${floorData?.uid} >>> .${getFloorPointClassName}`
11
10
  useEffect(() => {
12
11
  if (isViewOnlineState && reportData) {
13
12
  Taro.nextTick(() => {
14
13
  if (
15
14
  !taroJdBaseInfo.info.pageInfo.floorExposureInfo[
16
15
  getFloorPointClassName
17
16
  ]
18
17
  ){
19
18
  const createIntersectionObserver = new intersectionObserver({
20
19
  selector: getTaroSelector,
21
20
  context: this,
22
21
  onFinal: (res) => {
23
22
  taroJdBaseInfo.info.pageInfo.floorExposureInfo[
24
23
  getFloorPointClassName
25
24
  ] = true
26
25
  console.log('小程序曝光埋点收到进入可视区域啦!', getFloorPointClassName, reportData, res)
27
26
  if(!isCustomReport){
28
27
  addReportData(reportData)
29
28
  typeof trackCallback === 'function' && trackCallback(reportData)
30
29
  }else {
31
30
  typeof customReportDataFn === 'function' && customReportDataFn(customReportDataKey)
32
31
  }
33
32
  createIntersectionObserver.disconnect()
34
33
  },
35
34
  })
36
35
  createIntersectionObserver.connect()
37
36
  }
38
37
  })
39
38
  }
40
39
  }, [])
41
40
  return (showRenderState ? (
42
41
  <View
43
42
  className={classNames(
44
43
  {
45
44
  [exposureStyle['d-report-point']]: type === TrackType.point,
46
45
  },
47
46
  {
48
47
  [exposureStyle['d-report-floor']]: type === TrackType.floor,
49
48
  },
50
49
  getFloorPointClassName,
51
50
  className,
52
51
  )}
53
52
  />
54
53
  ) : null
55
54
  )
56
55
  return useMemo(() => {
57
56
  return <ExposureFloor {...props} />
58
57
  }, [])
59
58
  reportData: null,
60
59
  trackCallback: null,
61
60
  type: TrackType.point,
61
+ import Taro from '@tarojs/taro'
62
62
  const { type, className, reportData, customReportDataKey, customReportDataFn, trackCallback, innerRef } = props
63
63
  const isViewOnlineState =
64
64
  taroJdBaseInfo.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
65
65
  const isCustomReport = customReportDataKey && customReportDataFn
66
66
  const checkReportData = Array.isArray(reportData)
67
67
  const [floorData, mInfo] = checkReportData ? reportData : []
68
68
  const showRenderState = isCustomReport ? true : floorData && mInfo
69
69
  const getFloorPointClassName = isCustomReport ? `J_custom_${customReportDataKey}` : `J_floor_${floorData?.uid}_index_${mInfo?.pos}`
70
70
  const getTaroSelector = isCustomReport ? `#J_miniShopRoot >>> .${getFloorPointClassName}` : `#J_floor_${floorData?.uid} >>> .${getFloorPointClassName}`
71
71
  useEffect(() => {
72
72
  if (isViewOnlineState && reportData) {
73
73
  Taro.nextTick(() => {
74
74
  if (
75
75
  !taroJdBaseInfo.info.pageInfo.floorExposureInfo[
76
76
  getFloorPointClassName
77
77
  ]
78
78
  ){
79
79
  const createIntersectionObserver = new intersectionObserver({
80
80
  selector: getTaroSelector,
81
81
  context: this,
82
82
  onFinal: (res) => {
83
83
  taroJdBaseInfo.info.pageInfo.floorExposureInfo[
84
84
  getFloorPointClassName
85
85
  ] = true
86
86
  console.log('小程序曝光埋点收到进入可视区域啦!', getFloorPointClassName, reportData, res)
87
87
  if(!isCustomReport){
88
88
  addReportData(reportData,null)
89
89
  typeof trackCallback === 'function' && trackCallback(reportData)
90
90
  }else {
91
91
  if (typeof customReportDataFn === 'function') {
92
92
  const getReportData = customReportDataFn(customReportDataKey);
93
93
  if(getReportData){
94
94
  const { eventId, spmAllCode, spmCodeForCD, jsonParam } = getReportData;
95
95
  (eventId || spmAllCode || spmCodeForCD) &&
96
96
  jsonParam &&
97
97
  track.reportExposureEventLog({
98
98
  ...getReportData,
99
99
  target: null,
100
100
  });
101
101
  }
102
102
  }
103
103
  }
104
104
  createIntersectionObserver.disconnect()
105
105
  },
106
106
  })
107
107
  createIntersectionObserver.connect()
108
108
  }
109
109
  })
110
110
  }
111
111
  }, [])
112
112
  return (showRenderState ? (
113
113
  <View
114
114
  className={classNames(
115
115
  {
116
116
  [exposureStyle['d-report-point']]: type === TrackType.point,
117
117
  },
118
118
  {
119
119
  [exposureStyle['d-report-floor']]: type === TrackType.floor,
120
120
  },
121
121
  getFloorPointClassName,
122
122
  className,
123
123
  )}
124
124
  />
125
125
  ) : null
126
126
  )
127
127
  return useMemo(() => {
128
128
  return <ExposureFloor {...props} />
129
129
  }, [])
130
130
  reportData: null,
131
131
  trackCallback: null,
132
132
  type: TrackType.point,