<template>
	<view class="center">
		<view class="text">
			<text>请假原因</text>
			<textarea  v-model="reason" maxlength="300"  focus placeholder="您为什么要请假呢？"></textarea>
		</view>
		<view class="buttom" @click="submit('/pages/course/success')">
			立即提交
		</view>
		<view class="jilv" @click="nav('/pages/leave/details')">
			申请记录
		</view>
	</view>
</template>

<script>
import { setLeave} from '@/api/course.js';
import { mapState, mapMutations } from 'vuex';
export default {
	computed: {
		...mapState(['hasLogin', 'userInfo', 'baseURL', 'urlFile'])
	},
	data(){
		return{
			id: '',
			ifyid: '',
			grade_id: '',
			subject_id: '',
			manage_admin: '',
			reason: ''
		}
	},
	onLoad(option) {
		if (this.hasLogin) {
			this.id = option.id;
			this.ifyid = option.ifyid;
			this.grade_id = option.grade_id;
			this.subject_id = option.subject_id
		}else{
				uni.showModal({
					title: '登录',
					content: '您未登录，是否马上登陆?',
					success: e => {
						console.log(e)
						if (e.confirm) {
							console.log("1111")
							interceptor();
						}
					},
					fail: e => {
						console.log(e);
					}
				});
				return;
			}
		
	},
	methods: {
		submit(url){
			setLeave({
				timetable_id: this.id,
				ifyid: this.ifyid,
				grade_id: this.grade_id,
				subject_id: this.subject_id,
				reason: this.reason,
				manage_admin:this.manage_admin
			}).then(() =>{
				uni.navigateTo({
					url: url
				})
			}).catch(err =>{
				console.log(err);
			})
		},
		nav(url){
			uni.navigateTo({
				url: url
			})
		}
	}
}
</script>

<style lang="scss">
	.text{
		position: relative;
		width: 90%;
		margin: 30rpx auto;
		height: 430rpx;
		font-size: 30rpx;
		font-weight: 500;
		color: #000000;
		.js{
			position: absolute;
			right: 50rpx;
			bottom: 24rpx;
			
		}
		textarea {
			height: 100%;
			width: 100%;
		}
	}
	.buttom {
		margin: 10rpx auto;
		width: 560rpx;
		height: 90rpx;
		background: #1CC7C7;
		border-radius: 45px;
		text-align: center;
		line-height: 90rpx;
		
	}
	.jilv {
		margin-top: 30rpx;
		text-align: center;
		color: #999999;
		font-size: 30rpx;
	}
</style>
