<template>
	<view class="authorizedLogin-container" v-if="show">
		<image src="/static/logo.png" class="logo"></image>
		<view class="statement">
			<label>
				<label class="radio" @click="changecheck">
					<radio class="check-bt" value="1" :checked="checked" style="transform:scale(0.6)" />
					<text>我已阅读并同意</text>
					<text class="link" @click="statement">《隐私政策》</text>
					<text>首次使用自动注册登录</text>
				</label>
			</label>
		</view>
		<div class="btn-submit" @click="loginsubmit">一键登录</div>
	</view>
</template>

<script>
	import { wxLogin} from '@/api/openApi.js'
	export default {
		name:"AuthorizedLogin",
		data() {
			return {
				show:true,
				checked:true
			};
		},
		methods:{
			loginsubmit(){
				let self=this;
				uni.getProvider({
					service:"oauth",
					success(res){
						let provider=res.provider
						uni.login({
							provider,
							success: function (loginRes) {
								let code=loginRes.code;
								wxLogin(code).then((resp)=>{
									const { code, data, msg } = resp
									debugger
									if(data){
										if(data&&data.unionid){
											uni.setStorageSync('unionid',data.unionid)
										}
									}
								})
							}						
						})					
					}
				})
			},			
			changecheck(){
				this.checked= !this.checked
			},
			statement(){
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.authorizedLogin-container{
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		background-color: rgba(255,255,255,1);
		z-index: 999;
		padding: 20rpx;
		box-sizing: border-box;
		.logo{
			display: block;
			width: 100rpx;
			height: 100rpx;
			margin: 100rpx auto;
		}
		.statement{
			font-size: 24rpx;
			color: #666;
			.check-bt{
				::v-deep .uni-radio-input{
					margin-right: 0 !important;
				}
			}
			.link{
				color: #3D90F4;
			}
		}
		.btn-submit{
			width: 600rpx;
			height: 72rpx;
			line-height: 72rpx;	
			text-align: center;							
			background:#3D90F4;
			border-radius: 42rpx;	
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			z-index: 999;
			margin: 50rpx auto;
		}
	}
</style>