统计页面返回值会叠加及返回值会换成在另外一个课堂数据不对的情况

video_transcode
dinglink 5 years ago
parent 29ea294271
commit 760c2edfdd

@ -23,7 +23,7 @@ const App = (props) => {
total,
staticList,
changeParams,
initTotal
initTotal,
} = props;
// const [datas, setDatas] = useState([]);
// const [sortedInfo, setSortedInfo] = useState({});
@ -212,7 +212,8 @@ const App = (props) => {
sorter: (a, b) => a.cost_time - b.cost_time
}
];
useEffect(() => {
changeParams({
page: 1
@ -224,6 +225,7 @@ const App = (props) => {
pathId && staticList(pathId);
}
// const {
// study_count,
// course_study_count,
@ -249,7 +251,6 @@ const App = (props) => {
// 恢复初始值
changeParams(params);
initTotal();
console.log(staticList)
pathId && staticList(pathId);
}
@ -335,8 +336,9 @@ const mapStateToProps = (state) => {
return {
subject_info,
other_info,
total
total,
}
};
const mapDispatchToProps = (dispatch) => ({

@ -12,13 +12,15 @@ import { fetchStaticList } from "../../services/staticService";
export const staticList = (id) => {
return (dispatch, getState) => {
const { params, total_count, other_info } = getState().staticReducer;
if (other_info.length===20||total_count !== 0 && total_count === other_info.length) return;
// console.log('统计数据=====>>>>>', params);
// if (total_count !== 0 && total_count === other_info.length) return;
fetchStaticList(id, params).then(res => {
// console.log('统计数据=====>>>>>', res);
const {data} = res;
if (data.status === 0) {
dispatch({
type: types.GET_STATIC_INFO,
other_info:data.data.other_info,
payload: data.data
});
}

@ -38,12 +38,14 @@ const initalState = {
const staticReducer = (state = initalState, action) => {
const { payload = {}, type } = action;
const {subject_info, other_info = [], total = {}, total_count} = payload;
switch (type) {
case types.GET_STATIC_INFO:
return {
...state,
subject_info,
other_info: state.other_info.concat(other_info),
other_info,
// other_info: state.other_info.concat(other_info),
total,
total_count,
params: Object.assign({}, state.params, { page: state.params.page + 1 })

Loading…
Cancel
Save