@conecli/cone-render 0.10.1-beta.7 → 0.10.1-beta.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.
- package/dist/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/index.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/common/wxappApi.ts +1 -1
- package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +11 -0
- package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +4 -8
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.tsx +1 -1
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/interface/common.ts +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web/report.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -53
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/device.ts +1 -1
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/sass/app.h5.scss +255 -224
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -1
- package/dist/service/requestServer.h5.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -0
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
- package/dist/utils/jumpExtMapUtil.ts +1 -0
- package/dist/utils/sColor.js +1 -0
- package/dist/utils/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
- package/dist/wxapp/common/user_info.js +1 -1
- package/package.json +147 -141
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
1
|
const { type, className, reportData, customReportDataKey, customReportDataFn, trackCallback, markPoint } = props
|
|
3
2
|
const isCustomReport = customReportDataKey && customReportDataFn
|
|
4
3
|
const isViewOnlineState =
|
|
5
4
|
taroJdBaseInfo.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE
|
|
6
5
|
const showRenderState = isCustomReport ? true : reportData
|
|
7
6
|
const inViewCallback = () => {
|
|
8
7
|
console.log('埋点收到进入可视区域的回调啦!', reportData)
|
|
9
8
|
if(!isCustomReport){
|
|
10
9
|
addReportData(reportData)
|
|
11
10
|
typeof trackCallback === 'function' && trackCallback(reportData)
|
|
12
11
|
}else {
|
|
13
12
|
typeof customReportDataFn === 'function' && customReportDataFn(customReportDataKey)
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
let chartPointClassName = ""
|
|
17
16
|
|
|
18
17
|
if(isChartH5 && markPoint && Array.isArray(reportData)){
|
|
19
18
|
const [floorData, mInfo] = reportData
|
|
20
19
|
if(floorData && mInfo && mInfo.hasOwnProperty('pos') ){
|
|
21
20
|
chartPointClassName = track.getFloorPointIndexClassName(floorData, mInfo.pos)
|
|
22
21
|
}
|
|
23
22
|
}else if(isCustomReport){
|
|
24
23
|
chartPointClassName = `J_custom_${customReportDataKey}`
|
|
25
24
|
}
|
|
26
25
|
return isViewOnlineState && showRenderState
|
|
27
26
|
? <InViewRender className={classNames(
|
|
28
27
|
{
|
|
29
28
|
[exposureStyle['d-report-point']]: type === TrackType.point,
|
|
30
29
|
},
|
|
31
30
|
{
|
|
32
31
|
[exposureStyle['d-report-floor']]: type === TrackType.floor,
|
|
33
32
|
},
|
|
34
33
|
className,
|
|
35
34
|
chartPointClassName
|
|
36
35
|
)} height={'100%'} inViewCallback={inViewCallback}></InViewRender>
|
|
37
36
|
: null
|
|
38
37
|
return useMemo(() => {
|
|
39
38
|
return <Exposure {...props} />
|
|
40
39
|
}, [])
|
|
41
40
|
reportData: null,
|
|
42
41
|
trackCallback: null,
|
|
43
42
|
type: TrackType.point,
|
|
44
43
|
markPoint: false
|
|
44
|
+
import React, { useMemo } from 'react';
|
|
45
45
|
const {
|
|
46
46
|
type,
|
|
47
47
|
className,
|
|
48
48
|
reportData,
|
|
49
49
|
customReportDataKey,
|
|
50
50
|
customReportDataFn,
|
|
51
51
|
trackCallback,
|
|
52
52
|
markPoint,
|
|
53
53
|
innerRef,
|
|
54
54
|
} = props;
|
|
55
55
|
const isCustomReport = customReportDataKey && customReportDataFn;
|
|
56
56
|
const isViewOnlineState = taroJdBaseInfo.info.pageInfo.dataType === BUSINESS_TYPE.ONLINE;
|
|
57
57
|
const showRenderState = isCustomReport ? true : reportData;
|
|
58
58
|
const inViewCallback = () => {
|
|
59
59
|
const getInsertFlowMapEle =
|
|
60
60
|
innerRef?.current?.querySelector('.d-report-exposure-point') || createDefaultFlowMapEle;
|
|
61
61
|
if (!isCustomReport) {
|
|
62
62
|
addReportData(reportData, getInsertFlowMapEle);
|
|
63
63
|
typeof trackCallback === 'function' && trackCallback(reportData);
|
|
64
64
|
} else {
|
|
65
65
|
if (typeof customReportDataFn === 'function') {
|
|
66
66
|
const getReportData = customReportDataFn(customReportDataKey);
|
|
67
67
|
getReportData &&
|
|
68
68
|
getReportData?.eventId &&
|
|
69
69
|
getReportData?.jsonParam &&
|
|
70
70
|
track.reportExposureEventLog({
|
|
71
71
|
...getReportData,
|
|
72
72
|
target: getInsertFlowMapEle,
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
let chartPointClassName = '';
|
|
78
78
|
|
|
79
79
|
if (isChartH5 && markPoint && Array.isArray(reportData)) {
|
|
80
80
|
const [floorData, mInfo] = reportData;
|
|
81
81
|
if (floorData && mInfo && mInfo.hasOwnProperty('pos')) {
|
|
82
82
|
chartPointClassName = track.getFloorPointIndexClassName(floorData, mInfo.pos);
|
|
83
83
|
}
|
|
84
84
|
} else if (isCustomReport) {
|
|
85
85
|
chartPointClassName = `J_custom_${customReportDataKey}`;
|
|
86
86
|
}
|
|
87
87
|
return isViewOnlineState && showRenderState ? (
|
|
88
88
|
<InViewRender
|
|
89
89
|
className={classNames(
|
|
90
90
|
'd-report-exposure-point',
|
|
91
91
|
{
|
|
92
92
|
[exposureStyle['d-report-point']]: type === TrackType.point,
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
[exposureStyle['d-report-floor']]: type === TrackType.floor,
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
'd-report-exposure-jd-point': isJdApp,
|
|
99
99
|
},
|
|
100
100
|
className,
|
|
101
101
|
chartPointClassName,
|
|
102
102
|
)}
|
|
103
103
|
height={'100%'}
|
|
104
104
|
inViewCallback={inViewCallback}
|
|
105
105
|
></InViewRender>
|
|
106
106
|
) : null;
|
|
107
107
|
return useMemo(() => {
|
|
108
108
|
return <Exposure {...props} />;
|
|
109
109
|
}, []);
|
|
110
110
|
reportData: null,
|
|
111
111
|
trackCallback: null,
|
|
112
112
|
type: TrackType.point,
|
|
113
113
|
markPoint: false,
|
|
@@ -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(
|
|
99
99
|
floorData,
|
|
100
100
|
mInfo,
|
|
101
101
|
etModelInfo,
|
|
102
102
|
true,
|
|
103
103
|
isIsvReportModule,
|
|
104
104
|
);
|
|
105
105
|
console.log(`${floorData?.floorExtInfo?.moduleFlag}===reportJson===`, reportJson);
|
|
106
106
|
const { floorIdx } = floorData;
|
|
107
107
|
if (!task[floorIdx]) {
|
|
108
108
|
task[floorIdx] = {
|
|
109
109
|
arr: [],
|
|
110
110
|
startWaitTime: 0,
|
|
111
111
|
timer: 0,
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
const floorTask = task[floorIdx];
|
|
115
115
|
if (floorTask.arr.length === 0) {
|
|
116
116
|
floorTask.startWaitTime = Date.now();
|
|
117
117
|
}
|
|
118
118
|
if (reportJson) {
|
|
119
119
|
floorTask.arr.push(reportJson);
|
|
120
120
|
clearTimeout(floorTask.timer);
|
|
121
121
|
floorTask.timer = setTimeout(() => {
|
|
122
122
|
check(floorTask);
|
|
123
123
|
}, 1000);
|
|
124
124
|
check(floorTask);
|
|
125
125
|
}
|
|
126
126
|
} catch (e) {
|
|
127
127
|
{
|
|
128
128
|
console.log('坑位曝光埋点出错啦', e);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
} else {
|
|
132
132
|
console.log(
|
|
133
133
|
'坑位曝光埋点原始数据参数缺失,期望是[floorData, mInfo, etModelInfo],实际是:',
|
|
134
134
|
data,
|
|
135
135
|
);
|
|
136
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
isH5AndJdShopView,
|
|
3
2
|
isH5AndJdShopViewH5Scroll,
|
|
4
3
|
isAppClassifyPage,
|
|
5
4
|
TaroEventType,
|
|
6
5
|
WEBVIEW_STATE,
|
|
7
6
|
M_H5_ROOT_ELE_NODE,
|
|
8
7
|
latestFromNativeMsgStorage,
|
|
9
8
|
getNativePageScrollRes,
|
|
10
9
|
props: ComponentInterFace.InOrOutViewObserverProps,
|
|
11
10
|
const {
|
|
12
11
|
children,
|
|
13
12
|
style,
|
|
14
13
|
inViewCallback,
|
|
15
14
|
outViewCallback,
|
|
16
15
|
threshold = 0,
|
|
17
16
|
} = props
|
|
18
17
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
19
18
|
const componentObserverRef = useRef<HTMLElement | null>(null)
|
|
20
19
|
const componentShowStateRef = useRef(false)
|
|
21
20
|
const needShowHighVersion =
|
|
22
21
|
isAppClassifyPage ||
|
|
23
22
|
(isH5AndJdShopViewH5Scroll &&
|
|
24
23
|
!(
|
|
25
24
|
global.info.queryInfo?.downgraded &&
|
|
26
25
|
global.info.queryInfo.downgraded === 'true'
|
|
27
26
|
))
|
|
28
27
|
const rootDom =
|
|
29
28
|
isH5AndJdShopView && needShowHighVersion
|
|
30
29
|
? null
|
|
31
30
|
: document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
|
|
32
31
|
if (isH5AndJdShopView && !needShowHighVersion) {
|
|
33
32
|
useEffect(() => {
|
|
34
33
|
const latestRes =
|
|
35
34
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
36
35
|
dealPageScrollInfo(latestRes)
|
|
37
36
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, res => {
|
|
38
37
|
dealPageScrollInfo(res)
|
|
39
38
|
})
|
|
40
39
|
Taro.eventCenter.on(
|
|
41
40
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
42
41
|
state => {
|
|
43
42
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
44
43
|
},
|
|
45
44
|
)
|
|
46
45
|
return function cleanup() {
|
|
47
46
|
Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, res => {
|
|
48
47
|
dealPageScrollInfo(res)
|
|
49
48
|
})
|
|
50
49
|
Taro.eventCenter.off(
|
|
51
50
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
52
51
|
state => {
|
|
53
52
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
54
53
|
},
|
|
55
54
|
)
|
|
56
55
|
}
|
|
57
56
|
}, [])
|
|
58
57
|
useEffect(() => {
|
|
59
58
|
if (componentShowState) {
|
|
60
59
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
61
60
|
console.log('app=>in可视区域')
|
|
62
61
|
} else {
|
|
63
62
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
64
63
|
console.log('app=>out可视区域')
|
|
65
64
|
}
|
|
66
65
|
}, [componentShowState])
|
|
67
66
|
|
|
68
67
|
const handleInOrOutView = (type: boolean) => {
|
|
69
68
|
componentShowStateRef.current = type
|
|
70
69
|
setComponentShowState(type)
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
const dealPageScrollInfo = res => {
|
|
74
73
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
75
74
|
if (
|
|
76
75
|
typeof displayHeight === 'undefined' ||
|
|
77
76
|
typeof offSetY === 'undefined'
|
|
78
77
|
)
|
|
79
78
|
return
|
|
80
79
|
if (componentObserverRef.current) {
|
|
81
80
|
const eleClientRect = componentObserverRef.current.getBoundingClientRect()
|
|
82
81
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
83
82
|
const eleHeight = Math.ceil(eleClientRect.height)
|
|
84
83
|
if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
|
|
85
84
|
const isOutView =
|
|
86
85
|
offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
|
|
87
86
|
displayHeight - (eleOffsetTop - offSetY) <
|
|
88
87
|
Math.ceil(eleHeight * threshold)
|
|
89
88
|
handleInOrOutView(!isOutView)
|
|
90
89
|
} else {
|
|
91
90
|
const isInView =
|
|
92
91
|
offSetY >
|
|
93
92
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
|
|
94
93
|
offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
|
|
95
94
|
handleInOrOutView(isInView)
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
return (
|
|
100
99
|
<View ref={componentObserverRef} style={style}>
|
|
101
100
|
{children}
|
|
102
101
|
</View>
|
|
103
102
|
)
|
|
104
103
|
} else {
|
|
105
104
|
const { ref, inView } = useInView({
|
|
106
105
|
delay: 100,
|
|
107
106
|
threshold,
|
|
108
107
|
triggerOnce: false,
|
|
109
108
|
root: rootDom || null,
|
|
110
109
|
rootMargin: `0px 0px 0px 0px`,
|
|
111
110
|
})
|
|
112
111
|
useEffect(() => {
|
|
113
112
|
if (inView) {
|
|
114
113
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
115
114
|
console.log('其他h5=>in可视区域')
|
|
116
115
|
} else {
|
|
117
116
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
118
117
|
console.log('其他h5=>out可视区域')
|
|
119
118
|
}
|
|
120
119
|
}, [inView])
|
|
121
120
|
return (
|
|
122
121
|
<View ref={ref} style={style}>
|
|
123
122
|
{children}
|
|
124
123
|
</View>
|
|
125
124
|
)
|
|
126
125
|
}
|
|
127
126
|
children: null,
|
|
128
127
|
style: {},
|
|
129
128
|
className: '',
|
|
130
129
|
inViewCallback: null,
|
|
131
130
|
outViewCallback: null,
|
|
132
131
|
threshold: 0,
|
|
132
|
+
import Taro from '@tarojs/taro'
|
|
133
133
|
isH5AndJdShopView,
|
|
134
134
|
isH5AndJdShopViewH5Scroll,
|
|
135
135
|
isAppClassifyPage,
|
|
136
136
|
TaroEventType,
|
|
137
137
|
WEBVIEW_STATE,
|
|
138
138
|
M_H5_ROOT_ELE_NODE,
|
|
139
139
|
latestFromNativeMsgStorage,
|
|
140
140
|
getNativePageScrollRes,
|
|
141
141
|
props: ComponentInterFace.InOrOutViewObserverProps,
|
|
142
142
|
const {
|
|
143
143
|
children,
|
|
144
144
|
style,
|
|
145
145
|
inViewCallback,
|
|
146
146
|
outViewCallback,
|
|
147
147
|
threshold = 0,
|
|
148
148
|
} = props
|
|
149
149
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
150
150
|
const componentObserverRef = useRef<HTMLElement | null>(null)
|
|
151
151
|
const componentShowStateRef = useRef(false)
|
|
152
152
|
const needShowHighVersion =
|
|
153
153
|
isAppClassifyPage ||
|
|
154
154
|
(isH5AndJdShopViewH5Scroll &&
|
|
155
155
|
!(
|
|
156
156
|
global.info.queryInfo?.downgraded &&
|
|
157
157
|
global.info.queryInfo.downgraded === 'true'
|
|
158
158
|
))
|
|
159
159
|
const rootDom =
|
|
160
160
|
isH5AndJdShopView && needShowHighVersion
|
|
161
161
|
? null
|
|
162
162
|
: document.querySelector(`${M_H5_ROOT_ELE_NODE}`)
|
|
163
163
|
if (isH5AndJdShopView && !needShowHighVersion) {
|
|
164
164
|
console.log('视频========属于app原生滚动')
|
|
165
165
|
useEffect(() => {
|
|
166
166
|
const latestRes =
|
|
167
167
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
168
168
|
dealPageScrollInfo(latestRes)
|
|
169
169
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, res => {
|
|
170
170
|
dealPageScrollInfo(res)
|
|
171
171
|
})
|
|
172
172
|
Taro.eventCenter.on(
|
|
173
173
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
174
174
|
state => {
|
|
175
175
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
176
176
|
},
|
|
177
177
|
)
|
|
178
178
|
return function cleanup() {
|
|
179
179
|
Taro.eventCenter.off(TaroEventType.PAGE_SCROLL, res => {
|
|
180
180
|
dealPageScrollInfo(res)
|
|
181
181
|
})
|
|
182
182
|
Taro.eventCenter.off(
|
|
183
183
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
184
184
|
state => {
|
|
185
185
|
state === WEBVIEW_STATE.NOT_VISIBLE && handleInOrOutView(false)
|
|
186
186
|
},
|
|
187
187
|
)
|
|
188
188
|
}
|
|
189
189
|
}, [])
|
|
190
190
|
useEffect(() => {
|
|
191
191
|
if (componentShowState) {
|
|
192
192
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
193
193
|
console.log('app=>in可视区域')
|
|
194
194
|
} else {
|
|
195
195
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
196
196
|
console.log('app=>out可视区域')
|
|
197
197
|
}
|
|
198
198
|
}, [componentShowState])
|
|
199
199
|
|
|
200
200
|
const handleInOrOutView = (type: boolean) => {
|
|
201
201
|
componentShowStateRef.current = type
|
|
202
202
|
setComponentShowState(type)
|
|
203
203
|
console.log('handleInOrOutView', type)
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
const dealPageScrollInfo = res => {
|
|
207
207
|
console.log('dealPageScrollInfo===', res)
|
|
208
208
|
const { displayHeight, offSetY } = getNativePageScrollRes(res) || {}
|
|
209
209
|
if (
|
|
210
210
|
typeof displayHeight === 'undefined' ||
|
|
211
211
|
typeof offSetY === 'undefined'
|
|
212
212
|
)
|
|
213
213
|
return
|
|
214
214
|
console.log(
|
|
215
215
|
'处理后dealPageScrollInfo===displayHeight=offSetY',
|
|
216
216
|
displayHeight,
|
|
217
217
|
offSetY,
|
|
218
218
|
)
|
|
219
219
|
if (componentObserverRef.current) {
|
|
220
220
|
const eleClientRect = componentObserverRef.current.getBoundingClientRect()
|
|
221
221
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
222
222
|
const eleHeight = Math.ceil(eleClientRect.height)
|
|
223
223
|
console.log(
|
|
224
224
|
'==========================eleOffsetTop, eleHeight',
|
|
225
225
|
eleOffsetTop,
|
|
226
226
|
eleHeight,
|
|
227
227
|
)
|
|
228
228
|
if (eleOffsetTop >= 0 && eleOffsetTop < displayHeight) {
|
|
229
229
|
const isOutView =
|
|
230
230
|
offSetY > eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)) ||
|
|
231
231
|
displayHeight - (eleOffsetTop - offSetY) <
|
|
232
232
|
Math.ceil(eleHeight * threshold)
|
|
233
233
|
console.log(
|
|
234
234
|
'比较isOutView',
|
|
235
235
|
isOutView,
|
|
236
236
|
offSetY,
|
|
237
237
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
238
238
|
displayHeight - (eleOffsetTop - offSetY),
|
|
239
239
|
Math.ceil(eleHeight * threshold),
|
|
240
240
|
)
|
|
241
241
|
handleInOrOutView(!isOutView)
|
|
242
242
|
} else {
|
|
243
243
|
const isInView =
|
|
244
244
|
offSetY >
|
|
245
245
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold) &&
|
|
246
246
|
offSetY < eleOffsetTop + Math.ceil(eleHeight * (1 - threshold))
|
|
247
247
|
console.log(
|
|
248
248
|
'比较isInView',
|
|
249
249
|
isInView,
|
|
250
250
|
offSetY,
|
|
251
251
|
eleOffsetTop - displayHeight + Math.ceil(eleHeight * threshold),
|
|
252
252
|
eleOffsetTop + Math.ceil(eleHeight * (1 - threshold)),
|
|
253
253
|
)
|
|
254
254
|
handleInOrOutView(isInView)
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
return (
|
|
259
259
|
<View ref={componentObserverRef} style={style}>
|
|
260
260
|
{children}
|
|
261
261
|
</View>
|
|
262
262
|
)
|
|
263
263
|
} else {
|
|
264
264
|
console.log('视频========h5滚动')
|
|
265
265
|
const { ref, inView } = useInView({
|
|
266
266
|
delay: 100,
|
|
267
267
|
threshold,
|
|
268
268
|
triggerOnce: false,
|
|
269
269
|
root: rootDom || null,
|
|
270
270
|
rootMargin: `0px 0px 0px 0px`,
|
|
271
271
|
})
|
|
272
272
|
useEffect(() => {
|
|
273
273
|
if (inView) {
|
|
274
274
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
275
275
|
console.log('其他h5=>in可视区域')
|
|
276
276
|
} else {
|
|
277
277
|
typeof outViewCallback === 'function' && outViewCallback()
|
|
278
278
|
console.log('其他h5=>out可视区域')
|
|
279
279
|
}
|
|
280
280
|
}, [inView])
|
|
281
281
|
return (
|
|
282
282
|
<View ref={ref} style={style}>
|
|
283
283
|
{children}
|
|
284
284
|
</View>
|
|
285
285
|
)
|
|
286
286
|
}
|
|
287
287
|
children: null,
|
|
288
288
|
style: {},
|
|
289
289
|
className: '',
|
|
290
290
|
inViewCallback: null,
|
|
291
291
|
outViewCallback: null,
|
|
292
292
|
threshold: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
SECTION_HOME_TAB_TYPE,
|
|
3
2
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
4
3
|
const {
|
|
5
4
|
sectionType = SECTION_HOME_TAB_NAME_TYPE[
|
|
6
5
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
7
6
|
],
|
|
8
7
|
type = LazyType.FLOOR,
|
|
9
8
|
children = null,
|
|
10
9
|
placeholder = null,
|
|
11
10
|
height = 200,
|
|
12
11
|
className = '',
|
|
13
12
|
lazyNodeClassName = '',
|
|
14
13
|
containerId,
|
|
15
14
|
} = props
|
|
16
15
|
const [componentShowState, setComponentShowState] = useState(false)
|
|
17
16
|
const componentLazyRef = useRef<HTMLElement | null>(null)
|
|
18
17
|
const lazyLayoutLoadFloor =
|
|
19
18
|
'lazy-layout-load-floor' + Math.floor(Math.random() * 10000000)
|
|
20
19
|
useEffect(() => {
|
|
21
20
|
Taro.nextTick(() => {
|
|
22
21
|
const createIntersectionObserver = new intersectionObserver({
|
|
23
22
|
selector: `.${lazyLayoutLoadFloor}`,
|
|
24
23
|
context: this,
|
|
25
24
|
onFinal: () => {
|
|
26
25
|
setComponentShowState(true)
|
|
27
26
|
createIntersectionObserver.disconnect()
|
|
28
27
|
},
|
|
29
28
|
})
|
|
30
29
|
createIntersectionObserver.connect()
|
|
31
30
|
})
|
|
32
31
|
}, [])
|
|
33
32
|
return type === LazyType.IMAGE ? (
|
|
34
33
|
children
|
|
35
34
|
) : (
|
|
36
35
|
<View
|
|
37
36
|
id={`${containerId}_lazy`}
|
|
38
37
|
ref={componentLazyRef}
|
|
39
38
|
className={classNames(
|
|
40
39
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
41
40
|
'd-app-floor-lazy-load',
|
|
42
41
|
lazyLayoutLoadFloor,
|
|
43
42
|
)}
|
|
44
43
|
style={{
|
|
45
44
|
minHeight: `${componentShowState ? 'auto' : height + 'px'}`,
|
|
46
45
|
backgroundColor: componentShowState ? 'transparent' : '#ffffff',
|
|
47
46
|
}}
|
|
48
47
|
>
|
|
49
48
|
{componentShowState ? children : placeholder}
|
|
50
49
|
</View>
|
|
51
50
|
)
|
|
51
|
+
import Taro from '@tarojs/taro'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
const { className, pointClassName, children, reportData, customReportDataKey,customReportDataFn, trackCallback, ...otherProps } =
|
|
3
2
|
props
|
|
4
3
|
const isCustomReport = customReportDataKey && customReportDataFn
|
|
5
4
|
const checkReportData = Array.isArray(reportData)
|
|
6
5
|
const [floorData, mInfo] = checkReportData ? reportData : []
|
|
7
6
|
const checkReportDataState = isCustomReport ? true : floorData && mInfo
|
|
8
7
|
|
|
9
8
|
floorData && mInfo && !mInfo.hasOwnProperty('pos') && (mInfo.pos = 0)
|
|
10
9
|
return (
|
|
11
10
|
<View
|
|
12
11
|
ref={ref}
|
|
13
12
|
className={classNames(
|
|
14
13
|
itemViewExposureSmartStyle['d-item-point-layout'],
|
|
15
14
|
className,
|
|
16
15
|
)}
|
|
17
16
|
{...otherProps}
|
|
18
17
|
>
|
|
19
18
|
{children ? children : null}
|
|
20
19
|
{checkReportDataState && (
|
|
21
20
|
<ExposureSmart
|
|
22
21
|
className={classNames(pointClassName,{
|
|
23
22
|
[itemViewExposureSmartStyle['d-item-chart-point']]: isChartH5,
|
|
24
23
|
})}
|
|
25
24
|
reportData={reportData}
|
|
26
25
|
trackCallback={trackCallback}
|
|
27
26
|
customReportDataFn={customReportDataFn}
|
|
28
27
|
customReportDataKey={customReportDataKey}
|
|
29
28
|
markPoint
|
|
30
29
|
/>
|
|
31
30
|
)}
|
|
32
31
|
</View>
|
|
33
32
|
)
|
|
34
33
|
reportData: [],
|
|
35
34
|
customReportDataKey: null,
|
|
36
35
|
customReportDataFn: null
|
|
36
|
+
import React, { useRef } from 'react';
|
|
37
37
|
const {
|
|
38
38
|
className,
|
|
39
39
|
pointClassName,
|
|
40
40
|
children,
|
|
41
41
|
reportData,
|
|
42
42
|
customReportDataKey,
|
|
43
43
|
customReportDataFn,
|
|
44
44
|
trackCallback,
|
|
45
45
|
...otherProps
|
|
46
46
|
} = props;
|
|
47
47
|
const itemViewExposureRef = useRef(null);
|
|
48
48
|
const isCustomReport = customReportDataKey && customReportDataFn;
|
|
49
49
|
const checkReportData = Array.isArray(reportData);
|
|
50
50
|
const [floorData, mInfo] = checkReportData ? reportData : [];
|
|
51
51
|
const checkReportDataState = isCustomReport ? true : floorData && mInfo;
|
|
52
52
|
|
|
53
53
|
floorData && mInfo && !mInfo.hasOwnProperty('pos') && (mInfo.pos = 0);
|
|
54
54
|
return (
|
|
55
55
|
<View
|
|
56
56
|
ref={itemViewExposureRef}
|
|
57
57
|
className={classNames(itemViewExposureSmartStyle['d-item-point-layout'], className)}
|
|
58
58
|
{...otherProps}
|
|
59
59
|
>
|
|
60
60
|
{children ? children : null}
|
|
61
61
|
{checkReportDataState && (
|
|
62
62
|
<ExposureSmart
|
|
63
63
|
className={classNames(pointClassName, {
|
|
64
64
|
[itemViewExposureSmartStyle['d-item-chart-point']]: isChartH5,
|
|
65
65
|
})}
|
|
66
66
|
innerRef={itemViewExposureRef}
|
|
67
67
|
reportData={reportData}
|
|
68
68
|
trackCallback={trackCallback}
|
|
69
69
|
customReportDataFn={customReportDataFn}
|
|
70
70
|
customReportDataKey={customReportDataKey}
|
|
71
71
|
markPoint
|
|
72
72
|
/>
|
|
73
73
|
)}
|
|
74
74
|
</View>
|
|
75
75
|
);
|
|
76
76
|
reportData: [],
|
|
77
77
|
customReportDataKey: null,
|
|
78
78
|
customReportDataFn: null,
|
|
79
79
|
customReportDataForMapFn: null,
|