<style scoped>
	.vipDetail {
		width: 100%;
		height: 100vh;
		background: #FAF8F9;
		font-family: aa;
		padding: 15px;
		
	}
	.vipDetail .vipd_top{
		width: 100%;
		height: 194px;
		border-radius: 10px;
		overflow: hidden;
		position: relative;
	}

	.vipDetail .submit{
		width: 100%;
		height: 65px;
		position: fixed;
		background: #FAF8F9;
		left: 0;
		bottom: 0;
		padding: 0 15px;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		z-index: 99;
		
	}
	.vipDetail .submit-box{
		width: 100%;
		height: 45px;
		border-radius: 23px;
		font-size: 16px;
		display: flex;
		align-items: center;
		justify-content: center;
		
	}
	.vipDetail .bj {
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		background: rgba(0, 0, 0, 0.3);
		border-radius: 10px;
	}
	.vipDetail .btext{
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		font-size: 12px;
		color: #FFF;
		padding: 15px;
		display: flex;flex-direction: column;
		justify-content: space-between;
	}
</style>
<template>
	<view class="vipDetail" v-if="loading">
		<view class="vipd_top">
			<image mode="aspectFill" :src="cdetail.CardBagIco" style="width: 100%;height: 100%;border-radius: 10px;"></image>
			<!-- <view class="bj"></view> -->
			<view class="btext">
				<text></text>
				<view style="width: 100%;color: #FFF;font-size: 15px;">
					<view>{{cdetail.CardNo}}</view>
					<view style="margin-top: 12px;font-size: 12px;display: flex;flex-direction: row;align-items: center;">
						<view style="margin-right: 10px;max-width: 100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{useName}}</view>
							<!-- {{cdetail.StartDate.split('T')[0].split('-')[0]+'/'+cdetail.StartDate.split('T')[0].split('-')[1]}}
							~
							{{cdetail.EndDate.split('T')[0].split('-')[0]+'/'+cdetail.EndDate.split('T')[0].split('-')[1]}} -->
							{{cdetail.EndDate.split('T')[0].split('-')[1]+'/'+cdetail.EndDate.split('T')[0].split('-')[0].toString().substr(2, 2)}}
						</view>
				</view>
			</view>
		</view>
		<view style="width: 100%;height: 40px;line-height: 40px;font-weight: bold;color: #111111;font-size: 14px;">
			会员卡详情
		</view>
		<view style="width: 100%;margin-bottom: 100px;">
			<h-parse :content="detailContent" @navigate="clickDescription"></h-parse>
		</view>
		
		<view class="submit">
			<view class="submit-box" :style="{'background':cdetail.MemberNum==0?mc:'#D4D4D4',color:cdetail.MemberNum==0?'#FFF':'#999999'}"
			@click="submitreceive()"
			>
				
				<text v-if="cdetail.MemberNum==0">立即领取</text>
				<text v-if="cdetail.MemberNum!=0">已领取</text>
			</view>
			
		</view>
	</view>
</template>

<script>
	import hParse from "@/components/u-parse/parse.vue";
	export default {
		components: {
		  hParse,
		},
		data() {
			return {
				pageTitle: "会员卡详情",
				mc: "",
				loading: false,
				ID:0,
				storeId:0,
				cdetail:{},
				current:0,
				submitOrder:false,
				
				cstore:0,
				detailContent:'',
				useName:'',
			};
		},
		
		onLoad(option) {
			console.log(option)
			this.mc = this.$uiConfig.mainColor;
			if(option && option.ID){
				this.ID = option.ID
			}
			if(option && option.storeId){
				this.storeId = option.storeId
			}
			this.getDetail()//获取套餐卡详情
			this.useName = uni.getStorageSync("mall_UserInfo")?uni.getStorageSync("mall_UserInfo").Name:''
			
		},
		
		mounted() {
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
			
			
		},
	
		methods: {
			getDetail(){
				uni.showLoading({
					title: '加载中'
				});
				this.request2({
						url: '/api/AppletStores/GetReserveCardBagDetail',
						data: {ID:this.ID,StoreId:this.storeId==0?'-1':this.storeId}//判断下如果是列表没传门店id时候传-1
					},
					res => {
						if (res.resultCode == 1) {
							this.loading = true
							this.cdetail=res.data
							var richtext = this.cdetail.Describe;
							this.detailContent = richtext;
						}
						uni.hideLoading();
					}
				);
			},
			submitreceive(){
				if(this.cdetail.MemberNum==0){
					this.request2({
							url: '/api/AppletStores/GrantCardBag',
							data: {CouponId:this.ID,StoreId:this.storeId}
						},
						res => {
							if (res.resultCode == 1) {
								uni.showToast({
								    title: res.message,
								    icon: "none",
								});
								this.cdetail.MemberNum=1
							}
						}
					);
				}else{
					uni.showToast({
					    title: '已经领取过了!',
					    icon: "none",
					});
				}
				
			},
		
		
		},
	};
</script>


