From e3203083937dcfd2da3e01ea0a04b4b6aaf22b10 Mon Sep 17 00:00:00 2001 From: qitmac000249 Date: Mon, 24 Jul 2017 16:41:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9footer=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/actions/news.js | 37 ++++++++++--------- client/components/Footer/Footer.scss | 2 +- client/containers/News/News.js | 9 ++++- client/containers/News/NewsList/NewsList.js | 8 +++- .../News/NewsTimeline/NewsTimeline.js | 2 +- client/reducer/news/news.js | 1 + 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/client/actions/news.js b/client/actions/news.js index 5f2aef91..24a1fcb6 100644 --- a/client/actions/news.js +++ b/client/actions/news.js @@ -3,25 +3,28 @@ import { FETCH_MORE_NEWS } from '../constants/action-types.js'; -export function fetchNewsData (logId) { - const data = { - newsList:[ - { key: 1,title: '日志标题', username: 'John Brown', content: '您好!亲爱的用户:您已成功申请接口:实时空气质量数据查询,请于两个月内进行应用验证,逾期接口将不能正常使用。如果您在使用的过程中遇到任何问题,欢迎前往交流社区反馈意见,谢谢!',time: '2014-12-01' }, - { key: 2,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }, - { key: 3,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' } - ], - totalPage: 34 - }; - console.log(logId); +import axios from 'axios'; +import variable from '../constants/variable'; + +export function fetchNewsData (uid,page,limit) { + // const data = { + // newsList:[ + // { key: 1,title: '日志标题', username: 'John Brown', content: '您好!亲爱的用户:您已成功申请接口:实时空气质量数据查询,请于两个月内进行应用验证,逾期接口将不能正常使用。如果您在使用的过程中遇到任何问题,欢迎前往交流社区反馈意见,谢谢!',time: '2014-12-01' }, + // { key: 2,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }, + // { key: 3,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' } + // ], + // totalPage: 34 + // }; + + const param = { + uid: uid, + page: page, + limit: variable.PAGE_LIMIT?variable.PAGE_LIMIT:limit + } + console.log(param); return { type: FETCH_NEWS_DATA, - payload: new Promise(function(reslove,reject){ - if(data){ - reslove(data); - }else{ - reject("chucuole"); - } - }) + payload: axios.get('/log/list',param) }; } diff --git a/client/components/Footer/Footer.scss b/client/components/Footer/Footer.scss index fb523204..d6a1ff70 100644 --- a/client/components/Footer/Footer.scss +++ b/client/components/Footer/Footer.scss @@ -2,7 +2,7 @@ .footer{ // max-width: 12rem; - margin: 20px auto; + margin: 0px auto; clear: both; font-size: 12px; background: #000c15; diff --git a/client/containers/News/News.js b/client/containers/News/News.js index 395cfbf3..df5bb797 100644 --- a/client/containers/News/News.js +++ b/client/containers/News/News.js @@ -10,6 +10,7 @@ import { fetchNewsData } from '../../actions/news.js' @connect( state => { return { + uid: state.user.curUid, newsData: state.news.newsData?state.news.newsData:[] } }, @@ -27,7 +28,8 @@ class News extends Component { } static propTypes = { newsData: PropTypes.object, - fetchNewsData: PropTypes.func + fetchNewsData: PropTypes.func, + uid: PropTypes.string } setLoading(bool){ this.setState({ @@ -35,7 +37,10 @@ class News extends Component { }) } componentWillMount(){ - this.props.fetchNewsData() + console.log(this.props.uid); + this.props.fetchNewsData(1,1,10).then(function(data){ + console.log(data); + }) } render () { const data = this.props.newsData diff --git a/client/containers/News/NewsList/NewsList.js b/client/containers/News/NewsList/NewsList.js index cd98bb8c..7123ac3c 100644 --- a/client/containers/News/NewsList/NewsList.js +++ b/client/containers/News/NewsList/NewsList.js @@ -18,7 +18,9 @@ const logList = [{ }]; @connect( state => { + // console.log(state); return { + uid: state.user.curUid, newsData: state.news.newsData } }, @@ -31,7 +33,8 @@ class NewsList extends Component { static propTypes = { fetchNewsData: PropTypes.func, - setLoading: PropTypes.func + setLoading: PropTypes.func, + uid: PropTypes.string } constructor(props) { @@ -48,7 +51,8 @@ class NewsList extends Component { }) const that = this; this.props.setLoading(true); - this.props.fetchNewsData(+e.key).then(function(){ + this.props.fetchNewsData(+this.props.uid,0,5).then(function(data){ + console.log(data.data); that.props.setLoading(false); }) } diff --git a/client/containers/News/NewsTimeline/NewsTimeline.js b/client/containers/News/NewsTimeline/NewsTimeline.js index 953bc55e..dcb8f255 100644 --- a/client/containers/News/NewsTimeline/NewsTimeline.js +++ b/client/containers/News/NewsTimeline/NewsTimeline.js @@ -57,7 +57,7 @@ class NewsTimeline extends Component {
- 清空消息 + 项目日志 { switch (action.type) { case FETCH_NEWS_DATA: { + // console.log(action.payload); return { ...state, newsData: action.payload