<template>
	<view class="pos-r padding-lr-sm">
		<use-tabbar :tabbar="false" />
		<view class="record-list margin-top-sm margin-bottom-sm" v-if="fetch.parent == 1">
			<view>
				<view class="record-title fs fwbd ft-black margin-bottom-sm">上级信息</view>
				<view class="record-item"
					@click="Dever.pic.preview([fetch.parent_info.avatar], fetch.parent_info.avatar)">
					<view class="record-left">
						<image class="record-avatar" :src="fetch.parent_info.avatar" mode="aspectFill"></image>
						<view class="record-info">
							<view class="record-name">{{ fetch.parent_info.name }}</view>
							<view class="record-time">{{ fetch.parent_info.cdate_str }}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="gold-section">
			<view class="item dflex dflex-flow-c">
				<text>共{{page}}个成员</text>
			</view>
		</view>
		<!-- 记录列表 -->

		<view class="record-list margin-top-sm" v-if="fetch">
			<view class="record-title fs fwbd ft-black margin-bottom-sm">成员列表</view>
			<u-empty v-if="fetch.list && fetch.list.length <= 0" marginTop="30" mode="data" text="暂无记录"></u-empty>

			<view v-else>
				<view class="record-item" v-for="(item, index) in fetch.list" :key="index"
					@click="Dever.pic.preview([item.avatar], item.avatar)">
					<view class="record-left">
						<image class="record-avatar" :src="item.avatar" mode="aspectFill"></image>
						<view class="record-info">
							<view class="record-name">{{ item.name }}</view>
							<view class="record-time">{{ item.cdate_str }}</view>
						</view>
					</view>
					<view class="record-amount lock">
						<text>{{ item.order }}</text>
					</view>
				</view>
			</view>
		</view>

		<view class="safe-area-inset-bottom"></view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				fetch: {},
				page: 0,
			};
		},
		onLoad() {
			this.loadData(1);
		},
		//下拉刷新
		onPullDownRefresh() {
			this.loadData(1);
		},
		//加载更多
		onReachBottom() {
			this.loadData(2);
		},
		methods: {
			loadData(page) {
				this.DeverApi.page([page, 'list'], this, 'user.getGroup', {}, res => {
					this.page = res.page;
				});
			},
		}
	};
</script>
<style lang="scss">
	.gold-section {
		background: #ffffff;
		border-radius: 24rpx;
		padding: 32rpx;

		.dflex-b {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}

		.title {
			font-size: 32rpx;
			font-weight: bold;
			color: #333;
		}

		.link {
			font-size: 24rpx;
			color: #ff9800;
			text-decoration: underline;
		}

		.balance-number {
			margin-top: 20rpx;

			.price {
				font-size: 48rpx;
				color: #ff9800;
				font-weight: bold;
			}
		}

		.amount-summary {
			display: flex;
			justify-content: space-between;
			margin-top: 32rpx;

			.summary-item {
				flex: 1;
				display: flex;
				flex-direction: column;

				.label {
					font-size: 24rpx;
					color: #888;
				}

				.value {
					margin-top: 10rpx;
					font-size: 30rpx;
					font-weight: 600;
					color: #333;
				}
			}
		}
	}

	.card-tile {
		border-radius: 24rpx;
		padding: 30rpx;
		background: #ffffff;
		display: flex;
		align-items: center;
		justify-content: center;
		transition: all 0.2s ease-in-out;

		.icon {
			font-size: 60rpx;
			margin-right: 24rpx;
		}

		.text-content {
			display: flex;
			flex-direction: column;

			.title {
				font-size: 30rpx;
				font-weight: 600;
				color: #333;
			}

			.desc {
				font-size: 24rpx;
				color: #999;
				margin-top: 6rpx;
			}
		}

		&:active {
			transform: scale(0.97);
		}

		&:first-child {
			margin-right: 10rpx;
		}
	}

	.wpre-50 .card-tile {
		&:first-child {
			margin-bottom: 12rpx;
			margin-right: 0rpx;
		}
	}

	.record-list {
		background: #ffffff;
		border-radius: 20rpx;
		padding: 30rpx;

		.record-title {
			font-size: 30rpx;
			font-weight: bold;
			color: #333;
		}

		.record-item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 0;
			border-bottom: 1px solid #f0f0f0;

			&:last-child {
				border-bottom: none;
			}

			.record-left {
				display: flex;
				align-items: center;

				.record-avatar {
					width: 84rpx;
					height: 84rpx;
					border-radius: 50%; // 圆形头像
					margin-right: 20rpx;
				}

				.record-info {
					display: flex;
					flex-direction: column;

					.record-name {
						font-size: 28rpx;
						color: #333;
					}

					.record-time {
						font-size: 24rpx;
						color: #999;
						margin-top: 6rpx;
					}
				}

				.record-name {
					font-size: 28rpx;
					color: #333;
				}

				.record-desc {
					font-size: 28rpx;
					color: #999;
				}

				.record-time {
					font-size: 24rpx;
					color: #999;
					margin-top: 6rpx;
				}
			}

			.record-amount {
				font-size: 28rpx;
				font-weight: bold;

				&.income {
					color: #4caf50;
				}

				&.expense {
					color: #f44336;
				}

				&.lock {
					color: #999;
				}
			}
		}
	}

	.empty-record {
		text-align: center;
		padding: 60rpx 0;

		.empty-icon {
			width: 160rpx;
			height: 160rpx;
			margin-bottom: 20rpx;
			opacity: 0.6;
		}

		.empty-text {
			font-size: 28rpx;
			color: #999;
		}
	}
</style>