Skip to content

Commit

Permalink
add cd redux & todo
Browse files Browse the repository at this point in the history
  • Loading branch information
necfol committed Jul 1, 2017
1 parent cbde70b commit 8b39884
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
44 changes: 23 additions & 21 deletions src/action/cd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,35 @@ const fixHttp = (arr) => {
}
export const cd = (result) => {
return {
type: RankType.GET_CD,
type: CdType.GET_CD,
result
};
};

export const getcd = (id) => {
console.log('================')
return (dispatch) => {
axios.get('https://127.0.0.1:3838/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg', {
params: {
g_tk:5381,
uin:0,
format:'jsonp',
inCharset:'utf-8',
outCharset:'utf-8',
notice:0,
platform:'h5',
needNewCode:1,
new_format:1,
pic:500,
disstid:id,
type:1,
json:1,
utf8:1,
onlysong:0,
nosign:1,
_:new Date().getTime()
}
console.log('111111111111')
axios.get('http://127.0.0.1:3838/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg', {
params: {
g_tk:5381,
uin:0,
format:'jsonp',
inCharset:'utf-8',
outCharset:'utf-8',
notice:0,
platform:'h5',
needNewCode:1,
new_format:1,
pic:500,
disstid:id,
type:1,
json:1,
utf8:1,
onlysong:0,
nosign:1,
_:new Date().getTime()
}
})
.then(function (response) {
console.log(response);
Expand Down
7 changes: 4 additions & 3 deletions src/container/Cd.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { NavigationActions } from 'react-navigation'
import LinearGradient from 'react-native-linear-gradient'
import MyNav from '../component/MyNav.js'
import MyStatusBar from '../component/MyStatusBar.js'
// import { getcd } from '../action/cd.js'
import { getcd } from '../action/cd.js'
const SCREEN_HEIGHT = Dimensions.get('window').height
const navigateAction = NavigationActions.back({
key: null
Expand All @@ -31,9 +31,9 @@ var styles = StyleSheet.create({
}
})
@connect(state => ({state}),
dispatch => ({
(dispatch, id) => ({
navGo: () => dispatch(navigateAction),
// getCd: () => dispatch(getcd)
getCd: (id) => dispatch(getcd)
})
)
export default class Cd extends Component {
Expand All @@ -49,6 +49,7 @@ export default class Cd extends Component {
})
}
componentDidMount() {
this.props.getCd(this.props.id)
console.log(this.props.id)
}
render() {
Expand Down
2 changes: 1 addition & 1 deletion src/container/SongList.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class SongList extends Component {
list.map((item, index) => {
item.imgurl = item.imgurl.replace(/http/i, 'https');
return(
<TouchableHighlight key={item.dissid} onPress={() => {this.props.navGo(1)}}>
<TouchableHighlight key={item.dissid} onPress={() => {this.props.navGo(item.dissid)}}>
<View style={styles.imageView}>
<Image resizeMode="contain" style={styles.image} source={{uri: item.imgurl}}></Image>
<View style={styles.numView}>
Expand Down
15 changes: 15 additions & 0 deletions src/reducer/cd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const initialState = {
cdList: []
};

const actionsMap = {
cd(state, action) {
return {...state, ...action.result}
}
};

export default (state = initialState, action) => {
const reduceFn = actionsMap[action.type];
if (!reduceFn) return state;
return reduceFn(state, action);
};
4 changes: 3 additions & 1 deletion src/reducer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { combineReducers } from 'redux';
import nav from './nav.js'
import recommend from './recommend.js'
import rank from './rank.js'
import cd from './cd.js'
const AppReducer = combineReducers({
nav,
recommend,
rank
rank,
cd
});

export default AppReducer;

0 comments on commit 8b39884

Please sign in to comment.