<template>
	<view class="calendar-page">
		
		<!-- 导航栏 -->
		<u-navbar bgColor="red">
			<view class="u-nav-slot" slot="left">
				<text class="text-bold text-xxl text-white"> {{ $t('schedule') }} </text>
			</view>
			<view class="u-nav-slot" slot="right"></view>
		</u-navbar>
		
		 <uni-calendar insert foldAble :selected="selected" @change="change" />
		 
		 <u-gap height="120"/>
		 <button class="cu-btn block bg-red margin-tb-sm lg radio" @click="uploadAction">
		 	<text> 上传 </text>
		 </button>
		 <button class="cu-btn block bg-red margin-tb-sm lg radio" @click="monitoringBtnClick">
		 	<text> 监控 </text>
		 </button>
		
	</view>
</template>

<script>
	import Api from '../../api/api.js'
	import UniCalendar from "../../components/uni-calendar/uni-calendar.vue"
	export default {
		components:{
			UniCalendar
		},
		data() {
			return {
				currentDate: '',
				show: false,
				mode: 'range',
				selected: [
					{date: '2022-01-05', info: '签到', data: { custom: '自定义信息', name: '自定义消息头' }},
					{date: '2022-01-09', info: '打卡', data: { custom: '自定义信息', name: '自定义消息头' }},
					{date: '2022-02-03', info: '打卡', data: { custom: '自定义信息', name: '自定义消息头' }},
				]
			}
		},
		onReady() {
			
		},
		mounted() {
			// let now = new Date()
			// let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(now)
			// let mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(now)
			// this.currentDate = `${ye}${mo}` /// 202201
			
			let now = new Date();
			var year = now.getFullYear()
			var month = now.getMonth()+1
			this.currentDate = `${year}${month}` /// 202201
			console.log(this.currentDate)
			
			this.getClassSchedule()
		},
		methods:{
			async getClassSchedule() {
				Api.classSchedule(this.currentDate).then(res=>{
					console.log(res)
				})
			},
			previousBtnDidClick(){
				console.log('previousBtnDidClick')
			},
			nextBtnDidClick(){
				console.log('nextBtnDidClick')
			},
			change(e) {
				console.log(e)
			},
			uploadAction() {
				uni.navigateTo({url: '../test/upload'})
			},
			monitoringBtnClick() {
				uni.navigateTo({
					url: '../launch/index'
				})
			}
		}
	}
</script>


<style scoped>
</style>