<template>

	<view v-if="loading" class="skeleton-container">
		<!-- 安全等级卡片骨架 -->
		<view class="security-level-card skeleton-card">
			<view class="security-level-header">
				<view class="skeleton-line skeleton-line-sm"></view>
			</view>
			<view class="progress-bar skeleton-progress"></view>
			<view class="skeleton-line skeleton-line-xs"></view>
		</view>

		<!-- 安全设置列表骨架 -->
		<view class="security-settings skeleton-settings">
			<view class="security-item skeleton-item" v-for="i in 3" :key="i">
				<view class="item-left">
					<view class="item-icon skeleton-icon"></view>
					<view class="skeleton-line skeleton-line-md"></view>
				</view>
				<view class="item-right">
					<view class="skeleton-line skeleton-line-sm"></view>
				</view>
			</view>
		</view>

		<!-- 安全提示卡片骨架 -->
		<view class="security-tip-card skeleton-tip-card">
			<view class="tip-content">
				<view class="skeleton-circle"></view>
				<view class="skeleton-line skeleton-line-full"></view>
			</view>
		</view>
	</view>

	<view v-else class="account-security-page" style="overflow: hidden;" >
		<!-- 安全等级卡片 -->
		<view class="security-level-card">
			<view class="security-level-header">
				<text class="security-level-label">账号安全等级：</text>
				<text class="security-level-value">高</text>
			</view>
			<view class="progress-bar">
				<view class="progress-fill"></view>
			</view>
			<view class="security-desc">您已完成所有安全设置</view>
		</view>

		<!-- 安全设置列表 -->
		<view class="security-settings">
			<!-- 实名认证 -->
			<view class="security-item" @click="Service.GoPage(item.path)" v-for="(item,index) in funcList" :key="index">
				<view class="item-left">
					<view class="item-icon">
						<image :src="Service.GetIconImg(item.icon)" style="width: 100%; height: 100%; " mode=""></image>
					</view>
					<text class="item-label">{{item.name}}</text>
				</view>
				<view class="item-right">
					<text class="item-status">{{ item.des }}</text>
					<up-icon name="arrow-right" size="19" color="#999"></up-icon>
				</view>
			</view>

		</view>

		<!-- 安全提示卡片 -->
		<view class="security-tip-card">
			<view class="tip-content">
				<up-icon name="info-circle-fill" size="24" color="#999"></up-icon>
				<text class="tip-text">为保障您的账号安全，请勿泄露验证码，定期更新密码。</text>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { onLoad, onShow } from '@dcloudio/uni-app'
	import { Service } from "@/Service/Service"
	import { ref } from 'vue'
	import { CNRiderDataService } from "@/Service/CN/CNRiderDataService"

	let loading = ref(true)
	
	let riderInfo=ref<any>({})
	
	
	const funcList = ref([
		{
			name: '实名认证',
			icon: '/static/index/my/security/security.png',
			des: "已认证",
			path:'/pages/my/authentication'
		},
		{
			name: '手机号绑定',
			icon: '/static/index/my/security/phone.png',
			des: "",
			path:'/pages/my/setConnect?type=1'
		},
		{
			name: '紧急联系人',
			icon: '/static/index/my/security/user.png',
			des: "",
			path:'/pages/my/setConnect?type=0'
		},
		{
			name: '修改密码',
			icon: '/static/index/my/security/mima.png',
			des: "",
			path:'/pages/my/editPasssword'
		}
		
	])

	// 页面加载时的逻辑
	onLoad(() => {
		
	})
	
	onShow(()=>{
		getData()
		getConnect()
	})
	
	
	const getData = () => {
		CNRiderDataService.GetRiderInfo().then(res => {
			loading.value = false
			if(res.data){
				riderInfo.value=res.data.riderInfo
				funcList.value[0].des=riderInfo.value.status===-1?'未认证':(riderInfo.value.status===0?'审核中':'已认证')
				funcList.value[1].des='已绑定'+' '+riderInfo.value.phone.slice(0,3)+'****'+riderInfo.value.phone.slice(-4)
				
			}
		})
	}
	
	
	const getConnect=()=>{
		CNRiderDataService.GetRiderExigency().then(res=>{
			if(res.data){
				funcList.value[2].des=  res.data.info? res.data.info.phone :   '未绑定'
			}
		})
	}
	
	
</script>

<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	// 安全等级卡片样式
	.security-level-card {
		background-color: #E6F7FF;
		margin: 30rpx 30rpx 30rpx;
		padding: 30rpx;
		border-radius: 16rpx;
	}

	.security-level-header {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.security-level-label {
		font-size: 28rpx;
		color: #333;
	}

	.security-level-value {
		font-size: 32rpx;
		font-weight: 600;
		color: #007AFF;
	}

	.progress-bar {
		width: 100%;
		height: 8rpx;
		background-color: #B3D8FF;
		border-radius: 4rpx;
		overflow: hidden;
		margin-bottom: 16rpx;
	}

	.progress-fill {
		width: 100%;
		height: 100%;
		background-color: #007AFF;
		border-radius: 4rpx;
	}

	.security-desc {
		font-size: 24rpx;
		color: #666;
	}

	// 安全设置列表样式
	.security-settings {
		background-color: #fff;
		margin: 0 30rpx 30rpx;
		border-radius: 16rpx;
		overflow: hidden;
	}

	.security-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx;
		border-bottom: 1rpx solid #f0f0f0;
	}

	.security-item:last-child {
		border-bottom: none;
	}

	.item-left {
		display: flex;
		align-items: center;
	}

	.item-icon {
		width: 50rpx;
		height: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 20rpx;
	}

	.item-label {
		font-size: 32rpx;
		color: #333;
	}

	.item-right {
		display: flex;
		align-items: center;
	}

	.item-status {
		font-size: 28rpx;
		color: #4CD964;
		margin-right: 10rpx;
	}

	// 安全提示卡片样式
	.security-tip-card {
		background-color: #FFF8E8;
		margin: 0 30rpx;
		padding: 24rpx;
		border-radius: 16rpx;
	}

	.tip-content {
		display: flex;
		align-items: flex-start;
	}

	.tip-text {
		flex: 1;
		font-size: 24rpx;
		color: #999;
		line-height: 36rpx;
		margin-left: 10rpx;
	}

	// 骨架屏基础样式
	.skeleton-line {
		background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
		background-size: 200% 100%;
		animation: skeleton-loading 1.5s infinite;
		border-radius: 4rpx;
	}

	.skeleton-icon {
		background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
		background-size: 200% 100%;
		animation: skeleton-loading 1.5s infinite;
		border-radius: 8rpx;
	}

	.skeleton-circle {
		background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
		background-size: 200% 100%;
		animation: skeleton-loading 1.5s infinite;
		border-radius: 50%;
		width: 40rpx;
		height: 40rpx;
		margin-right: 16rpx;
	}

	.skeleton-progress {
		background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
		background-size: 200% 100%;
		animation: skeleton-loading 1.5s infinite;
	}

	// 骨架屏线条尺寸
	.skeleton-line-xs {
		height: 28rpx;
		width: 200rpx;
		margin-top: 16rpx;
	}

	.skeleton-line-sm {
		height: 32rpx;
		width: 300rpx;
	}

	.skeleton-line-md {
		height: 36rpx;
		width: 240rpx;
	}

	.skeleton-line-full {
		height: 36rpx;
		width: calc(100% - 60rpx);
	}

	// 骨架屏动画
	@keyframes skeleton-loading {
		0% {
			background-position: 200% 0;
		}

		100% {
			background-position: -200% 0;
		}
	}

	// 骨架屏容器样式
	.skeleton-container {
		overflow: hidden;
	}

	// 骨架屏卡片样式
	.skeleton-card {
		background-color: #fff;
	}

	.skeleton-settings {
		background-color: #fff;
	}

	.skeleton-item {
		border-bottom: 1rpx solid #f0f0f0;
	}

	.skeleton-item:last-child {
		border-bottom: none;
	}

	.skeleton-tip-card {
		background-color: #fff;
	}
</style>