<template>
	<g-toast :is-show="isShowToast">
		<view class="challenge-invite">
			<view class="challenge-user">
				<view
					class="user-avatar"
					:style="{ backgroundImage: `url(${serverUserInfo.cha_avatar})` }"
				/>
			</view>
			<view class="challenge-title">
				“{{ serverUserInfo.cha_nickname }}”向你发起学分挑战 详情可在“我的挑战”列表中查看
			</view>
			<view class="challenage-btn" @click="toChallenge('0')">查看详情</view>
		</view>
	</g-toast>
</template>

<script>
	import GToast from "../../components/global/toast.vue"
	export default {
		components: {
			GToast
		},
		data() {
			return {
				serverUserInfo: uni.getStorageSync("serverUserInfo"),
				initToast: true
			}
		},
		computed: {
			isShowToast() {
				let { cha_nickname } = this.serverUserInfo
				return this.initToast && cha_nickname
			}
		},
		methods: {
			// 跳转挑战
			toChallenge() {
				uni.navigateTo({
					url: "../../pages/challenge/index?nav=0"
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.challenge-invite {
		display: flex;
		flex-direction: column;
		align-items: center;
		.challenge-user {
			width: 426rpx;
			height: 334rpx;
			margin: 0 auto 48rpx auto;
			background: url(https://api.jiuweiyun.cn/public/uploads/weapp/icon/invite.png) center no-repeat;
			background-size: 100%;
			position: relative;
			.user-avatar {
				width: 168rpx;
				height: 168rpx;
				border-radius: 50%;
				position: absolute;
				bottom: 8rpx;
				left: 50%;
				transform: translateX(-50%);
				background-position: center;
				background-repeat: no-repeat;
				background-size: 100%;
				background-color: #007AFF;
			}
		}
		.challenge-title {
			width: 456rpx;
			color: #FFF1AD;
			font-size: 32rpx;
			line-height: 50rpx;
			margin-bottom: 86rpx;
			font-weight: bold;
		}
		.challenage-btn{
			width: 502rpx;
			height: 96rpx;
			border-radius: 96rpx;
			background: linear-gradient(180deg, #FEEB71 0%, #F89018 100%);
			color: #984100;
			font-size: 32rpx;
			font-weight: bold;
			line-height: 96rpx;
			text-align: center;
		}
	}
</style>
