<template>
	<view class="container">
		<image class="cbg" src="../../static/common_bg.png"></image>
		<view class="wrap">
			
			<view class="wrap-block">
				<view  @click="toUrl(1)">我要预约</view>
				<view  @click="toUrl(2)">校友库</view>
			</view>

		</view>
		<tabbar :currentPage="2"></tabbar>
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar/tabbar.vue';
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				user: {},
				appointment_total: 0,
				is_schoolmate: 0,
			}
		},
		onLoad() {
			this.getUser()
		},
		methods: {
			getUser() {
				this.$u.api.user().then(res => {
					console.log("res", res)
					this.is_schoolmate = res.user.is_schoolmate
					this.appointment_total = res.user.appointment_total ? res.user.appointment_total : 0
					this.$u.vuex('vuex_user', res.user)
				})
			},
			toUrl(type) {
				if (type === 1) {
					if (this.appointment_total > 0) {
						uni.navigateTo({
							url: '/packages/booksubmit/index'
						})
					} else {
						this.base.toast("您当前没有预约次数")
					}

				} else if (type === 2) {
					if (this.is_schoolmate) {
						uni.navigateTo({
							url: '/packages/schoolmate/index'
						})
					} else {
						this.base.toast("您还不是校友，无权查看")
					}

				}
			}
		},

	}
</script>

<style scoped lang="scss">
	.container {
		width: 100%;
		height: 100vh;
		padding-bottom: 200rpx;
		.cbg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100vh;
		}
		.wrap{
			position: relative;
			top:0;
			left:0;
			&-block{
				display: flex;
				align-items: center;
				justify-content: center;
				&>view{
					width:200rpx;
					height:180rpx;
					text-align: center;
					line-height: 180rpx;
					margin:20rpx;
					font-size: 28rpx;
					background:linear-gradient(to right,#d8b594,#ba9676);
					border-radius: 20rpx;
					color:#fff;
					
				}
			}
		}
		
	}
</style>