<template>
	<view class="login">
		<view class="logo">
			<image src="/static/image/logo.jpg"
			mode=""></image>
		</view>
		<view class="title">
			欢迎使用瑶都万能墙
		</view>
		<view class="btn mt"
			@click="wxLogin">
			<view class="icon">
				<image src="../static/auth/wx.png" mode=""></image>
			</view>
			<view class="">
				快捷登录
			</view>
		</view>
		<view class="btn b2"
		@click="qux">
			匿名体验
		</view>
		
		
		
		<view class="config">
			<uv-checkbox-group
				v-model="checkboxValue"
				shape="circle">
				<view class="content" @click="toggleCheckbox">
					<view class="checkbox-row">
						<uv-checkbox
							size="50rpx"
							icon-size="40rpx"
							activeColor="#5baaff"
							:name="1"
						></uv-checkbox>
						<view class="text-content">
							阅读并同意我们的<text @click.stop="openConfigDetail('getPrivacyPolicy')">"服务协议与隐私条款"</text>
						</view>
					</view>
					<view class="text-line">
						以及<text @click.stop="openConfigDetail('getUserAgreement')">个人信息保护指引</text>
					</view>
				</view>
			</uv-checkbox-group>
		</view>
		
		<configPopup ref="popup"></configPopup>
		
	</view>
</template>

<script>
	import configPopup from '@/components/config/configPopup.vue';
	export default {
		name : 'Login',
		data() {
			return {
				checkboxValue : []
			}
		},
		methods: {
			wxLogin(){
				if(!this.checkboxValue.length){
					return uni.showToast({
						title: '请先同意隐私协议',
						icon:'none'
					})
				}
				this.$store.commit('login')
			},
			//切换勾选状态
			toggleCheckbox(){
				if(this.checkboxValue.includes(1)){
					this.checkboxValue = []
				} else {
					this.checkboxValue = [1]
				}
			},
			//打开应用配置
			openConfigDetail(key){
				this.$refs.popup.open(key)
			},
			qux(){
				uni.reLaunch({
					url: '/pages/index/index'
				})
			},
		}
	}
</script>

<style scoped lang="scss">
.login{
	display: flex;
	justify-content: center;
	align-items: center;
	height: 80vh;
	flex-direction: column;
	position: relative;
	.logo{
		height: 140rpx;
		width: 140rpx;
		background-color: #ddd;
		border-radius: 30rpx;
		image{
			width: 100%;
			height: 100%;
			border-radius: 30rpx;
		}
		margin-bottom: 20rpx;
	}
	.title{
		position: relative;
		font-weight: 900;
		font-size: 45rpx;
		&::after{
			content: '';
			position: absolute;
			left: 0;
			top: 100%;
			display: block;
			height: 8rpx;
			width: 210rpx;
			background: linear-gradient(to right,$uni-color, #fff);
		}
	}
	.btn{
		width: 80%;
		height: 100rpx;
		background-color: $uni-color;
		color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 20rpx;
        margin: 20rpx 0;
		.icon{
			margin-right: 10rpx;
			image{
				width: 40rpx;
				height: 35rpx;
			}
		}
	}
	.b2{
		background-color: #3c69f122;
		color: #3c69f1;
	}
	.mt{
		margin-top: 200rpx;
	}
	
	.config{
		position: absolute;
		bottom: 0;
		font-size: 28rpx;
		text-align: center;
		line-height: 50rpx;
		padding: 20rpx;
		
		.content {
			cursor: pointer;
			padding: 15rpx;
			border-radius: 10rpx;
			transition: background-color 0.2s;
		}
		
		.checkbox-row {
			display: flex;
			align-items: center;
			justify-content: center;
			margin-bottom: 10rpx;
		}
		
		.text-content {
			margin-left: 15rpx;
			flex: 1;
		}
		
		.text-line {
			text-align: center;
			margin-top: 5rpx;
		}
		
		text{
			color: $uni-color;
			font-weight: 500;
		}
	}
}
</style>
