<template>
	<view class="tab_page" :style="{'height':h+'px', 'padding-top':mt+'px'}">
		<up-navbar title=" " bgColor="transparent">
			<template #left></template>
		</up-navbar>
		<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/9043fbbe-2e5d-4adb-ba36-039d33a9b694.png" class="top_bg_img" mode="widthFix"></image>
		<div class="info">
			<div class="info-top adfacjb">
				<div class="info-top-left adfac">
					<image class="avatar" :src="userInfo?userInfo.avatar:'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/6db27a79-235b-4595-87f2-89ff09fc66a5.png'"></image>
					<div class="text">
						<div class="text-top">{{userInfo?userInfo.name:'未登录'}}</div>
						<div class="text-bottom" v-if="userInfo"></div>
						<div class="text-bottom" v-else @tap="showLogin">去登录注册&nbsp;>></div>
					</div>
				</div>
				<div class="info-top-right" @tap="handleTurnPage('/pagesMy/information')">
					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/d0319d8d-1445-47d6-94fa-cb934e022ab8.png"></image>
				</div>
			</div>
			<div class="info-tip">
				<div class="info-tip-pre adfacjb">
					<div class="left">家庭公益名称：{{userInfo?userInfo.xxx:'暂无'}}</div>
					<div class="right">
						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/79079542-4711-44e8-9246-9cd1b8ea4e39.png"></image>
					</div>
				</div>
				<div class="info-tip-pre adfacjb">
					<div class="left">家庭公益口号：{{userInfo?userInfo.xxx:'暂无'}}</div>
					<div class="right">
						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/79079542-4711-44e8-9246-9cd1b8ea4e39.png"></image>
					</div>
				</div>
			</div>
		</div>
		<div class="box" style="margin-top: 40rpx;">
			<div class="box-title">公益记录</div>
			<div class="box-card adfacjb">
				<div class="box-card-pre adffcac red" @tap="handleTurnPage('/pagesMy/heartNumber')">
					<image class="top" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/4e6e3db8-127f-433d-9644-66f1451a6d72.png"></image>
					<div class="num">{{(heartNum||0).toFixed(2)}}</div>
					<div class="text adf">
						<text>我的爱心值</text>
						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/35df3e58-7b8c-4d3c-8f09-41f252cb3805.png"></image>
					</div>
				</div>
				<div class="box-card-pre adffcac purple" @tap="handleTurnPage('/pagesMy/archives')">
					<image class="top" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/dc26c6af-2617-47b7-ab38-9ccbf2016c5c.png"></image>
					<div class="num">{{(fileNum||0).toFixed(2)}}</div>
					<div class="text adf">
						<text>我的档案</text>
						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/51adb43e-acdd-475e-9e3d-64cbeedd4fe4.png"></image>
					</div>
				</div>
				<div class="box-card-pre adffcac orange" @tap="handleTurnPage('/pagesMy/volunteerHours')">
					<image class="top" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/c5048d96-826e-4bbf-a133-dd2115162746.png"></image>
					<div class="num">{{(hourNum||0).toFixed(2)}}</div>
					<div class="text adf">
						<text>义工时长(h)</text>
						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/9bdc2845-e4bc-4215-82d0-9582066b710f.png"></image>
					</div>
				</div>
			</div>
		</div>
		<div class="box" @tap="handleTurnPage('/pagesMy/achievement')">
			<div class="box-title">我的成就</div>
			<div class="box-achievement adfacjb">
				<div class="box-achievement-left">收获<span>{{achievement}}</span>项成就</div>
				<div class="box-achievement-right adfacjb">
					<div class="imgs"></div>
					<div class="jt">
						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/79079542-4711-44e8-9246-9cd1b8ea4e39.png"></image>
					</div>
				</div>
			</div>
		</div>
		<div class="box">
			<div class="box-title">其他功能</div>
			<div class="box-other adfacjb">
				<div class="box-other-pre adffcac" @tap="handleTurnPage('/pagesMy/practice')">
					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/53fb5a7a-e7fb-4e5d-b902-f434cfc6d786.png"></image>
					<text>申领社会实践记录</text>
				</div>
				<div class="box-other-pre adffcac">
					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/06acc5f2-45e8-43ea-96a3-c17e79a190bc.png"></image>
					<text>家庭成员</text>
				</div>
				<div class="box-other-pre adffcac" @tap="handleTurnPage('/pagesMy/exclusiveScroll')">
					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/7746f429-615d-4e1b-8564-c943f07882be.png"></image>
					<text>我的专享卷</text>
				</div>
			</div>
		</div>
		<CusTabbar :tabbarIndex="2"></CusTabbar>
		<login-register></login-register>
	</view>
</template>

<script setup name="">
	import CusTabbar from '@/components/CusTabbar/index.vue'
	import { ref, getCurrentInstance } from 'vue'
	const { proxy } = getCurrentInstance();
	import { useUserStore } from '@/common/stores/user';
	const userStore = useUserStore();
	import { useGlobalShare } from '@/common/composables/useGlobalShare';
	const { isLogin } = useGlobalShare();
	
	const userInfo = ref(null)
	const heartNum = ref(0)
	const fileNum = ref(0)
	const hourNum = ref(0)
	const achievement = ref(0)
	
	const showLogin = () => {
		userStore.openLoginModal();
	}
	
	const handleTurnPage = (url) => {
		if(!isLogin()) return
		uni.navigateTo({ url })
	}
</script>

<style scoped lang="scss">
	.tab_page{
		.info{
			margin-top: 40rpx;
			position: relative;
			padding: 0 24rpx 0 16rpx;
			&-top{
				&-left{
					.avatar{
						width: 148rpx;
						height: 148rpx;
					}
					.text{
						margin-left: 24rpx;
						&-top{
							font-family: PingFang-SC, PingFang-SC;
							font-weight: bold;
							font-size: 40rpx;
							color: #151B29;
							line-height: 40rpx;
						}
						&-bottom{
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							font-size: 26rpx;
							color: #151B29;
							line-height: 26rpx;
							margin-top: 26rpx;
						}
					}
				}
				&-right{
					image{
						width: 48rpx;
						height: 48rpx;
					}
				}
			}
			&-tip{
				margin-top: 4rpx;
				&-pre{
					margin-top: 36rpx;
					.left{
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #252525;
						line-height: 28rpx;
					}
					.right{
						image{
							width: 32rpx;
							height: 32rpx;
						}
					}
				}
			}
		}
		.box{
			background: #FFFFFF;
			border-radius: 24rpx;
			padding: 40rpx 24rpx 36rpx;
			margin-top: 20rpx;
			position: relative;
			&-title{
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 36rpx;
				color: #151B29;
				line-height: 40rpx;
			}
			&-card{
				margin-top: 72rpx;
				&-pre{
					width: calc(100% / 3 - 8rpx);
					height: 200rpx;
					position: relative;
					background-size: 100% 100%;
					background-repeat: no-repeat;
					.top{
						width: 82rpx;
						height: 82rpx;
						position: absolute;
						left: 50%;
						margin-left: -41rpx;
						top: -32rpx;
					}
					.num{
						font-family: DINAlternate, DINAlternate;
						font-weight: bold;
						font-size: 40rpx;
						line-height: 40rpx;
						text-align: center;
						margin-top: 86rpx;
					}
					.text{
						margin-top: 20rpx;
						text{
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							font-size: 24rpx;
							line-height: 24rpx;
						}
						image{
							width: 26rpx;
							height: 26rpx;
							margin-left: 6rpx;
						}
					}
					&.red{
						background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/0b81f526-1698-459f-9428-f875c91c9e23.png');
						.num,.text text{
							color: #FC5768;
						}
					}
					&.purple{
						background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/cca2576e-318c-4cbc-8e42-67c27b6882e4.png');
						.num,.text text{
							color: #8360E8;
						}
					}
					&.orange{
						background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/ce8e6415-4490-41e9-b04c-292e6344f9ed.png');
						.num,.text text{
							color: #FF8200;
						}
					}
				}
			}
			&-achievement{
				margin-top: 24rpx;
				&-left{
					width: 210rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #676775;
					line-height: 24rpx;
					label{
						font-weight: bold;
						font-size: 32rpx;
						color: #EA3044;
						line-height: 32rpx;
						margin: 0 7rpx;
					}
				}
				&-right{
					width: calc(100% - 210rpx);
					.jt{
						image{
							width: 32rpx;
							height: 32rpx;
						}
					}
				}
			}
			&-other{
				margin-top: 39rpx;
				&-pre{
					width: calc(100% / 3);
					image{
						width: 48rpx;
						height: 48rpx;
					}
					text{
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #151B29;
						line-height: 33rpx;
						text-align: center;
						margin-top: 16rpx;
					}
				}
			}
		}
	}
</style>