<template>
	<view class="container">
		<image class="cbg" :src="base.imgHost('book-bg.png')"></image>
		<view class="schoolmate btn">
			<image mode="widthFix" @click="toUrl(2)" :src="base.imgHost('book-schoolmate1.png')"></image>
			<!-- <view>加入我们</view> -->
		</view>
		<view class="book btn">
			<image mode="widthFix" @click="toUrl(1)" :src="base.imgHost('book-book1.png')"></image>
			<!-- <view>立即预约</view> -->
		</view>
		<tabbar :currentPage="2"></tabbar>
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar/tabbar.vue';
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				user: {},
				can_appointment: false,
				enter_schoolmate: 0,
				door_appointments: false, // 当前是否有预约
			}
		},
		onShareAppMessage() {
			return{
				title:"苏州科技商学院",
				imageUrl:"/static/share.jpg"
			}
		},
		onShareTimeline() {
			return{
				title:"苏州科技商学院",
				imageUrl:"/static/share.jpg"
			}
		},
		onShow() {
			this.getUser()
		},
		onLoad() {
		},
		methods: {
			getUser() {
				this.$u.api.user().then(res => {
					console.log("res", res)
					this.enter_schoolmate = res.enter_schoolmate
					if (res.user.appointment_total - res.user.pass_appointments > 0) {
						this.can_appointment = true
					} else {
						this.can_appointment = false
					}
					// this.door_appointments = res.door_appointments ? true : false
					this.$u.vuex('vuex_user', res.user)
				})
			},
			async toUrl(type) {
				if (type === 1) {
					uni.navigateTo({
						url: '/packages/booksubmit/appointment'
					})
					// await this.$u.api.user().then(res => {
					// 	if (res.user.appointment_total - res.user.pass_appointments > 0) {
					// 		this.can_appointment = true
					// 		uni.navigateTo({
					// 			url: '/packages/booksubmit/appointment'
					// 		})
					// 	} else {
					// 		this.can_appointment = false
					// 		this.base.toast("您当前没有可预约次数")
					// 	}
					// })
				} else if (type === 2) {
					if (this.enter_schoolmate) {
						uni.navigateTo({
							url: '/packages/schoolmate/index'
						})
					} else {
						this.base.toast("您还不是校友，无权查看",1000,function(){
							setTimeout(function(){
								uni.switchTab({
									url: '/pages/course/index'
								})
							},1000)
							
						})
						
					}

				}
			}
		},

	}
</script>

<style scoped lang="scss">
	.container {
		width: 100%;
		height: 100vh;
		padding-bottom: 200rpx;

		.cbg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100vh;
		}
		.btn{
			width:320rpx;
			// height:136rpx;
			position: absolute;
			image{
				width:100%;
				height:100%;
			}
			view{
				text-align: center;
				margin-top:10rpx;
				color:#806e5c;
				font-size:30rpx;
			}
		}
		.schoolmate{

			top: 300rpx;
			left: 40rpx;
		}
		.book{
			bottom: 300rpx;
			right: 40rpx;
		}


		

	}
</style>