<template>
	<view class="index-page">
		<view class="about-container">
			<image class="app-icon" :src="icon" mode="aspectFit">
			</image>
			<image :src="login_icon" style="width: 200rpx;height: 200rpx"></image>
			<view>{{ tips }}</view>
		</view>
	</view>
</template>

<script>
import PageContainer from '@/components/page-container/page-container.vue'


export default {
	components: {
		PageContainer
	},
	data() {
		let icon = "";
		let login_icon = "https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/app/index_login.gif";
		// #ifdef APP
		icon = "/static/app-plus/icon_108.png";
		login_icon = "/static/app-plus/index_login.gif";
		// #endif
		return {
			icon: icon,
			login_icon: login_icon,
			tips: "正在加载中。。。"
		}
	},
	onLoad() {
		this.load();
		// const currentPage = getCurrentPages();
		// console.log('currentPagecurrentPagecurrentPage', currentPage);
	},
	methods: {
		toHome() {
			// #ifdef H5 || MP
			uni.switchTab({
				url: '/pages/shouye/index'
			});
			// #endif
		},
		async load() {
			var that = this;
			uni.getNetworkType({
				success(res) {
					if (res.networkType === 'none') {
						// uni.hi
						uni.hideToast();
						// 可能是无网络或权限被拒绝
						console.log('无网络连接或权限被拒绝');
						that.tips = "无网络连接或权限被拒绝";
						uni.onNetworkStatusChange(function (res) {
							console.log('网络状态变化:', res.isConnected, res.networkType);
							if (res.isConnected) {
								// 网络已连接
								that.tips = "正在加载中。。。";
								// #ifdef APP
								if (plus.runtime.restart) {
									plus.runtime.restart();
								} else {
									uni.showToast({
										title: "重启失败",
										icon: "none"
									});
								}
								// #endif
							} else {
								// 网络断开
								that.tips = "网络断开";
							}
						});
					} else {
						// 有网络权限
						console.log('网络权限已授予');
						that.$platform.appData();
						// that.toHome();
						// AppData()
					}
				},
				fail() {
					// 获取网络状态失败，可能是权限问题
					console.log('获取网络状态失败，可能无权限');
				}
			});

		},

	}
}
</script>

<style lang="scss">
.index-page {
	width: 100vw;
	height: 100vh;
	background-color: #f8f8f8;
}

.about-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 20px;

	.app-icon {
		width: 96px;
		height: 96px;
		margin-top: 20vh;
		border-radius: 50%;
	}

	.app-info {
		margin-top: 20px;
		text-align: center;

		.app-name {
			font-size: 18px;
			font-weight: bold;
			margin-bottom: 10px;
		}

		.app-version {
			font-size: 14px;
			color: #666;
			margin-bottom: 5px;
		}
	}

	.test-mode-container {
		margin-top: 30px;
		border: 1px dashed #ff6600;
		border-radius: 8px;
		padding: 15px;
		width: 80%;

		.test-mode-content {
			width: 100%;
		}

		.test-mode-title {
			text-align: center;
			font-weight: bold;
			font-size: 16px;
			color: #ff6600;
			margin-bottom: 15px;
		}

		.test-mode-item {
			margin: 10px 0;
			font-size: 14px;
		}

		.button-group {
			display: flex;
			justify-content: space-between;
		}

		.log-button {
			width: 48%;
			margin: 0;
		}

		.test-button {
			margin-top: 15px;
			background-color: #ff6600;
			color: white;
			font-size: 14px;
		}
	}
}
</style>