<template>
	<view style="background-color: #fff;height: 100vh;">
		<view style="width: 80%;margin: 0 auto;">
			<view class="" style="margin-bottom: 150rpx;">
				<image src="http://antis14.sherkxuan.cn/assets/images/a4.jpg" mode="widthFix"></image>
			</view>
			<view>
				<view class='content'>
					<view>申请获取以下权限</view>
					<text>获得你的公开信息(手机号等)</text>
				</view>
				<button class='bottom' type='primary' lang="zh_CN" open-type="getPhoneNumber"
					@getphonenumber="decryptPhoneNumber">
					一键授权登录
				</button>
			</view>
			<view class="xiey">
				
			</view>
				<!-- <u-checkbox 
					@change="checkboxChange" 
					v-model="item.checked" 
					v-for="(item, index) in list" :key="index" 
					:name="item.name"
				></u-checkbox> -->
				<!-- 我已认证阅读并同意接受 -->
			<!-- <text style="color: #179b16;">《用户协议》</text></view> -->
		</view>
	</view>
</template>

<script>
	import service from '@/service/service.js'
	export default {
		data() {
			return {
				list:[
					{
						checked:false,
						checked:false,
						name:"xz"
					}
				],
				formss:{
					account:'admin',
					password:'e10adc3949ba59abbe56e057f20f883e'
				},
				code: '',
				listdata: {},
				aesIv: '',
				encryptedData: '',
				// 上级绑定下级用户
				form: {
					CommissionerUserId: 0,
					ManagerUserId: 0,
				},
				// 类型
				// Type:0,
				model: {
					username: '',
					picture: ''
				},
				// 授权手机登录之后的信息
				LoginWeCharData: {
					"aesIv": "",
					"encryptedData": "",
					"code": ""
				},
				scene: ''
			}
		},

		// 打开页面的时候
		onLoad(data) {
			this.getCode()
		},
		methods: {
			checkboxChange(e){
				console.log("xz",e);
				this.list[0].value = e;
			},
			//1，code
			getCode() {
				//获取code
				let that = this
				uni.login({
					// provider:'sskxjht',
					success(res) {
						that.LoginWeCharData.code = res.code
						console.log("code",res);
					}
				})
			},
			goNav(url) {
				uni.navigateTo({
					url: url
				})
			},
			gain() {
				// const token = uni.getStorageSync("token");
				// if (!token) return
				this.API.getplie({
					pageNum: 1,
					pageSize: 8000
				}).then(response => {
					console.log(response, '界桩')
					let box1 = []
					for (let i = 0; i < response.rows.length; i++) {
						const newlist = response.rows[i];
						if (i == 0) {
							let c1 = '四川省眉山市仁寿县' + newlist.boundaryName
							box1.push(c1)
						} else {
							let ontrue = false
							for (let q = 0; q < box1.length; q++) {
								if (box1[q] == '四川省眉山市仁寿县' + newlist.boundaryName) {
									ontrue = true
									break
								}
							}
							if (ontrue) {
			
							} else {
								let c1 = '四川省眉山市仁寿县' + newlist.boundaryName
								box1.push(c1)
							}
			
						}
					}
					getApp().globalData.list1 = box1
					console.log('行政', getApp().globalData.list1)
				})
			},
			// 获取手机号
			decryptPhoneNumber(e) {
				console.log(e);
				this.LoginWeCharData.aesIv = e.detail.iv;
				this.LoginWeCharData.encryptedData = e.detail.encryptedData;
				console.log('获取手机号信息',JSON.stringify(this.LoginWeCharData))
				console.log('1111',this.LoginWeCharData,this.list[0].value);
					console.log(this.LoginWeCharData);
					this.API.postLogin(this.LoginWeCharData).then(res=>{
						console.log('res',res);
						service.saveUser(res.data.user);
						service.addToken(res.data.token);
						uni.setStorageSync("userjs", res.data.roles[0]);
						this.gain()
						if(res.code == 200){
							uni.reLaunch({
								url:"/pages/home/home"
							})
						}
					})
					if(this.list[0].value){
				}
				
				
			},

		}
	}
</script>

<style lang="scss" scoped>
	.login{
		padding: 30rpx;
		button{
			background-color: #e85b49;
			border-radius: 50rpx;
			margin-top: 60rpx;
			color:#fff
		}
	}
	.bg{
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		z-index: -1;
	}
	.header {
		margin-bottom: 20rpx;
		margin-top: 30rpx;
		padding: 40rpx;
		padding-top: 0rpx;
		width: 100vw;
		position: relative;
		image{
			width: 50vw;
			height: 10vh;
			margin-top: 40rpx;
		}
		
	}
	.content {
		margin-left: 50rpx;
		margin-bottom: 90rpx;
	}

	.content text {
		display: block;
		color: #9d9d9d;
		margin-top: 40rpx;
	}

	.bottom {
		border-radius: 80rpx;
		margin: 70rpx 50rpx;
		font-size: 35rpx;
	}

	.xiey {
		text-align: center;
		font-weight: 600;
		font-size: 26rpx;
		margin-left: 10rpx;
		line-height: 40rpx;
	}
</style>
