<template>
	<view class="initialization_content">
		<view class="initialization_body">
			<view class="app_logo">
				<image src="/static/app_logo.png" class="is_image"></image>
			</view>
			<view class="app_title">
				古言小说
			</view>
		</view>
		<view class="initialization_footer">

			<!-- <view class="app_title">
				古言小说
			</view> -->
		</view>
		<u-modal :show="modalShowOne" title="欢迎使用" :showCancelButton="true" cancelColor="#999" confirmText="同意并继续"
			cancelText="不同意" confirmColor="#FF728F" @confirm="toAgreeWith" @cancel="handelOnceMore">
			<view class="slot_content">
				<text>感谢您信任并使用古言小说！本服务需联网，申请通知权限用于为您提供书籍更新、优惠活动等信息服务。点击“同意”，即表示您同意上述内容及</text>
				<text class="user_agreement" @tap="toAgreement('1')">《古言用户服务协议》</text>
				<text>及</text>
				<text class="privacy" @tap="toAgreement('2')">《古言隐私政策》</text>
			</view>
		</u-modal>
		<u-modal :show="modalShowTwo" title="您需要同意以下协议才能正常使用古言" :showCancelButton="true" cancelColor="#999"
			confirmText="同意" cancelText="不同意并退出" confirmColor="#FF728F" @confirm="toAgreeWith"
			@cancel="toExitApplication">
			<view class="slot_content">
				<view>若您不同意，很遗憾我们将无法为您提供服务。</view>
				<view class="user_agreement" @tap="toAgreement('1')">《古言用户服务协议》</view>
				<view class="privacy" @tap="toAgreement('2')">《古言隐私政策》</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	import {
		myGetStorage,
		mySetStorage
	} from '@/utils/storage/index.js';
	export default {
		data() {
			return {
				giveService: false,
				modalShowOne: false,
				modalShowTwo: false
			}
		},
		onShow() {
			const giveService = myGetStorage('giveService');
			this.giveService = giveService ? false : true;
			this.modalShowOne = giveService ? false : true;
			if (giveService) {
				setTimeout(() => {
					uni.switchTab({
						url: `/pages/bookCity/bookCity/index`
					})
				}, 1000)
			}
		},
		methods: {
			toAgreeWith() {
				setTimeout(() => {
					uni.switchTab({
						url: `/pages/bookCity/bookCity/index`
					})
				}, 300)
				mySetStorage('giveService', 1);
				this.modalShowOne = false;
				this.modalShowTwo = false;
			},
			toExitApplication() {
				if (uni.getSystemInfoSync().platform == 'ios') {
					plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
				} else if (uni.getSystemInfoSync().platform == 'android') {
					plus.runtime.quit();
				}
			},
			toAgreement(type) {
				uni.navigateTo({
					url: `/pages/agreement/agreement?type=${type}`
				})
			},
			handelOnceMore() {
				this.modalShowOne = false;
				this.modalShowTwo = true;
			}
		}
	}
</script>

<style lang="scss">
	.is_image {
		display: block;
		width: 100%;
		height: 100%;
		border-radius: 16rpx;
		box-shadow: 0 0 16rpx rgba(0, 0, 0, 0.2);
	}

	.initialization_content {
		width: 100%;
		height: 100%;
		position: relative;
		background: linear-gradient(to bottom, #FFC7D3 0%, #FFEBEE 50%, #fff 100%);

		.initialization_body {
			padding-top: 260rpx;
			display: flex;
			flex-direction: column;
			align-items: center;

			// .app_title_image {
			// 	width: 200rpx;
			// 	height: 400rpx;
			// }
			.app_logo {
				width: 160rpx;
				height: 160rpx;
			}

			.app_title {
				font-size: 60rpx;
				font-weight: 600;
				margin-left: 16rpx;
				margin-top: 20rpx;
			}
		}

		.initialization_footer {
			// position: absolute;
			// bottom: 180rpx;
			// left: 0;
			// display: flex;
			// justify-content: center;
			// align-items: center;
			// width: 100%;

			// .app_logo {
			// 	width: 100rpx;
			// 	height: 100rpx;
			// }

			// .app_title {
			// 	font-size: 46rpx;
			// 	font-weight: 600;
			// 	margin-left: 16rpx;
			// }
		}

		.slot_content {
			font-size: 30rpx;
			color: #999;

			.user_agreement {
				color: #FF728F;
			}

			.privacy {
				color: #FF728F;
			}
		}
	}
</style>