<template>
	<view class="member-card-box">
		<navigation-bar-vue title="会员中心" background-color="#262626" title-color="#FFFFFF"></navigation-bar-vue>
		<view class="main-body">
			<!-- 会员卡展示区 -->
			<view class="vip-box">
				<view class="dl-menu-box">
					<view v-for="(item,index) in memberCardList" @click="itemClick(index)" class="dl-menu"
						:class="item.id==chooseCardId?'dl-menu click':'dl-menu'">
						<!-- 这里的图标要换成动态配置的 -->
						<image src="@/static/mine/huang.png" mode="aspectFit"></image>
						{{item.cardName}}
					</view>
				</view>
				<!-- 会员卡详情 -->
				<view class="card-detail-box">
					<view class="price-box">
						<view class="price-item">
							<view>年付会员</view>
							<view><text>¥</text>228</view>
							<view>折合0.82</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 权益展示区 -->
			<view class="rights-box">
				<view class="rights-item title">
					<view class="title-left">会员权益</view>
					<view class="value-item" v-for="(item,index) in cardList">{{item.name}}</view>
				</view>
				<view class="rights-item item-bg" v-for="(item,index) in rightsList">
					<view class="title-left">{{item.name}}</view>
					<view :class="[i==cardList.length-1?'value-item yellow-bg':'value-item']"
						v-for="(card,i) in cardList">
						<view v-if="'02'==item.rightsType">
							<!-- 数量限制 -->
							<text v-if="0==item.cardRights[card.id]">无限</text>
							<text v-else>{{item.cardRights[card.id]}}条</text>
						</view>
						<view v-else-if="'01'==item.rightsType">
							<!-- 是否支持 -->
							<text v-if="0==item.cardRights[card.id]">-</text>
							<view v-else>
								<uni-icons v-if="i==cardList.length-1" color="#3A3A38" type="checkmarkempty"
									size="18"></uni-icons>
								<uni-icons v-else color="#E8CEAD" type="checkmarkempty" size="18"></uni-icons>
							</view>
						</view>
					</view>
				</view>
				<view class="rights-item item-bg">
					<view class="title-left">每日报名上限</view>
					<view class="value-item">20条</view>
					<view class="value-item">无限</view>
					<view class="value-item yellow-bg">无限</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import navigationBarVue from '@/components/navigation/navigationBar.vue';
	export default {
		components: {
			navigationBarVue
		},
		data() {
			return {
				//当前选中的会员卡ID
				chooseCardIndex: 0,
				// 会员卡数组
				memberCardList: [{
					id: "1",
					cardName: "箐英会员",
					image: "",
					monthPrice: 28,
					quarterPrice: 78,
					yearPrice: 228,
					dayPrice: 0.82
				}, {
					id: "2",
					cardName: "钻石会员",
					image: "",
					monthPrice: 28,
					quarterPrice: 78,
					yearPrice: 228,
					dayPrice: 0.82
				}],
				//权益对比的数组
				cardList: [{
					id: '1',
					name: '非会员'
				}, {
					id: '2',
					name: '箐英'
				}, {
					id: '3',
					name: '钻石'
				}],
				rightsList: [{
					name: "每日解锁通告上限",
					// 权益类型  01-是否支持  |  02-数量限制
					rightsType: '02',
					cardRights: {
						"1": 20,
						"2": 0,
						"3": 0
					}
				}, {
					name: "高奖励&最新通告",
					// 权益类型  01-是否支持  |  02-数量限制
					rightsType: '01',
					cardRights: {
						"1": 0,
						"2": 1,
						"3": 1
					}
				}]
			}
		},
		methods: {
			/**
			 * 菜单点击
			 * @param {Object} index
			 */
			itemClick(index) {
				this.chooseCardIndex = index
			},
		}
	}
</script>

<style lang="scss">
	.member-card-box {
		width: 100%;
		color: #363636;
		font-size: 29rpx;
		background-color: #262626;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: relative;

		.main-body {
			width: 100%;
			min-height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 57rpx);
			padding: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: flex-start;

			.vip-box {
				width: 100%;
				flex-direction: column;
				align-items: center;
				justify-content: flex-start;
				padding-bottom: 20rpx;

				.dl-menu-box {
					display: flex;
					align-items: center;
					justify-content: flex-start;
					width: 100%;
					color: #888888;
					padding-top: 20rpx;

					.dl-menu {
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 30rpx;
						margin: 0 20rpx;
						padding-bottom: 15rpx;
						text-align: center;

						image {
							width: 38rpx;
							height: 38rpx;
							margin-right: 5rpx;
						}
					}

					.click {
						color: white;
						font-weight: bold;
						border-bottom: 2px solid white;
					}
				}

				.card-detail-box {
					width: 100%;
					margin-top: 20rpx;
					padding: 30rpx 20rpx 30rpx 20rpx;
					border-radius: 20rpx;
					border: 1rpx solid #96948C;
					background-color: #1A1A1A;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
				}
			}

			.rights-box {
				width: 100%;
				padding: 0 20rpx 30rpx 20rpx;
				border-radius: 20rpx;
				border: 1rpx solid #96948C;
				background-color: #363636;
				color: #E8CEAD;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.rights-item {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: center;

					.title-left {
						width: 260rpx;
						padding: 20rpx 0 20rpx 20rpx;
					}

					.value-item {
						flex: 1;
						text-align: center;
						padding: 20rpx;
					}
				}

				.title {
					font-weight: bold;
				}

				.item-bg {
					font-size: 24rpx;
					background-color: #42403E;
					border-radius: 15rpx;
					margin-bottom: 20rpx;

					.yellow-bg {
						background-color: #F3D2A6;
						border-radius: 0 15rpx 15rpx 0;
						color: #3A3A38;
					}
				}
			}
		}
	}
</style>