<template>
	<view class="statistics-box">
		<view class="label-box" @click.stop="isShow = !isShow">
			<text class="iconfont label-icon">&#xe808;</text>
			<text class=" label-name one-row">{{ Vo.dayValue }}</text>
			<text class="label-text">+{{ Vo.actualReceivePayment }}</text>
			<text :class="['iconfont', 'label-next' , isShow ? 'open-icon' : '' ]">&#xe671;</text>
		</view>
		<view :class="['animation-box']" :style="{height:(isShow ? ContentHeight : 0) +'px'}">
			<view class="statistics-content">
				<view class="money-content">
					<view class="money-item" v-for="item in MoneyContent">
						<view class="money-value">
							<text class="money-tag">{{item.tag}}</text>
							<text class="money-num">{{ numCapture(Vo[item.key] , 'Integer') }}.</text>
							<text class="money-n">{{ numCapture(Vo[item.key] , 'Decimals') }}</text>
						</view>
						<text class="money-text">{{item.label}}</text>
					</view>
				</view>
				<view class="integral-content money-content">
					<view class="integral-item money-item" v-for="item in IntegralContent">
						<view class="integral-value money-value">
							<text class="money-num">{{ numCapture(Vo[item.key] , 'Integer') }}.</text>
							<text class="money-n">{{ numCapture(Vo[item.key] , 'Decimals') }}</text>
						</view>
						<text class="money-text">{{item.label}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { getCurrentInstance, onMounted, ref } from "vue";
	import { numCapture } from "@/util/Filters.ts";

	defineProps({
		Vo: {
			type: Object,
			default: () => { }
		}
	});

	const MoneyContent = [
		{
			label: '实际收款',
			tag: '￥',
			key: 'actualReceivePayment'
		},
		{
			label: '实际到账',
			tag: '￥',
			key: 'actualCredited'
		},
		{
			label: '预估结算',
			tag: '￥',
			key: 'todaySettlement'
		}
	];
	const IntegralContent = [
		{
			label: '用户消耗积分',
			key: 'userUsePoint'
		},
		{
			label: '店铺发放积分',
			key: 'businessGivePoint'
		}
	];

	const instance = getCurrentInstance();
	const isShow = ref(false);
	const ContentHeight = ref(0)
	onMounted(() => {
		try {
			const query = uni.createSelectorQuery().in(instance);
			query
				.select(".statistics-content")
				.boundingClientRect((data) => {
					ContentHeight.value = data.height
				})
				.exec();
		} catch (error) {
			console.log("query ==error= ", error)
			//TODO handle the exception
		}
	})
</script>

<style lang="scss" scoped>
	$pad_lr: 30rpx;
	$s_: 0.3s;

	.statistics-box {
		background-color: #fff;
		border-radius: 24rpx;
		overflow: hidden;
	}

	.label-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 $pad_lr;
		width: 100%;
		height: 100rpx;
		background-color: #fff;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		box-sizing: border-box;
		border-bottom: 1rpx solid #f7f7f7;

		.label-icon {
			font-size: 38rpx;
			color: #FFAD00;
		}

		.label-name {
			flex: 1;
			padding: 0 12rpx;
			font-size: 32rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			color: #1a1a1a;
		}

		.label-text {
			color: #5CBD76;
			padding-right: 10rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
		}

		.label-next {
			color: #000000;
			transform: rotate(90deg);
			transition: transform $s_;
		}

		.open-icon {
			transform: rotate(-90deg);
		}
	}

	.animation-box {
		width: 100%;
		transition: height $s_;
		overflow: hidden;
	}

	.statistics-content {
		box-sizing: border-box;
		width: 100%;
		padding: $pad_lr;

		.money-content {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #F7F6F6;
			border-radius: 20rpx;

			.money-item {
				box-sizing: border-box;
				flex: 1 0;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				padding: $pad_lr;
				position: relative;

				&:before {
					box-sizing: border-box;
					content: '';
					position: absolute;
					left: 0;
					top: 50%;
					width: 1rpx;
					height: calc(100% - $pad_lr - $pad_lr);
					background-color: #e6e5e5;
					transform: translateY(-50%);
				}

				&:first-child {
					&:before {
						display: none;
					}
				}

				.money-value {
					display: flex;
					justify-content: center;
					align-items: baseline;
					font-weight: normal;
					color: #eb5153;

					.money-tag {
						font-size: 26rpx;
					}

					.money-num {
						font-size: 32rpx;
						font-weight: 600;
					}

					.money-n {
						font-size: 26rpx;
						font-weight: 600;
					}
				}

				.money-text {
					padding-top: 10rpx;
					font-size: 26rpx;
					font-family: PingFang SC, PingFang SC-Regular;
					font-weight: 400;
					text-align: center;
					color: #666666;
				}
			}
		}

		.integral-content {
			margin-top: 20rpx;

			.integral-item {
				.integral-value {
					color: #f29b3a;
				}

				// .integral-text{
				// 	padding-top: 10rpx;
				// 	font-size: 26rpx;
				// 	font-family: PingFang SC, PingFang SC-Regular;
				// 	font-weight: 400;
				// 	text-align: center;
				// 	color: #666666;
				// }
			}
		}
	}
</style>