Commit 19710804 by 王树冬

init

parent 4c85e978
......@@ -4,7 +4,7 @@
"description": "demo",
"appid": "wx8566afef50e5f76b",
"setting": {
"urlCheck": false,
"urlCheck": true,
"es6": false,
"postcss": false,
"minified": false,
......
......@@ -79,7 +79,11 @@ export function asyncAdd() {
// 'content-type': 'application/json'
// }
// }))
export const list = createApiAction(LIST, params => api.get('news/list', params))
// export const list = createApiAction(LIST, params => api.get('news/list', params))
export const list = createApiAction(LIST, params => {
console.log('list',params);
return api.get('news/list', params)
})
export default bindActionCreators({
list,
......
......@@ -27,14 +27,11 @@ import './index.styl'
state => ({
list: state.counter.list,
}),
(dispatch) => {
console.log('dispatch', dispatch);
return {
list() {
dispatch(list())
}
(dispatch) => ({
getList(params) {
dispatch(list(params))
}
},
})
)
class Index extends Component {
......@@ -45,53 +42,69 @@ class Index extends Component {
super(props)
console.log('props', props);
// this.state = { date: new Date() }
props.list()
// let params = {
// page: 2, perPage: 2
// }
this.state = {
page: 1, perPage: 10
}
props.getList(this.state)
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentWillMount() {
this.props.getList(this.state)
}
componentWillUnmount() {
}
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View className='index'>
<View className='news'>
<View className='item'>
<View className='desc'>
<View className='title'></View>
<View className='info'></View>
</View>
<View className='rightImage'>
</View>
</View>
<View>
{
this.props.list.map((item, index) => {
return <View className='item' key={index}>
<View className='info'>
<View className='title'>{item.title}</View>
<View className='footer'>
<View className='user'>{item.username}</View>
<View className='comment'>{item.username}</View>
</View>
</View>
<View className='rightImage'><Image calssName='img' src={item.image_url} /></View>
</View>
})
}
</View>
</View>
</View >
)
onShareAppMessage () {
return {
title: '蜂窝煤',
path: '/pages/index/index',
imageUrl: '../../common/image/share.png'
}
}
onReachBottom() {
console.log('触发到底部了')
this.setState({
page: this.state.page + 1
})
const { page, perPage } = this.state
let params = {
page: this.state.page + 1, perPage: perPage
}
console.log(this.props, 'onReachBottom')
this.props.getList(params)
}
render() {
return (
<View className='index'>
<View className='news'>
{
this.props.list.map((item, index) => {
return <View className='item' key={index}>
<View className='info'>
<View className='title'>{item.title}</View>
<View className='footer'>
<View className='user'>{item.username}</View>
<View className='comment'>{item.username}</View>
</View>
</View>
<View className='rightImage'><Image calssName='img' src={item.image_url} /></View>
</View>
})
}
</View>
</View >
)
}
}
export default Index
......@@ -2,7 +2,7 @@ import { ADD, MINUS, LIST } from '../constants/counter'
const INITIAL_STATE = {
num: 0,
list:''
list:[]
}
export default function counter (state = INITIAL_STATE, action) {
......@@ -19,9 +19,14 @@ export default function counter (state = INITIAL_STATE, action) {
num: state.num - 1
}
case LIST:
let data = state.list.concat(action.payload.data.news)
// Object.assign(state.list, action.payload.data.news)
console.log('data',data)
console.log('state',state)
return {
...state,
list: action.payload.data.news
// list: action.payload.data.news
list: data
}
default:
return state
......
......@@ -3,7 +3,7 @@ import { HTTP_STATUS, COMMON_STATUS, RESULT_STATUS } from '../const/status.js'
// import config from '../config/index.js'
import { logError } from '../utils'
const baseURL = "http://beeapi.shudong.wang/v1/"
const baseURL = "https://shudong.wang/v1/"
// Taro.request({
// url: baseURL + '',
// data: {
......@@ -21,6 +21,7 @@ export default {
let { url, data } = params
// let token = getApp().globalData.token
// if (!token) login()
console.log('params', params)
let contentType = 'application/x-www-form-urlencoded'
contentType = params.contentType || contentType
const option = {
......@@ -41,6 +42,7 @@ export default {
},
get(url, data = '') {
let option = { url, data }
console.log('data', data)
return this.baseOptions(option)
},
post: function (url, data, contentType) {
......
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