import { AlbumActionTypes } from '../types' ; import { getRecommendListDetailRequest } from './services' ; export const changeCurrentAlbum = ( data ) => ( { type : AlbumActionTypes . CHANGE_CURRENT_ALBUM , data , } ) ; export const changePullUpLoading = ( data ) => ( { type : AlbumActionTypes . CHANGE_PULL_UP_LOADING , data , } ) ; export const changeLoading = ( data ) => ( { type : AlbumActionTypes . CHANGE_LOADING , data , } ) ; export const getAlbumList = ( id , fromURL ) => { let request ; switch ( fromURL ) { case '/recommend' : request = getRecommendListDetailRequest ; break ; case '/rank' : break ; default : request = getRecommendListDetailRequest ; } return ( dispatch ) => { dispatch ( changeLoading ( true ) ) ; request ( id ) . then ( ( res ) => { dispatch ( changeLoading ( false ) ) ; let data = res . playlist ; console . log ( 'data' , data ) ; dispatch ( changeCurrentAlbum ( data ) ) ; } ) . catch ( ( ) => { console . log ( '获取album数据失败!' ) ; } ) ; } ; } ;