Skip to content

Commit 133521b

Browse files
febobofebobo
authored andcommitted
add webfare page
1 parent bb808fa commit 133521b

File tree

10 files changed

+80
-13
lines changed

10 files changed

+80
-13
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react-native-refreshable-listview": "^2.0.0-beta4",
2222
"react-native-tab-navigator": "^0.3.2",
2323
"react-native-vector-icons": "^2.0.2",
24+
"react-native-video": "^0.8.0",
2425
"react-redux": "^4.4.5",
2526
"redux": "^3.5.2",
2627
"redux-actions": "^0.10.0",

src/actions/ActionTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export const REPLY_TOPIC = 'REPLY_TOPIC'; // 评论
88
export const UPS_TOPIC = 'UPS_TOPIC'; // topic 点赞
99
export const GET_TOPIC_DETAIL = 'GET_TOPIC_DETAIL'; // 获取文章详情
1010
export const UP_REPLY = 'UP_REPLY'; // 评论点赞
11-
export const GET_PHOTO = 'GET_PHOTO'; // 评论点赞
11+
export const GET_PHOTO = 'GET_PHOTO'; // 照片列表
12+
export const GET_VIDEO = 'GET_VIDEO'; // 视频列表

src/actions/WelfareActions.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as types from './actionTypes';
2+
import * as welfareService from '../service/welfareService';
3+
import {createAction} from 'redux-actions';
4+
5+
export const getVideo = createAction(types.GET_VIDEO , welfareService.getVideo , ({
6+
page,
7+
limit
8+
} , resolved , rejected) => {
9+
resolved && resolved();
10+
})

src/actions/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as TabActions from './TabActions'
55
import * as UtilsActions from './UtilsActions'
66
import * as CommentActions from './CommentActions'
77
import * as ActicleActions from './ActicleActions'
8+
import * as WelfareActions from './WelfareActions'
89

910
export default {
1011
...DetailActions,
@@ -13,5 +14,6 @@ export default {
1314
...UserActions,
1415
...UtilsActions,
1516
...CommentActions,
16-
...ActicleActions
17+
...ActicleActions,
18+
...WelfareActions
1719
}

src/container/tabview.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ import Icon from 'react-native-vector-icons/Ionicons';
1616
const myIcon = (<Icon name="ios-time" size={30} color="#900" />)
1717
import * as EssencePage from '../page/Essence';
1818
import * as ArticlePage from '../page/Article';
19-
import Welfare from '../page/Welfare';
19+
import * as WelfarePage from '../page/Welfare';
2020
import * as Login from '../page/Login';
2121
import connectComponent from '../utils/connectComponent';
2222
import TabNavigator from 'react-native-tab-navigator';
2323
import iconHome from '../public/favicon.png';
2424
const Essence = connectComponent(EssencePage);
2525
const Article = connectComponent(ArticlePage);
26+
const Welfare = connectComponent(WelfarePage);
2627

2728
export default class TabView extends Component {
2829
constructor (props){
@@ -167,8 +168,6 @@ export default class TabView extends Component {
167168
}
168169
}
169170
render(){
170-
console.log(222)
171-
172171
return(
173172
<View style={{flex:1}}>
174173
{this.renderTabber()}

src/page/Welfare.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@ import {
66
StyleSheet
77
} from 'react-native';
88

9-
export default class Welfare extends Component {
9+
class Welfare extends Component {
1010
constructor (props){
1111
super(props);
1212
}
1313

14+
componentWillMount (){
15+
console.log(this)
16+
const { actions , Welfare } = this.props;
17+
actions.getVideo({
18+
page : Welfare.page,
19+
limit: Welfare.limit
20+
})
21+
}
22+
1423
render (){
1524
return (
1625
<View style={[styles.container]}>
17-
<Text style={{fontSize:30,color:'#fff'}}>Hello React-native</Text>
1826
</View>
1927
)
2028
}
@@ -23,8 +31,12 @@ export default class Welfare extends Component {
2331
const styles = StyleSheet.create({
2432
container : {
2533
flex : 1,
26-
alignItems : 'center',
27-
justifyContent : 'center',
28-
backgroundColor : '#730'
2934
}
3035
})
36+
37+
export const LayoutComponent = Welfare;
38+
export function mapStateToProps(state){
39+
return {
40+
Welfare : state.Welfare,
41+
}
42+
}

src/reducers/Acticle.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as types from '../actions/actionTypes';
33

44
export default function Acticle (state={page:1,limit:10,photos:[]} , action={}){
55
const { payload } = action;
6-
console.log(action,'action')
76
switch (action.type) {
87
case types.GET_PHOTO:
98
return Object.assign(

src/reducers/Welfare.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as types from '../actions/actionTypes';
2+
3+
export default function Welfare (state={page:1,limit:10,videos:[]} , action={}){
4+
const { payload } = action;
5+
console.log(state,9999)
6+
switch (action.type) {
7+
case types.GET_VIDEO:
8+
return Object.assign(
9+
{} , state , {
10+
videos : state.videos.concat(payload.list),
11+
page : payload.params.page,
12+
limit : payload.params.limit
13+
}
14+
)
15+
break;
16+
default:
17+
return state;
18+
}
19+
}

src/reducers/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import Comment from './Comment'
55
import User from './User'
66
import Utils from './Utils'
77
import Acticle from './Acticle'
8-
8+
import Welfare from './Welfare'
99
export {
1010
Essence,
1111
Tab,
1212
Detail,
1313
Comment,
1414
User,
1515
Utils,
16-
Acticle
16+
Acticle,
17+
Welfare
1718
}

src/service/welfareService.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as requestService from './requestService';
2+
import config from '../config'
3+
const urlPrefix = config.spDomain;
4+
export function getVideo({page,limit}){
5+
6+
console.log(page,limit)
7+
let url = `${urlPrefix}&type=41&limit=${limit}&page=${page}`;
8+
// let url = `${urlPrefix}`;
9+
return requestService.get(url,true).then( data =>{
10+
if(!data.showapi_res_error){
11+
return {
12+
list : data.showapi_res_body.pagebean.contentlist,
13+
params : {
14+
page,
15+
limit
16+
}
17+
}
18+
// return data.showapi_res_body.newslist
19+
}else{
20+
throw 'do getPhoto failed'
21+
}
22+
})
23+
}

0 commit comments

Comments
 (0)