<template>
	<g-toast :is-show="isShowToast">
		<view class="toast_container xueba_toast" @click="toChallenge">
			<image class="bg" src="https://api.jiuweiyun.cn/public/uploads/icon/toast7.png"></image>
			<view class="text">{{ serverUserInfo.level_name }}学霸</view>
		</view>
	</g-toast>
</template>

<script>
	import { toClieckedToast } from "../../utils/api/toast.js"
	import GToast from "../../components/global/toast.vue"
	export default {
		components: {
			GToast
		},
		data() {
			return {
				serverUserInfo: uni.getStorageSync("serverUserInfo"),
				initToast: true
			}
		},
		computed: {
			isShowToast() {
				let { max_popovers } = this.serverUserInfo
				return this.initToast && max_popovers && max_popovers.type === 10
			}
		},
		methods: {
			// 学霸跳转荣誉殿堂
			toChallenge() {
				let { max_popovers } = this.serverUserInfo
				toClieckedToast({
					id: max_popovers.id
				}).then(res => {
					this.serverUserInfo.max_popovers = {}
					uni.setStorage({
						key: "serverUserInfo",
						data: this.serverUserInfo,
						success() {
							uni.navigateTo({
								url: "../../honor/index"
							})
						}
					})
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.toast_container {
		position: relative;
		margin: 0 auto;
		.bg {
			width: 100%;
			height: 100%;
		}
		&.xueba_toast {
			width: 662rpx;
			height: 685rpx;
			
			.text {
				width: 416rpx;
				text-align: center;
				height: 112rpx;
				line-height: 112rpx;
				color: #FFFFFF;
				font-size: 58rpx;
				position: absolute;
				left: 50%;
				bottom: 0;
				transform: translate(-50%, -230rpx);
			}
		}	
	}
</style>
