Commit f124542a authored by 熊成伟's avatar 熊成伟

debug

parent c36fc4a1
This diff is collapsed.
...@@ -4,7 +4,8 @@ import TodoCard from '../../components/LogCard' ...@@ -4,7 +4,8 @@ import TodoCard from '../../components/LogCard'
import TopSearch from '../../components/TopSearch' import TopSearch from '../../components/TopSearch'
const Backlog = (props) => { const Backlog = (props) => {
const [current, setCurrent] = useState() const [current, setCurrent] = useState(1);
const [searchWord, setSearchWord] = useState()
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
...@@ -13,6 +14,13 @@ const Backlog = (props) => { ...@@ -13,6 +14,13 @@ const Backlog = (props) => {
const checkLog = () => { const checkLog = () => {
props.history.push(`/blank/info/example/1`) props.history.push(`/blank/info/example/1`)
}; };
const getData = () => {
setLoading(false)
const pageMap ={searchWord, nowPage: current, pageSize: 10}
let result = data.concat([{}, {}, {}, {}, {}, {}])
setData(result)
setCurrent(current + 1)
};
//下拉加载 //下拉加载
const handleScroll = () => { const handleScroll = () => {
...@@ -20,15 +28,19 @@ const Backlog = (props) => { ...@@ -20,15 +28,19 @@ const Backlog = (props) => {
const top = event.scrollTop; const top = event.scrollTop;
const scrollHeight = event.scrollHeight; const scrollHeight = event.scrollHeight;
const clientHeight = event.clientHeight; const clientHeight = event.clientHeight;
console.log(top, scrollHeight, clientHeight);
if (top + clientHeight === scrollHeight) { if (top + clientHeight === scrollHeight) {
setData([...data, {}, {}, {}, {}, {}, {}]) setLoading(true);
// setCurrent(current + 1) getData()
} }
}; };
useEffect(() => { useEffect(() => {
window.addEventListener('scroll', handleScroll, true); window.addEventListener('scroll', handleScroll, true);
return () => window.removeEventListener('scroll', handleScroll, true); return () => window.removeEventListener('scroll', handleScroll, true);
}, [data]);
useEffect(() => {
const element = document.getElementById('common-content')
element.scrollTo(0, 0)
}, []) }, [])
return ( return (
...@@ -39,7 +51,7 @@ const Backlog = (props) => { ...@@ -39,7 +51,7 @@ const Backlog = (props) => {
animating={loading} animating={loading}
/> />
<WhiteSpace/> <WhiteSpace/>
<TopSearch onSearch={val => console.log(val)}/> <TopSearch onSearch={setSearchWord}/>
{ {
data.map((item, index) => ( data.map((item, index) => (
<div key={index}> <div key={index}>
......
import React, {useState} from 'react'; import React, {useEffect, useState} from 'react';
import {ActivityIndicator, WhiteSpace, WingBlank} from 'antd-mobile' import {ActivityIndicator, WhiteSpace, WingBlank} from 'antd-mobile'
import TodoCard from '../../components/LogCard' import TodoCard from '../../components/LogCard'
import TopNotice from '../../components/NoticeTab' import TopNotice from '../../components/NoticeTab'
const Notice = (props) => { const Notice = (props) => {
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false);
const [current, setCurrent] = useState(1);
const [searchWord, setSearchWord] = useState()
const [data, setData] = useState([{},{},{},{},{},{}]);
const getData = () => {
setLoading(false)
const pageMap ={searchWord, nowPage: current, pageSize: 10}
let result = data.concat([{}, {}, {}, {}, {}, {}])
setData(result)
setCurrent(current + 1)
};
//下拉加载
const handleScroll = () => {
const event = document.getElementById("common-content")
const top = event.scrollTop;
const scrollHeight = event.scrollHeight;
const clientHeight = event.clientHeight;
if (top + clientHeight === scrollHeight) {
setLoading(true);
getData()
}
};
useEffect(() => {
window.addEventListener('scroll', handleScroll, true);
return () => window.removeEventListener('scroll', handleScroll, true);
}, [data]);
const checkLog = () => {
props.history.push(`/blank/info/example/1`)
};
return ( return (
<WingBlank> <WingBlank>
<ActivityIndicator <ActivityIndicator
...@@ -15,8 +46,15 @@ const Notice = (props) => { ...@@ -15,8 +46,15 @@ const Notice = (props) => {
/> />
<WhiteSpace/> <WhiteSpace/>
<TopNotice/> <TopNotice/>
{
data.map((item, index) => (
<div key={index}>
<WhiteSpace/> <WhiteSpace/>
<TodoCard/> <TodoCard data={item} onClick={checkLog}/>
</div>
))
}
</WingBlank> </WingBlank>
); );
}; };
......
...@@ -31,21 +31,6 @@ const Work = () => { ...@@ -31,21 +31,6 @@ const Work = () => {
// index > -1 && arr.splice(index, 1); // index > -1 && arr.splice(index, 1);
}; };
//测试数据
const data222 = Array.from(new Array(7)).map((_val, i) => ({
id: `name${i}`,
icon: '/img/test/test.png',
text: `name${i}`,
}));
const data22222 = Array.from(new Array(7)).map((_val, i) => ({
id: `name2${i}`,
icon: '/img/test/test-1.png',
text: `name${i}`,
}));
console.log(data);
return ( return (
<WingBlank> <WingBlank>
<ActivityIndicator <ActivityIndicator
...@@ -56,15 +41,6 @@ const Work = () => { ...@@ -56,15 +41,6 @@ const Work = () => {
<WhiteSpace/> <WhiteSpace/>
<TopSearch onSearch={ workSearch }/> <TopSearch onSearch={ workSearch }/>
<WhiteSpace/> <WhiteSpace/>
<WorkCard
type="edit"
title="常用板块"
addCommon={ commonEdit }
addStatus={addStatus}
data={data222}
iconAction={ itemSlice }
/>
<WhiteSpace/>
<WorkCard <WorkCard
title="事物管理" title="事物管理"
addCommon={ commonEdit } addCommon={ commonEdit }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment