<template>
	<view class="se-pos se-h-vh-100">
		<view class="se-flex se-pt-200 se-flex-h-c se-flex-ff-cw">
			<image class="se-w-150 se-h-150" src="@/static/image/logo.png" mode=""></image>
			<view class="se-flex se-flex-h-c se-fs-34 se-fw-6 se-c-black se-mt-40">
				租房小程序
			</view>
		</view>
		<view class="se-pb-200 se-pos-cb se-w-p-100">
			<view  @click="onLogin()" class="se-mx-80  se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-white se-bgc-green">
				<image class="se-w-45 se-h-35" src="@/static/image/wechat.png" mode=""></image>
				<text class="se-ml-10">微信登录</text>
			</view>
			<!-- <view class="se-mx-80 se-br-40 se-mt-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-66 se-bgc-f5">
				<text>手机验证码登录</text>
			</view> -->
			<view class="se-mx-80 se-br-40 se-mt-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-24 se-c-33">
				<uv-checkbox-group @change="checkboxChange" v-model="checked">
					<uv-checkbox name="1" activeColor="#07C160" label-size="12" shape="circle" label="阅读并同意"></uv-checkbox>
					<text class="se-c-green" @click="open()">《隐私政策》</text>
					<text class="se-c-green" @click="open()">《服务条款》</text>
				</uv-checkbox-group>
				
			</view>
		</view>
		<uv-popup ref="popup" :round="20"  mode="center" bg-color="transparent" :close-on-click-overlay="false">
			<view class="se-w-600  se-bgc-white se-br-40 se-p-40">
				<view class="se-flex se-flex-h-c">
					<image class="se-a-80" src="@/static/image/6588.png" mode=""></image>
				</view>
				<view class="se-flex se-flex-h-c se-fs-34 se-fw-6 se-c-black se-mt-40">
					服务协议和隐私权政策
				</view>
				<view class="se-lh-40 se-mt-40 se-fs-24 se-c-99">
					<text>请您务必审慎阅读、充分理解用户协议和隐私政策各条款，包括但不限于用户注意事项、用户行为规范以及为了向你提供服务而收集、使用、存储你个人信息的情况等。你可阅读</text>
					<text class="se-c-black se-fw-6" @click="handleOpenPrivacyContract()">《租房小程序用户服务协议》</text>
					<text>和</text>
					<text class="se-c-black se-fw-6" @click="handleOpenPrivacyContract()">《租房小程序平台隐私权政策》</text>
					<text>了解详细信息。如你同意，请点击下方按钮开始接受我们的服务。</text>
				</view>
				<view class="se-flex se-flex-h-sb se-mt-40">
					<view @click="onCancel" class="se-br-20 se-flex-1 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-66 se-bgc-f5">
						<text>不同意</text>
					</view>
					<view @click="onAgree" class="se-br-20 se-ml-20 se-flex-1 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-white se-bgc-green">
						<text class="se-ml-10">同意</text>
					</view>
				</view>
			</view>
			</uv-popup>
	</view>
</template>

<script>
	import { fetchMenu,wxLogin } from "@/common/api.js"
	export default {
		name : 'Auth',
		data() {
			return {
				checked:[],
				show:false
			}
		},
		methods: {
			open(){
				this.$refs.popup.open();
			},
			checkboxChange(n) {
				console.log('change', n);
			},
			onCancel(){
				this.$refs.popup.close();
				this.checked=[];
			},
			onAgree(){
				this.$refs.popup.close();
				this.checked=['1'];
			},
			onLogin(){
				let that = this
				if(that.checked.length==0){
					return uni.showToast({
						icon: "none",
						title: "请勾选隐私协议"
					})
				}
				uni.showLoading({
					title: '登录中...'
				})
				uni.login({
					success(res) {
						console.info(res.code)
						if(res.errMsg != "login:ok"){
							return
						}
						wxLogin({ code : res.code }).then((response) => {
							uni.hideLoading()
							uni.setStorageSync('token', response.result.token)
							that.commit('setUserInfo',{userInfo:response.result.userInfo,token:response.result.token})
						}).catch(() =>{
							
						})
					}
				})
			},
			handleOpenPrivacyContract() {
				// 打开隐私协议页面
				wx.openPrivacyContract({
					success: () => {}, // 打开成功
					fail: () => {}, // 打开失败
					complete: () => {}
				})
			}
			
		}
	}
</script>

<style scoped lang="scss">
</style>
