<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 2" :key="index">
						<text>{{index==0?"费用预存":index==1?"缴费记录":""}}</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￥{{money}}</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 djList" :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>{{item.month}}</text>
							<text style="color: #EE0101;">￥{{item.money}}</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>房屋面积：{{item.sqm}}</text>
							<text>单价/平米：￥{{item.price}}</text>
							<text>金额：{{item.money}}</text>
						</view>
					</view>
				</view>
				<view v-if="indexTab==1&&djList.length==0" style="padding-top: 100rpx;">
					<u-empty mode="data"></u-empty>
				</view> -->
				<view v-if="indexTab==1" 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;">
							{{$wskj.isNull(item.startTime)? '':item.startTime.slice(0,10)}}～{{$wskj.isNull(item.endTime)? '':item.endTime.slice(0,10)}}</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.updateTime.slice(5)}}</text>
					</view>
				</view>
				<view v-if="indexTab==1&&jfjlList.length==0" style="padding-top: 100rpx;">
					<u-empty mode="data"></u-empty>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

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

			};
		},
		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
				// if (index == 1) {
				// 	this.getDjList()
				// 	return
				// }
				if (index == 1) {
					this.getJfjlList()
					return
				}
			},
			onClick(index) {
				this.indexNumber = index
			},
			//类型（1电费 2水费 3物业费 4车位管理费 5车位出租费 6储藏室出租 7其他费用）
			getDjList() {
				const params = {
					url: '/api/liveBill/listAll?type=3',
					method: 'GET',
				}
				this.$request(params).then(res => {
					let money = 0
					this.djList = res.data
					res.data.forEach(item => {
						money = money + parseFloat(item.money)
					})
					this.money = money.toFixed(2)
				})
			},
			getJfjlList() {
				const params = {
					url: '/api/payRecord/listAll?type=3',
					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>