<template>
	<view class="pageBgImg">
		<view class="pad">
			<view class="status_bar"></view>
			<view class="" style="height: 100rpx;"></view>
			<!-- <u-button @click="requestSingleFreshLocationFn">单次定位</u-button> -->
			<!-- <u-button @click="getInitFaceVerifyFn">人脸核身</u-button> -->
			<topInfo :carType="curObject" @changeSubject="changeSubject" :dynamics="subjectStatus.studentClassHourVO"></topInfo>
			<view class="" v-if="token">
				<subject1 v-if="curObject.id==1" :subjectStatus="subjectStatus"></subject1>
				<subject2 v-if="curObject.id==2" :subjectStatus="subjectStatus"></subject2>
				<subject3 v-if="curObject.id==3" :subjectStatus="subjectStatus"></subject3>
				<subject4 v-if="curObject.id==4" :subjectStatus="subjectStatus"></subject4>
			</view>
		</view>
	</view>
</template>

<script>
	import topInfo from './comp/topInfo.vue'
	import subject1 from './comp/subject1.vue'
	import subject2 from './comp/subject2.vue'
	import subject3 from './comp/subject3.vue'
	import subject4 from './comp/subject4.vue'
	import {  getStudentSubject1Status, getStudentSubject2Status, getStudentSubject3Status, getStudentSubject4Status, getStudentProcess } from '@/config/api.js'
	export default {
		components: { topInfo, subject1, subject2,subject3,subject4 },
		data() {
			return {
				curObject: {
					name: '科目一',
					id: 1,
				},
				dynamics: {},
				subjectStatus: {
					studentClassHourVO: {}
				},
				token: ''
			}
		},
		onPullDownRefresh() {
			this.init()
		},
		onLoad() {
			
		},
		onShow() {
			this.init()
			// this.getStudentProcessFn()
		},
		methods: {
			init() {
				this.token = this.$store.state.user.vuex_loginInfo.accessToken
				if(!this.token) return this.$u.toast('请先登录')
				this.getStudentSubject1StatusFn()
			},
			// 切换科目
			changeSubject(val) {
				if(this.curObject==val) return
				this.curObject = val
				this.init()
			},
			
			async requestSingleFreshLocationFn() {
				await this.$store.dispatch('getCity')
			},
			async getStudentSubject1StatusFn() {
				let arrFn = [getStudentSubject1Status, getStudentSubject2Status, getStudentSubject3Status, getStudentSubject4Status]
				const {data: res} = await arrFn[this.curObject.id-1]({studentId: this.studentId})
				this.subjectStatus = res
				console.log(res)
				// console.log(this.subjectStatus.studentClassHourVO)
			},
			// async getStudentProcessFn() {
			// 	const {data: res} = await getStudentProcess({studentId: this.studentId})
			// 	let obj = {
			// 		ValidTtime: res.subjectOneValidTtime,
			// 		TotalTime: res.subjectOneTotalTime
			// 	}
			// 	if(this.curObject.id==2) {
			// 		obj.ValidTtime = res.subjectTwoValidTtime
			// 		obj.TotalTime = res.subjectTwoTotalTime
			// 	}else if(this.curObject.id==3) {
			// 		obj.ValidTtime = res.subjectThreeValidTtime
			// 		obj.TotalTime = res.subjectThreeTotalTime
			// 	}else if(this.curObject.id==4) {
			// 		obj.ValidTtime = res.subjectFourValidTtime
			// 		obj.TotalTime = res.subjectFourTotalTime
			// 	}
			// 	this.dynamics = obj
			// }
		}
	}
</script>

<style scoped lang="scss">
	
</style>