actions.js 643 Bytes
Newer Older
xuzhenghua committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
import {api, getParam, http} from "@/utils";

export const RECEIVE_COURSES_DETAIL = 'RECEIVE_COURSES_DETAIL'
export const receiveCourseDetail = payload => ({
    type: RECEIVE_COURSES_DETAIL,
    payload
})

export const fetchCoursesListIfNeeded = () => (dispatch, getState) => {
    dispatch(getCourses({
        courseInfo: getState().detailInfo
    }))
}
export const getCourses = payload => dispatch => {
    return http.get(`${api.home}/m/course/detail/${getParam('id')}`,).then((res) => {
        if (res.data.code === 200) {
            dispatch(receiveCourseDetail({
                ...res.data.data
            }))
        }
    })
}