<template>
	<view class="pageBg">
		<view class="bgImg">
			<topNavbar title="学员详情"></topNavbar>
			<view class="pad" >
				<cardNav :navData="navData" :currentNav="currentNav" @changeNav="changeNav"></cardNav>
			</view>
			<scrollNav @changeTab="changeTab" :currentTab="currentTab" :tabData="tabData" v-if="currentNav==1"/>
		</view>

		<view class="pad">
			<view class="con" v-if="currentNav==1">
				<list :list="list"></list>
			</view>
			<view class="con" v-else>
				<info :id="studentId" />
			</view>
		</view>
	</view>
</template>

<script>
	import list from './comp/list'
	import info from './comp/info'
	import {
		getStudentDynamics
	} from '@/config/api.js'
	export default {
		components: {
			list,
			info
		},
		data() {
			return {
				currentTab: 0,
				currentNav: 1,
				tabData: [{
						text: '全部',
						id: 0
					},
					{
						text: '科目一',
						id: 1
					},
					{
						text: '科目二',
						id: 2
					},
					{
						text: '科目三',
						id: 3
					},
					{
						text: '科目四',
						id: 4
					},
				],
				navData: [{
						text: '学车进展',
						id: 1
					},
					{
						text: '个人及报名信息',
						id: 2
					},
				],
				studentId: '',
				list: []
			}
		},
		onLoad(options) {
			this.studentId = options.id
			this.getStudentDynamicsFn()
		},
		methods: {
			async getStudentDynamicsFn() {
				let obj = {
					"studentId": this.studentId,
					"subject": this.currentTab,
					"coachId": this.vuex_coachId
				}
				if(obj.subject==0) delete obj.subject
				const {
					data: res
				} = await getStudentDynamics(obj)
				console.log(res)
				this.list = res
			},
			changeTab(id) {
				this.currentTab = id
				this.getStudentDynamicsFn()
			},
			changeNav(id) {
				this.currentNav = id
			}
		}
	}
</script>

<style lang="scss" scoped>
.bgImg  {
	padding-bottom: 1rpx;
}
.con {
	margin-top: 20rpx;
}
</style>