<template>
	<view class="Body">
		<navbar ref="navbar" :config="config" backColor="#666"></navbar>
		<view class="top">
			<view class="title">
				授权 <text>{{checkInfo.thirdApplicationName}}</text> 获取以下信息:
			</view>
			<view class="info">
				<!-- v-if="checkInfo.showBaseData" -->
				<view class="info-item">
					<view class="circle"></view>
					<view class="">获取你的账号信息(头像、昵称、手机号)</view>
				</view>
				<!-- v-if="checkInfo.showRealNameData" -->
				<view class="info-item">
					<view class="circle"></view>
					<view class="">使用身份信息(姓名、证件号码)办理业务</view>
				</view>
				<!-- v-if="checkInfo.showBusinessData" -->
				<view class="info-item">
					<view class="circle"></view>
					<view class="">提供企业信息(名称、社会信用统一代码)办理业务</view>
				</view>
			</view>
		</view>
		<view class="footer">
			<button class="agree-btn" @click="agree()">同意授权</button>
			<button class="close-btn" @click="close()">暂不授权</button>
		</view>
	</view>
</template>

<script>
	let app = getApp()
	export default {
		data() {
			return {
				config: {
					back: true, //false是tolbar页面 是则不写
					title: '服务授权',
					color: '#1a1a1a',
					//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
					backgroundColor: [1, '#fff'],
					backTabPage: '/pages/home'
				},
				statusBarHeight: app.globalData.statusBarHeight,
				authInfo: {},
				checkInfo: {}
			}
		},
		onLoad(options) {
			console.log(uni.getStorageSync('authInfo'), 33333)
			this.authInfo = uni.getStorageSync('authInfo')
			this.checkInfo = uni.getStorageSync('checkInfo')
		},
		onUnload() {
			uni.removeStorageSync('authInfo')
			uni.removeStorageSync('checkInfo')
		},
		methods: {
			agree() {
				this.$yghttp.post('/auth/confirmAuth', this.authInfo).then(res => {
					console.log(res, 666666)
					if (res.code == 200) {
						uni.redirectTo({
							url: `/pages/web-view/Apps?path=${encodeURIComponent(res.data.redirect)}`
						});
					}
				})
			},
			close() {
				try {
					uni.removeStorageSync('authInfo')
					uni.removeStorageSync('checkInfo')
				} catch (err) {
					console.log('未缓存信息')
				}
				uni.switchTab({
					url: '/pages/home'
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.Body {
		position: absolute;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		background:url("/static/czd/service-authBg.png");
		background-size: 100% 100%;
	}

	.lgoin-nav {
		width: 100%;
		background-color: #fff;
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		z-index: 0;
	}

	.top {
		padding: 200rpx 60rpx;
		margin-bottom: 150rpx;

		.title {
			color: #191919;
			margin-bottom: 40rpx;
			font-size: 28rpx;

			text {
				margin: 0 10rpx;
				font-size: 42rpx;
				font-weight: bold;
				color: #191919;
			}
		}

		.info {
			.info-item {
				display: flex;
				// align-items: center;
				color: #191919;
				margin-bottom: 10rpx;

				.circle {
					width: 6rpx;
					margin-right: 10rpx;
					height: 6rpx;
					border-radius: 50%;
					background-color: #AAAAAA;
					margin-top: 16rpx;
				}
			}
		}
	}

	.footer {
		position: fixed;
		bottom: 300rpx;
		width: 100%;
		.agree-btn {
			width: 670rpx;
			height: 81rpx;
			background: linear-gradient(180deg, #29b1a1 0%, #2ba7bd 100%);
			border-radius: 40px;
			box-shadow: 0rpx 3rpx 10rpx 0rpx rgba(12, 41, 146, 0.26);
			color: #fff;
			line-height: 81rpx;
			font-size: 30rpx;
			margin: 0 auto 26rpx;
		}

		.close-btn {
			width: 670rpx;
			height: 81rpx;
			background: #ffffff;
			border: 2rpx solid #2aacb1;
			border-radius: 40rpx;
			line-height: 81rpx;
			font-size: 30rpx;
			margin:auto;
		}
	}
</style>