<template>
	<view class="container">
		<view class="info-box">
			<view class="info-item">
				用&nbsp;&nbsp;户&nbsp;名：{{user.name}}
			</view>
			<view class="info-item">
				任职机构：{{user.corpName ?? '无'}}
			</view>
		</view>
		<view class="list-box">
			<view class="list-item-box">
				<view class="list-item">
					年份
				</view>
				<view class="list-item">
					是否缴费
				</view>
				<view class="list-item">
					会籍情况
				</view>
			</view>
			<view class="list-item-box" v-for="(item, index) in listData" :key="index">
				<view class="list-item">
					{{item.year}}
				</view>
				<view class="list-item">
					{{item.payed ? '是' : '否'}}
				</view>
				<view class="list-item">
					<view class="button" :class="[item.payed ? '' : 'error']" @click="onJiaoFei(item)">
						{{item.payed ? '正常' : '失效，点击缴费'}}
					</view>
				</view>
			</view>
		</view>
		<view class="desc-box">
			<!-- <rich-text :nodes="explain"></rich-text> -->
			<mp-html :content="explain" />
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import { useAuthStore } from '@/store/authStore'
	
	import { list } from '@/api/cost.js'
	const authStore = useAuthStore()
	
	// 用户信息
	const user = ref({
		userIcon: '1',
		name: '某某某',
		corpName: '广州市xx地产有限公司',
		corpRegNo: '123xxxx'
	})
	
	const listData = ref([
	])
	const explain = ref(`
	<p><span style="font-size: 14px;"></span></p><p style="line-height:150%"><span style="font-size: 14px; font-family: arial, helvetica, sans-serif;"><strong><span style="font-size: 14px; line-height: 150%;">会员会费缴交规则：</span></strong></span></p><p style="line-height:150%"><span style="line-height: 150%; font-family: arial, helvetica, sans-serif; font-size: 12px;">根据《广州市房地产中介协会章程》第五十六条，会费标准如下：</span></p><p style="line-height:150%"><span style="text-indent: 32px; font-family: arial, helvetica, sans-serif; font-size: 12px;"><span style="font-size: 12px; font-family: 宋体; text-indent: 32px; text-wrap-mode: wrap;">•&nbsp;</span>副会长单位：50000元/年；</span></p><p style="line-height:150%"><span style="text-indent: 32px; font-family: arial, helvetica, sans-serif; font-size: 12px;"><span style="font-size: 12px; font-family: 宋体; text-indent: 32px; text-wrap-mode: wrap;">•&nbsp;</span>理事单位：10000元/年；</span></p><p style="line-height:150%"><span style="text-indent: 32px; font-family: arial, helvetica, sans-serif; font-size: 12px;"><span style="font-size: 12px; font-family: 宋体; text-indent: 32px; text-wrap-mode: wrap;">•&nbsp;</span>普通会员单位：1000元/年；</span></p><p style="line-height:150%"><span style="text-indent: 32px; font-family: arial, helvetica, sans-serif; font-size: 12px;"><span style="font-size: 12px; font-family: 宋体; text-indent: 32px; text-wrap-mode: wrap;">•&nbsp;</span>个人会员：200元/年/人。</span></p><p><span style="font-family: arial, helvetica, sans-serif; font-size: 12px;">单位会员会籍为每年1月1日至12月31日；</span></p><p><span style="font-family: arial, helvetica, sans-serif; font-size: 12px;">个人会员会籍为每年5月1日至次年4月30日。</span></p><p>&nbsp;&nbsp;&nbsp;&nbsp;</p><p><br/></p>
	`)
	function onJiaoFei(val) {
		if (val.payed) {
			return
		}
		uni.navigateTo({
			url: `/pages/geRenHuiFeiJiaoJiao/geRenHuiFeiJiaoJiao?year=${val.year}&duePrice=${val.duePrice}`
		})
	}
	
	onLoad(() => {
		user.value = authStore.userInfo
		list().then(res => {
			if (res && res.message === 'success') {
				listData.value = res.data
			}
		})
	})
</script>

<style lang="scss" scoped>
	.container {
		min-height: 100vh;
		width: 100vw;
		background: rgb(141, 204, 255);
		background: -moz-linear-gradient(   90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
		background: -webkit-linear-gradient(90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
		background: -o-linear-gradient(     90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
		background: -ms-linear-gradient(    90deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
		background: linear-gradient(       180deg, rgb(141, 204, 255) 10%, rgb(247, 247, 247) 30%);
		
		.info-box {
			margin: 0 20rpx;
			padding: 0 40rpx;
			padding-top: 50rpx;
			margin-bottom: 30rpx;
			.info-item {
				margin-bottom: 10rpx;
				font-size: $uni-title-font-size-2;
				font-weight: bold;
				letter-spacing: 3rpx;
			}
		}
		
		.list-box {
			margin: 0 20rpx;
			background-color: $uni-bg-color-grey;
			border-radius: $uni-card-border-radius;
			padding: 20rpx 15rpx;
			margin-bottom: 30rpx;
			.list-item-box {
				&:first-child {
					border-bottom: 5rpx solid #E6E6E6;
					font-size: $uni-font-size-1;
					font-weight: bold;
					.list-item {
						width: calc(100% / 3);
						text-align: center;
						&:last-child {
							color: #303133;
							font-weight: bold;
						}
					}
				}
				padding: 20rpx 0;
				text-align: center;
				font-size: $uni-font-size-1;
				font-weight: bold;
				display: flex;
				align-items: center;
				.list-item {
					width: calc(100% / 3);
					text-align: center;
					&:last-child {
						font-weight: normal;
					}
				}
				
				.button {
					width: fit-content;
					border-radius: $uni-card-border-radius;
					color: #303133;
					margin: 0 auto;
				}
				.primary {
					padding: 5rpx 25rpx;
					background-color: $uni-color-primary;
				}
				.error {
					padding: 5rpx 15rpx;
					color: $uni-text-color-inverse;
					background-color: $uni-color-error;
				}
			}
		}
	
		.desc-box {
			margin: 0 20rpx;
			padding-bottom: 30rpx;
			font-weight: bold;
		}
	}
</style>