<template>
  <view class="regbox">
	  <view class="rggtop flex0"></view>
	  <image :src="headimg" class="headimg flex0"></image>
	   
	  <view class="flex1">
		  <button  type="primary" class="rbtn mb20 mt50" open-type="getUserInfo" @getuserinfo="getuserinfo">
		  	<text class="btn-txt">微信一键登录</text>
		  </button>
			<view class="lread" @click="checkflag=!checkflag">
				<view class="lreadl">
					<image :src="checkimg" v-if="checkflag"></image>
					<image :src="ncheckimg" v-else></image>
				</view>
				<view class="tit">阅读后自行选择是否同意<text @click.stop="handlePrivacy">用户协议</text>及<text @click.stop="handlePrivacy">隐私政策</text></view>
			</view>
	  </view>
	  <!-- <phone-btn :type="typeflag" @getPhoneNumber='getPhoneNumber' @getClose="getClose"></phone-btn> -->
  </view>
</template>

<script>
	import phoneBtn from "@/components/toptab/phonebtn.vue"
  export default {
	  components:{
		  phoneBtn
	  },
	data(){
		return{
			headimg:require('@/static/images/logo.png')
		}
	},
	
	methods:{
		 async getuserinfo(e) {
			 // if(!this.checkflag){
				//  this.$toast("请同意用户协议")
				//  return
			 // }
		 	const {iv,encryptedData} = e.detail
		 	const {nickName, avatarUrl, ...userInfo} = e.detail.userInfo
			// console.log(e.detail)
		 	try{
				uni.login({
                    provider: 'weixin',
                    success: (res) => {
                        // 获取用户信息
						if(res.code){
							this.avatarUrl = avatarUrl
							this.nickName = nickName
							this.code = res.code
							this.userInfo =e.detail.userInfo
							uni.setStorageSync('userInfo', e.detail.userInfo)
							uni.setStorageSync('lcheckflag',true)
							this.typeflag=true;
						}
                    }
                })
		 	} catch(e){
		 		//TODO handle the exception
		 	}
		 },
	},
	
	onLoad: function() {	
    },
  }
</script>

<style lang="scss" scoped>
.regbox{
	min-height: 100vh;background-color: #f6f2e9;display: flex;flex-direction: column;
	.rggtop{width: 100%;height: 314rpx;background: linear-gradient(180deg, #EACBA2 0%, rgba(236,207,167,0) 100%);}
	.rbtn{
		width: 616rpx;height: 100rpx;border-radius: 50rpx;background-color: #D4A354 ;
		.btn-txt{font-size: 30rpx;color: #FFFFFF;}
	}
}
.headimg{width: 294rpx;height: 100rpx;margin:0 auto 36rpx;}
.lread{
	display: flex;align-items: flex-start;justify-content: center;
	.lreadl{padding-top: 4rpx;
		image{width: 28rpx;height: 28rpx;margin-right: 14rpx;}
	}
	.tit{font-size: 26rpx;font-weight: 500;color: #666666;line-height: 40rpx;
		text{color: #4775EA;text-decoration: underline;padding: 0 6rpx;}
	}
}

// app
</style>
