<template>
	<view>
		<view class="container" v-if="payList.length">
			<view class="page">
				<view class="paycost">
					<view class="item" @click="onPayFree(item.chargeTypeCode)" v-for="item in payList" :key="item.chargeTypeCode">
						<view class="information">
							<view class="image">
								<image v-if="item.chargeTypeCode === 'SFLX00001'" src="../../static/images/paycost01.png" class="icon"></image>
								<image v-else-if="item.chargeTypeCode === 'SFLX00002'" src="../../static/images/paycost02.png" class="icon"></image>
								<image v-else-if="item.chargeTypeCode === 'SFLX00003'" src="../../static/images/paycost03.png" class="icon"></image>
								<image v-else-if="item.chargeTypeCode === 'SFLX00004'" src="../../static/images/paycost04.png" class="icon"></image>
								<image v-else-if="item.chargeTypeCode === 'SFLX00005'" src="../../static/images/paycost05.png" class="icon"></image>
								<image v-else src="../../static/images/paycost06.png" class="icon"></image>
							</view>
							<view class="title">
								<view class="name">{{item.chargeTypeName}}<view class="tag" v-if="item.waitPay > 0">待缴费</view></view>
								<view class="add">
									<text>待缴账单：<text style="color: #6A59F2">{{item.waitPay}}</text></text>
									<text style="margin-left:30rpx">已缴账单：<text style="color: #13c2c2">{{item.havePay}}</text></text>
								</view>
							</view>
						</view>
						<uni-icons type="forward" color="#E4E4EA"></uni-icons>
					</view>
				</view>
			</view>
		</view>
		<no-data :show="payList.length === 0" text="暂无缴费信息"></no-data>
	</view>
</template>

<script>
	import {
		queryChargeApi
	} from '@/config/api.js'
	import noData from '@/components/no-data/no-data'
	export default {
		components: {noData},
		data() {
			return {
				payList: []
			}
		},
		methods: {
			async getList() {
				let res = await queryChargeApi()
				this.payList = res.result
			},
			onPayFree(code) {
				uni.navigateTo({
					url: `/pages/payCostProperty/index?code=${code}`,
				});
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		background-position: top center;
		background-repeat: no-repeat;
		background-size: cover;
		background-image: url('https://life.cloud.hjxbc.cn/sys/common/static/miniapp/bg_pay.png');
	}

	.page {
		padding: 0 30rpx;
	}

	.paycost {
		padding: 30rpx 0;
		box-sizing: border-box;
		min-height: 100vh;
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		flex-direction: column;

		.item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #ffffff;
			border-radius: 16rpx;
			padding: 54rpx 50rpx;
			margin-bottom: 40rpx;

			.information {
				display: flex;
				justify-content: center;
				align-items: center;

				.image {
					width: 76rpx;
					height: 76rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					background-color: #EEECFE;
					border-radius: 76rpx;

					.icon {
						width: 44rpx;
						height: 44rpx;
					}
				}


				.title {
					margin-left: 20rpx;

					.name {
						font-size: 32rpx;
						color: #373737;
						font-weight: bold;
						display: flex;
						margin-bottom: 15rpx;

						.tag {
							height: 36rpx;
							line-height: 36rpx;
							font-size: 22rpx;
							padding: 0 20rpx;
							border-radius: 30rpx;
							display: inline-block;
							color: #F42E2E;
							border: 1px solid #F42E2E;
							background-color: #FFF5F5;
							margin-left: 20rpx;
						}
					}

					.add {
						font-size: 28rpx;
						color: #9D9CA6;
					}

				}

			}

		}
	}
</style>