<template>
	<view class="container">
		<image class="cbg"  :src="base.imgHost('common_bg.png')"></image>
		<view class="book-top">
			<image :src="base.imgHost('book-top.png')"></image>
		</view>
		<view class="book">
			<view class="book-pic">
				<view class="book-pic-item">
					<image  :src="base.imgHost('book-pic1.png')"></image>
					<view>
						<view>图书馆</view>
						<view>
							<text class="colortext">1</text>
							<text>/1</text>
						</view>
					</view>
				</view>
				<view class="book-pic-item">
					<image :src="base.imgHost('book-pic1.png')"></image>
					<view>
						<view>会议室</view>
						<view>
							<text class="colortext">1</text>
							<text>/1</text>
						</view>
					</view>
				</view>
			</view>
			<view class="book-block">
				<image @click="toUrl(1)" :src="base.imgHost('book-icon1.png')"></image>
				<image @click="toUrl(2)" :src="base.imgHost('book-icon2.png')"></image>
			</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,
				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
					if(res.user.appointment_total - res.user.pass_appointments>0){
						this.can_appointment = true
					}else{
						this.can_appointment = false
					}
					this.$u.vuex('vuex_user', res.user)
				})
			},
			toUrl(type) {
				if (type === 1) {
					if (this.can_appointment) {
						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;
		}
		.book-top{
			position: relative;
			padding:80rpx 0 60rpx 0;
			image{
				width:539rpx;
				height:88rpx;
				display: block;
				margin:0 auto;
			}
		}
		.book {
			position: relative;
			padding:0 30rpx;
			height:calc(100vh - 400rpx);
			overflow: scroll;
			&-block {
				display: flex;
				align-items: center;
				justify-content: space-between;
				image{
					width:330rpx;
					height:126rpx;
				}
			}
			&-pic{
				&-item{
					font-size: 0;
					border-radius: 10rpx;
					margin-bottom:30rpx;
					image{
						width:100%;
						height:350rpx;
					}
					&>view{
						display: flex;
						align-items: center;
						justify-content: space-between;
						padding:20rpx 30rpx;
						background-color: #fff;
						font-size: 28rpx;
						color:#000;
						border-radius: 0 0 10rpx 10rpx;
						text{
							color:#666;
							font-size: 24rpx;
						}
						.colortext{
							color:#b79373;
						}
					}
				}
			}
		}

	}
</style>