<template>
	<view class="container clearfix">
		<view class="cm-member-top">
			<view class="cm-member-head">
				<view class="cm-member-text">
					<view class="cm-member-h1">
						<text>采美·超级会员</text>
					</view>
					<view class="cm-member-p">
						<text>享专属特权</text>
					</view>
				</view>
			</view>
		</view>
		<view class="cm-member-main">
			<view class="title">超级会员套餐</view>
			<view class="cm-member-pay">
				<view class="pay-item" 
					  v-for="(pay,index) in payList" 
					  :key="index" 
					  :class="{current: tabCurrent === index}" 
					  @click="handleCheckedPay(index,pay)"
				>
					<view class="hot" v-if="index == 0">推荐</view>
					<view class="text-1">{{ pay.month }}</view>
					<view class="text-2"> <text>￥</text>{{ pay.money }}</view>
					<view class="text-3">{{ pay.text }}</view>
				</view>
			</view>
			<view class="cm-member-button">
				<view class="pay-btn pay" @click="hanldPayUrl('/pages/user/member/member-pay')">立即支付{{ payAmount }}元开通</view>
				<view class="pay-btn none">抵扣{{ payBeans }}个采美豆开通</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState,mapMutations} from 'vuex';
	export default {
		components:{
			
		},
		data() {
			return {
				StaticUrl:this.$Static,
				memberType:0,
				tabCurrent:0,
				params:{
					userId:0,
					redemptionCode:'',
					source:2,
				},
				payList:[
					{month:'12个月',money:4800,type:1,text:'400元/月',beans:480000},
					{month:'3个月',money:1500,type:2,text:'500元/月',beans:150000},
					{month:'1个月',money:600,type:3,text:'',beans:60000},
				],
				payAmount:4800,
				payBeans:480000,
			}
		},
		onLoad() {
			
		},
		filters: {
			TypeFormat:function(value) {
				switch (value) {
					case 0:
						return  '活动券';
						break;
					case 1:
						return  '品类券';
						break;
					case 2:
						return  '用户专享券';
						break;
					case 3:
						return  '店铺券';
						break;
					case 4:
						return  '新用户券';
						break;
				}
			}
		},
		computed: {
			...mapState(['hasLogin','userInfo','identity','isActivity'])
		},
		methods: {
			hanldPayUrl(url){
				this.$api.navigateTo(url)
			},
			handleCheckedPay(index,pay){// 选择会员
				this.tabCurrent = index
				this.payAmount = pay.money
				this.payBeans = pay.beans
			}
		},
		onShow(){
			this.$api.getComStorage('userInfo').then((resolve) =>{
				this.params.userId = resolve.userId ? resolve.userId : 0;
			}).catch(error =>{
				console.log('暂无用户信息~')
			})
		}
	}
</script>

<style lang="scss">
	.container{
		width: 100%;
		height: auto;
	}
	.cm-member-top{
		width: 100%;
		height: 242rpx;
		box-sizing: border-box;
		padding: 0 24rpx;
		background: url(https://static.caimei365.com/app/img/icon/icon-member-bg01@2x.png) no-repeat;
		background-size: cover;
		position: relative;
		.cm-member-head{
			width: 702rpx;
			height: 132rpx;
			box-sizing: border-box;
			padding: 30rpx 32rpx 0 109rpx;
			background: url(https://static.caimei365.com/app/img/icon/icon-member-bg02@2x.png) no-repeat;
			background-size: cover;
			position: absolute;
			bottom: 0;
			left: 24rpx;
			border-radius: 16rpx 16rpx 0 0;
			.cm-member-text{
				float: left;
				.cm-member-h1{
					line-height: 42rpx;
					font-size: $font-size-30;
					color: #55331D;
					text-align: left;
					margin-bottom: 12rpx;
					font-weight: bold;
				}
				.cm-member-p{
					line-height: 30rpx;
					font-size: $font-size-22;
					color: #55331D;
					text-align: left;
				}
			}
		}
	}
	.cm-member-main{
		width: 100%;
		box-sizing: border-box;
		padding: 40rpx 24rpx;
		background-color: #FFFFFF;
		margin-bottom: 20rpx;
		.title{
			font-size: $font-size-32;
			line-height: 45rpx;
			text-align: left;
			color:#55331D;
			font-weight: bold;
			.small{
				font-size: $font-size-24;
				color: #E4AA43;
				font-weight: normal;
				margin-left: 15rpx;
			}
		}
		.cm-member-pay{
			width: 100%;
			height:236rpx;
			margin: 40rpx 0;
			.pay-item{
				width: 218rpx;
				height: 100%;
				float: left;
				margin-right: 24rpx;
				border: 1px solid #F0F0F0;
				border-radius: 16rpx;
				box-sizing: border-box;
				text-align: center;
				padding: 40rpx 0;
				position: relative;
				.hot{
					width: 80rpx;
					height: 36rpx;
					text-align: center;
					line-height: 36rpx;
					font-size: $font-size-24;
					color: #FFFFFF;
					background-color: #FF2A2A;
					border-radius: 0 8rpx 8rpx 8rpx;
					position: absolute;
					left: 0;
					top: -10rpx;
				}
				&.current{
					background-color: #FDF8EE;
					border: 1px solid #F0CC8C;
				}
				&:last-child{
					margin-right: 0;
				}
				.text-1{
					line-height: 40rpx;
					font-size: $font-size-28;
					margin-bottom: 10rpx;
					color: #55331D;
				}
				.text-2{
					line-height: 59rpx;
					font-size: $font-size-40;
					margin-bottom: 10rpx;
					color: #FF2A2A;
					font-weight: bold;
					text{
						font-size: $font-size-26;
					}
				}
				.text-3{
					line-height: 33rpx;
					font-size: $font-size-24;
					color: #666666;
				}
				
			}
		}
		.cm-member-button{
			width: 100%;
			box-sizing: border-box;
			padding: 0 51rpx;
			.pay-btn{
				width: 100%;
				height: 90rpx;
				line-height: 90rpx;
				border-radius: 50rpx;
				text-align: center;
				font-size: $font-size-30;
				color: #55331D;
				box-sizing: border-box;
				margin-bottom: $font-size-24;
				&.pay{
					background: linear-gradient(90deg, #FEE9BA 0%, #F0CB72 100%);
					font-weight: bold;
				}
				&.none{
					border: 1px solid #F0CB72;
					margin-bottom: 0;
				}
			}
		}
	}
</style>
