<template>
	<view>
		<view class="w100 rowsc rows">
			<view class="w-710 bgff br-20 rows rowsl rowsm">
				<view class="rows rowsm h-112 w-654 rowsb" style="border-bottom: 1rpx solid #eee;"
				@click="$tools.goNext(`/pageOne/mes/agreement?name=隐私政策&type=1`)">
					<text class="fs-28 mr-20">隐私政策</text>
					<image class="w-20 h-20" src="/static/images/erf.png" mode=""></image>
				</view>
				<view class="rows rowsm h-112 w-654 rowsb" style="border-bottom: 1rpx solid #eee;"
				@click="$tools.goNext(`/pageOne/mes/agreement?name=用户协议&type=2`)">
					<text class="fs-28 mr-20">用户协议</text>
					<image class="w-20 h-20" src="/static/images/erf.png" mode=""></image>
				</view>
				<view class="rows rowsm h-112 w-654 rowsb" style="border-bottom: 1rpx solid #eee;"
				@click="$tools.goNext(`/pageOne/mes/agreement?name=关于我们&type=3`)">
					<text class="fs-28 mr-20">关于我们</text>
					<image class="w-20 h-20" src="/static/images/erf.png" mode=""></image>
				</view>
				<view class="rows rowsm h-112 w-654 rowsb" @click="handlePromotion">
					<text class="fs-28 mr-20">版本号：1.0.5</text>
				</view>
			</view>
		</view>
		<view class="w100 rows rowsc fixed" style="bottom: 60rpx;">
			<view class="w-694 h-90 bg colfff fs-30 br-100 rows rowsc rowsm"
			@click="getLogin">
				退出登录
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				promotionTapCount: 0,
				promotionUnlocked: false
			}
		},
		onShow() {
			this.syncPromotionStatus()
		},
		methods: {
			syncPromotionStatus() {
				this.promotionUnlocked = this.$tools.getPromotionUnlocked()
			},
			handlePromotion() {
				if (this.promotionUnlocked) {
					this.$tools.goNext('/pageOne/mes/promotion')
					return
				}
				this.promotionTapCount += 1
				const remainCount = 5 - this.promotionTapCount
				if (remainCount > 0) {
					return
				}
				this.$tools.setPromotionUnlocked(true)
				this.promotionUnlocked = true
				this.promotionTapCount = 0
				uni.$emit('promotionUnlocked')
				this.$tools.goNext('/pageOne/mes/promotion')
			},
			getLogin(){
				uni.showModal({
					title: '温馨提示',
					content: '尚未登录或登录已过期，是否前往登录？',
					success: (res) => {
						if(res.confirm){
							this.$tools.clearLoginStorage()
							uni.navigateTo({
								url: "/pages/login/login"
							})
						}
					}
				});
			}
		}
	}
</script>

<style>
	page{
		background-color: #F7F6FA;
		padding-top: 20rpx;
	}
</style>
