yapi/client/containers/News/News.js

78 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-07-17 12:15:21 +08:00
import './News.scss'
import React, { Component } from 'react'
import NewsTimeline from './NewsTimeline/NewsTimeline'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
2017-08-09 16:08:37 +08:00
import Breadcrumb from '../../components/Breadcrumb/Breadcrumb'
import { Button } from 'antd'
2017-08-09 18:00:45 +08:00
import { getMockUrl } from '../../reducer/modules/news.js'
2017-08-10 12:13:32 +08:00
import Subnav from '../../components/Subnav/Subnav.js';
2017-07-17 12:15:21 +08:00
@connect(
state => {
2017-08-09 16:08:37 +08:00
console.log(state);
2017-07-17 12:15:21 +08:00
return {
2017-08-10 21:20:57 +08:00
uid: state.user.uid + ''
2017-07-17 12:15:21 +08:00
}
},
{
2017-08-09 18:00:45 +08:00
getMockUrl: getMockUrl
2017-07-17 12:15:21 +08:00
}
)
class News extends Component {
constructor(props) {
2017-08-09 18:00:45 +08:00
super(props);
this.state = {
mockURL:""
}
2017-07-17 12:15:21 +08:00
}
static propTypes = {
2017-08-09 18:00:45 +08:00
uid: PropTypes.string,
getMockUrl: PropTypes.func
}
componentWillMount(){
const that = this;
this.props.getMockUrl(2724).then(function(data){
const { prd_host, basepath, protocol } = data.payload.data.data;
const mockURL = `${protocol}://${prd_host}${basepath}/{path}`;
that.setState({
mockURL: mockURL
})
})
2017-07-20 16:30:55 +08:00
}
2017-07-17 12:15:21 +08:00
render () {
return (
2017-08-10 12:13:32 +08:00
<div>
<Subnav
default={'动态'}
data={[{
name: '动态',
path: '/news'
}, {
name: '测试',
path: '/follow'
}, {
name: '设置',
path: '/follow'
}]}/>
<div className="g-row">
<section className="news-box">
<div className="logHead">
<Breadcrumb />
<div className="Mockurl">
<span>Mock地址</span>
<p>{this.state.mockURL}</p>
<Button type="primary">下载Mock数据</Button>
</div>
</div>
<NewsTimeline/>
</section>
2017-08-09 16:08:37 +08:00
</div>
2017-08-10 12:13:32 +08:00
</div>
2017-07-17 12:15:21 +08:00
)
}
}
export default News