<template>
	<view class="index">
		<button type="primary" @tap="toranking">排行榜</button>
		<button type="primary" @tap="toupload">图片上传</button>
		<button type="primary" @tap="tohonour">荣耀殿堂</button>
		<button type="primary" @tap="toexchange">礼品兑换</button>
		<button type="primary" @tap="tostatistics">数据统计</button>
		<button type="primary" @tap="tosetting">设置</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		computed: {
			userServerInfo () {  //用户服务器信息
				return this.$store.state.userServerInfo
			}
		},
		onShow() {
			this.routing = false
		},
		methods: {
			toranking () {  //点击排行榜
				if (this.$verified()) {  //用户是否已登录
					if (this.userServerInfo.type === 1) {  //判断用户类型，普通用户需要报名后才可以查看排行榜
						if (this.userServerInfo.signuped) {  //如果用户已报名，就跳转
							if (this.routing) { return }
							this.routing = true
							uni.navigateTo({ url: '../ranking/ranking' })
							
						} else {  ////如果用户已报名，就提示用户没有报名
							uni.showToast({
								title: '您还没有报名参赛',
								icon:"none"
							});
							
						}	
					} else {  //代理公司和政委可以直接查看排行榜页
						if (this.routing) { return }
						this.routing = true
						uni.navigateTo({ url: '../ranking/ranking' })
					}
				} else {  //未登录弹出登录框
					uni.showToast({
						title: '您还未登录'
					});
				}
			},
			tohonour () {  //点击荣誉殿堂
				if (this.$verified()) {  //用户是否已登录
					if (this.userServerInfo.type === 1) {  //普通用户直接跳转到荣誉殿堂页面
						if (this.routing) { return }
						this.routing = true
						uni.navigateTo({ url: '../honour/honour' })
					} else {  //代理公司和政委不可参赛，所以提示无参赛记录
						uni.showToast({
							title: '无参赛记录',
							icon:"none"
						});
					}
				} else {  //未登录弹出登录框
					uni.showToast({
						title: '您还未登录'
					});
				}
			},
			toupload () {  //点击上传图片
				if (this.$verified()) {  //用户是否已登录
					if (this.userServerInfo.signuped) {
						if (this.userServerInfo.status === 1 || this.userServerInfo.status === 4) {
							uni.showToast({
								title: '比赛还没有开始',
								icon:"none"
							});
						} else if (this.userServerInfo.status === 2) {
							if (this.routing) { return }
							this.routing = true
							uni.navigateTo({ url: '../upload/upload' })
						} else if (this.userServerInfo.status === 3 || this.userServerInfo.status === 5) {
							uni.showToast({
								title: '比赛已经结束了',
								icon:"none"
							});
						}
					} else {
						uni.showToast({
							title: '您还没有报名参赛',
							icon:"none"
						});
					}
				} else {  //未登录弹出登录框
					uni.showToast({
						title: '您还未登录'
					});
				}
			},
			toexchange () {  //点击兑换奖品
				if (this.$verified()) {  //用户是否已登录
					if (this.userServerInfo.status === 3) {
						if (this.routing) { return }
						this.routing = true
						uni.navigateTo({ url: '../exchange/exchange' })
					} else {
						uni.showToast({
							title: '礼品兑换还未开始',
							icon:"none"
						});
					}
				} else {  //未登录弹出登录框
					uni.showToast({
						title: '您还未登录'
					});
				}
			},
			tosetting () {  //点击设置
				if (this.routing) { return }
				this.routing = true
				uni.navigateTo({ url: '../setting/setting' })
			},
			tostatistics () {  //点击数据统计
				if (this.$verified()) {  //用户是否已登录
					if (this.routing) { return }
					this.routing = true
					uni.navigateTo({ url: '../statistics/statistics' })
				} else {  //未登录弹出登录框
					uni.showToast({
						title: '您还未登录'
					});
				}
			},
		}
	}
</script>

<style>
	.index{
		width: 100%;
		height: 100%;
		position: relative;
		box-sizing: border-box;
		padding: 161rpx 50rpx 0;
		display: flex;
		flex-direction: column;
	}
	button {
		width: 100%;
		margin-top: 20px;
	}
</style>
