<template>
	<view class="mobile-frame" v-show="frame">
		<view class="frame">
			<image src="../../static/image/tips.png" mode=""></image>
			<view class="title">
				当前操作需要授权手机号
			</view>
			<view class="submit" @click="frame=false">
				<button type="default" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即授权</button>
			</view>
		</view>
		<view class="close">
			<image src="../../static/image/close-white.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	var app = getApp()
	export default {
		name: 'mobile-auth',
		data() {
			return{
				frame:false
			}
		},
		props: {
			frame: {
				default: false
			},
		
		},
		created(){
			
		},
		methods: {
			
			//获取手机号
			getPhoneNumber: function(e) {
				console.log(e.detail)
				let data = {
					session_key: uni.getStorageSync('session_key'),
					iv: e.detail.iv,
					encryptedData: e.detail.encryptedData
				}
				app.request('/user/sync-mobile', data, 'post').then(res => {
					this.frameIshow = false
					app.globalData.is_auth = true
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.mobile-frame {
		position: fixed;
		height: 100vh;
		width: 100%;
		background: rgba($color: #000000, $alpha: 0.6);
		z-index: 99999;
		top: 0;

		.frame {
			width: 50%;
			margin: 0 auto;
			padding: 50upx 30upx;
			margin-top: 40%;
			border-radius: 12upx;
			background-color: #FFFFFF;
			text-align: center;

			image {
				height: 90upx;
				width: 90upx;
			}

			.title {
				height: 70upx;
				line-height: 70upx;
				font-size: 28upx;
			}

			.submit {
				margin: 0 auto;
				width: 50%;
				margin-top: 30upx;

				button {
					background-color: $mine-background-color;
					height: 70upx;
					line-height: 70upx;
					text-align: center;
					font-size: 26upx;
					color: #FFFFFF;
					background-color: $mine-background-color;
				}
			}

		}

		.close {
			margin: 0 auto;
			height: 100upx;
			width: 100upx;
			text-align: center;

			margin-top: 10%;

			image {
				height: 50upx;
				width: 50upx;
			}
		}
	}
</style>
