<template>
	<ax-body blank="0" hideIndicatorArea>
		<image src="@/static/img/page-bg01.png" class="page-background"></image>
		<view class="body">
			<view class="title">
				<view>
					<view class="h1">您好!</view>
					<view class="h2">欢迎使用中数电动</view>
				</view>
				<image src="@/static/img/logo.svg" class="logo" mode="widthFix"></image>
			</view>
			<view class="logo-wrap">
				<image src="@/static/img/login-bg.svg" class="bg" mode="widthFix"></image>
			</view>
			<view class="footer" style="padding-left: 0;padding-right: 0;">
				<button @getphonenumber="onGetPhoneNumber" open-type="getPhoneNumber" class="submit" :disabled="!agreement" style="margin-left: 35px;width: calc(100% - 70px);">
					<text class="ax ax-iconblock i-weixin"></text>
					<text>微信用户一键登录</text>
				</button>
				<view class="cancel">取消返回</view>
				<view @click="agreement = !agreement" class="agreement" style="font-size: 17px;">
					<view class="mask" :class="{active:agreement}"><text class="ax ax-iconline i-select"></text></view>
					<text>我已阅读并理解和同意</text>
					<text @click.stop="checkPrivacy()" class="em">《隐私政策协议》</text>
				</view>
			</view>
		</view>
	</ax-body>
</template>

<script>
	export default {
		onLoad() {
			uni.getPrivacySetting({success:res=>{
				this.privacy.name = res.privacyContractName;
				this.privacy.need = res.needAuthorization;
			}});
		},
		data() {
			return {
				agreement: false,
				privacy:{
					need: true,
					name: ''
				},
			}
		},
		methods: {
			// 查看隐私
			checkPrivacy(){
				uni.openPrivacyContract();
			},
			onGetPhoneNumber(e){
				if(e.detail.code){
					this.$api.base("post",'/userApi/getPhone',{code:e.detail.code}).then(async res=>{
						await this.$app.storage.set('USER_INFO',res.userInfo);
						this.$app.url.back()
					});
				}
			},
		}
	}
</script>

<style scoped>
@import url("login.css");
</style>
