/** * Created by FANGlh on 2018/11/12 15:34. */ import React,{Component} from 'react'; import './ClassSchedule.css'; import line_img from '../../../style/imgs/line_img.png'; import {fetchPost,fetchGet,fetchGetNoSession} from '../../../utils/fetchRequest'; import {API} from '../../../configs/api.config'; import {Toast} from 'antd-mobile'; import moment from 'moment' import {connect} from 'react-redux'; import hi0_img from '../../../style/imgs/ic_head1.png'; function HSItem(props) { return(
{moment(props.itemdata.curStartTime).format('HH:mm')}–{moment(props.itemdata.curEndTime).format('HH:mm')}
{props.itemdata.curName}
{props.itemdata.userName}
{/**/}
) } class ClassSchedule extends Component{ constructor(){ super(); this.state = { curDay:new Date().getDay(), classData:{ monday:[], tuesday:[], wednesday:[], thursday:[], friday:[], saturday:[], sunday:[] }, curDayData:[], Class_SchData:[1,2,3,4], CurDay:2 } } render(){ return(
{/*
11月12日,2018年
*/}
{/*
上午
*/}

{this.state.curWeek}

{this.state.curDayData.map((itemdata,index) => )}
{/*
*/} {/*
下午
*/} {/*
*/} {/*
*/} {/*{this.state.Class_SchData.map((itemata,index) => )}*/} {/*
*/} {/*
*/}
) } selectDayClick = (value)=>{ console.log("value",value) var Cdata = null if(value == 1){ Cdata = this.state.classData.monday }else if(value == 2){ Cdata = this.state.classData.tuesday }else if(value == 3){ Cdata = this.state.classData.wednesday }else if(value == 4){ Cdata = this.state.classData.thursday }else if(value == 5){ Cdata = this.state.classData.friday } this.setState({ CurDay:value, curDayData:Cdata },function (){ console.log("curDayData",this.state.curDayData) }) } componentWillMount() { document.title = '课表查询' } componentDidMount() { fetchGet(API.curriculumListByStuId,{ // stuId:this.props.userInfo.stuId, stuId:10003, curStatus:1 },{}).then((response)=>{ if(response.success && response.data){ this.setState({ classData:response.data }) this.selectDayClick(this.state.curDay) } }).catch((error) =>{ console.log('error',error) if (typeof error === 'string') { Toast.fail(error, 2) } else { Toast.fail('请求异常', 2) } }) } } let mapStateToProps = (state) => ({ userInfo: {...state.redUserInfo} }) let mapDispatchToProps = (dispatch) => ({}) export default connect(mapStateToProps, mapDispatchToProps)(ClassSchedule)