<template>
	<view class="center plr-25">
		<view class="flex-column-center fs-30 mt-30 h-140 pb-30 br-12 plr-25"
			style="background: linear-gradient( 90deg, #5FE8A9 0%, #1FCA7C 100%);color: white;">
			<image class="w-42 h-42 mr-20" src="/pagesMain/static/icon_cz_img.png"></image>
			<text>物业费：{{userinfo.room}}</text>
		</view>
		<view class="flex-column br-12" style="margin-top: -50rpx;background:white;">
			<view class="flex-column">
				<view class="flex">
					<view @click="onTabClick(index)" class="h-50 flex-column flex-between-center fs-28 pad-30"
						style="flex: 1;" :style="{ color: index==indexTab?'#333333':'#999999'}"
						v-for="(item, index) in 3" :key="index">
						<text>{{index==0?"费用预存":index==1?"待缴查看":index==2?"缴费记录":""}}</text>
						<view v-if="index==indexTab" style="background: #27CC81;height: 1rpx;width: 77rpx;">
						</view>
						<view v-else style="background: #FFFFFF;height: 1rpx;width: 77rpx;">
						</view>
					</view>
				</view>
				<text v-if="indexTab==1" class="fs-30 fw-700 ">未缴金额\n￥1355.04</text>
			</view>
		</view>
		<view class="overflow-y" style="background: white;">
			<scroll-view scroll-y style="height:100%;">
				<view v-if="indexTab==1" v-for="(item, index) in jfjlList" :key="index" @click="onClick(index)">
					<view class="flex-column fs-24 mar-20 pb-20" style="border-bottom: 1rpx solid #E9E9E9;">
						<view class="flex v-center fs-28">
							<text>2025年01月</text>
							<text style="color: #EE0101;">￥{{item.payAmount}}</text>
							<image style="width: 20rpx;height: 20rpx;" src="/pagesMain/static/icon_zksq_1.png">
							</image>
						</view>
						<view v-if="indexNumber==index" class="flex-column mt-20 fs-24"
							style="color: #999999;text-align: left;">
							<text>缴费项目：物业管理费</text>
							<text>房屋面积：72.15</text>
							<text>单价/平米：￥1.3</text>
							<text>金额：{{item.payAmount}}</text>
						</view>
					</view>
				</view>
				<view v-if="indexTab==2" v-for="(item, index) in jfjlList" :key="index" @click="onClick(index)">
					<view class="flex-column fs-24 mb-20" style="text-align: left;">
						<text class="fs-28 h-80 lh-80 plr-25" style="background:#F2F2F2;">{{item.month}}</text>
						<view class="flex-row-between plr-25 mtb-20">
							<text style="color: #999999;">缴费渠道：线上缴费</text>
							<text>{{item.payAmount}}</text>
						</view>
						<text class="plr-25" style="color: #999999;">{{item.month}}</text>
					</view>
				</view>
			</scroll-view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				indexTab: 1,
				indexNumber: 0,
				type: 0,
				userinfo: '',
				jfjlList: [],
				djList: [],

			};
		},
		onLoad(options) {
			this.type = options.type
			this.userinfo = uni.getStorageSync("userInfo")
			this.getDjList()
			this.getJfjlList()

		},
		methods: {
			onTabClick(index) {
				if (index == 0) {
					this.$wskj.to("/pagesMain/pages/jnzd_wyf")
					return
				}
				this.indexTab = index
			},
			onClick(index) {
				this.indexNumber = index
			},
			//类型（1电费 2水费 3物业费 4车位管理费 5车位出租费 6储藏室出租 7其他费用）
			getDjList() {
				const params = {
					url: '/api/liveBill/listAll?type=1',
					method: 'GET',
				}
				this.$request(params).then(res => {
					this.djList = res.data
				})
			},
			getJfjlList() {
				const params = {
					url: '/api/payRecord/listAll?type=1',
					method: 'GET',
				}
				this.$request(params).then(res => {
					this.jfjlList = res.data
				})
			},

		}
	};
</script>

<style>
	.center {
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: #F2F2F2;
	}

	.grid-container {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-around; // 可以根据需求调整元素的水平排列方式，这里是均匀分布
		align-items: center; // 垂直方向居中对齐
	}

	.grid-item {
		width: 32%;
		height: 80rpx; // 宫格高度
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background: #F2F2F2;
		border-radius: 12rpx;
		margin-top: 10rpx;
	}
</style>