<template>
	<view class="page">
		<u-navbar title="我的卡包" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
			title-size='36' height='44' :custom-back="btns" id="navbar">
		</u-navbar>
       <view class="top">
       	   <!-- <view class="toptab">
       	    	<view @click="btntab(1)" :class="activeindex == 1 ? 'active' : ''">
       	    		储值卡
       	    	</view>
       	    	<view @click="btntab(2)" :class="activeindex == 2 ? 'active' : ''">
       	    		卡劵
       	    	</view>
       	    </view> -->
       	    <view class="bot" @click="btnlishi">
       	    	<!-- <view class="">
       	    		<image src="https://api.ccttiot.com/smartmeter/img/static/ua5tXFz6W29RUniwsKzh" mode=""></image> 历史储存卡
       	    	</view>
       	    	<u-icon name="arrow-right" color="#7C7C7C" size="28"></u-icon> -->
       	    </view>
       </view>
	   <scroll-view class="list" scroll-y style="height: 81vh;" @scrolltolower="onScrollToLower">
	   	<view class="list_item" v-for="(item,index) in listka" :key="index">
				<image src="https://api.ccttiot.com/smartmeter/img/static/u9yhfTszqRFL3zhHWyR7" mode=""></image>
				<view class="top">
					<view class="lt">
						<view class="time">
							{{item.coupon.name == undefined ? '--' :item.coupon.name}}
						</view>
						<view class="wz" v-if="item.coupon.type == 1">
							可用金额：{{item.coupon.storedAmount == undefined ? '--' : '￥' + item.coupon.storedAmount}}
						</view>
							<view class="wz" v-if="item.coupon.type == 2"> 
								可用时长：{{item.coupon.hours == undefined ? '--' : item.coupon.hours}}小时
							</view>
							<view class="wz" v-if="item.coupon.type == 3">
								可用剩余金额：{{'￥' + item.storedAmount}}
							</view>
							<view class="wz" v-if="item.coupon.type == 4">
								可用次数：{{item.coupon.limitNum == undefined ? '--' : item.coupon.limitNum}}次
							</view>
						<view class="wz">
							有效期：
								{{item.startTime == undefined ? '--' : item.startTime}} - {{item.endTime == undefined ? '--' : item.endTime}}
						</view>
					</view>
					<view class="leix" v-if="item.coupon.type == 1">
						储存卡
					</view>
						<view class="leix" v-if="item.coupon.type == 2">
							小时卡
						</view>
						<view class="leix" v-if="item.coupon.type == 3">
							团购劵
						</view>
						<view class="leix" v-if="item.coupon.type == 4">
							次卡
						</view>
					<view class="rt" @click="btnqsy">
						去使用
						<!-- ￥{{item.coupon.retailPrice == undefined ? '--' : item.coupon.retailPrice}} -->
					</view>
				</view>
				<view class="bots">
					该卡券<text v-for="(val,index) in item.coupon.availableWeek">{{val == 1 ? '周一' : val == 2 ? '周二' : val == 3 ? '周三': val == 4 ? '周四': val == 5 ? '周五': val == 6 ? '周六': val == 7 ? '周日' : ''}}</text> 
						  <span style="margin-left:50rpx" v-if="item.coupon.availableTimeStart == '00:00' && item.coupon.availableTimeEnd == '00:00'">全时段可使用</span>
						  <span style="margin-left:50rpx" v-else>{{item.coupon.availableTimeStart}}-{{item.coupon.availableTimeEnd}}可使用</span>
					<view class="">
						描述：{{item.coupon.descr == null ? '--' : item.coupon.descr}}
					</view>
				</view>
	   	</view>
	   	<view style="width: 100%;text-align: center;color: #ccc;margin-top: 50rpx;">
	   		当前没有更多卡劵啦...
	   	</view>
	   </scroll-view>
       <view class="anniu">
       	   <view class="tddh" @click="btnhx">
       	   	    团购兑换
       	   </view>
		   <view class="gm" @click="btngm">
		   	    购买
		   </view>
       </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: "#fff",
                },
				activeindex:1,
				listka:[]
			}
		},
		onLoad() {

		},
		onShow() {
			this.getkajuanlist()
		},
		methods: {
			// 点击去使用
			btnqsy(){
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			// 用户查询可用卡劵
			getkajuanlist(){
				this.$u.get(`/user/user/getAvailableCard`).then(res => {
					if (res.code == 200) {
						this.listka = res.data
					}
				})
			},
			btns(){
				uni.switchTab({
					url:'/pages/my'
				})
			},
			// 点击去使用
			btnsy(){
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			// 点击去购买储值卡
			btngm(){
				uni.switchTab({
					url:'/pages/juanbao/index'
				})
			},
			// 点击跳转到历史储值卡页面
			btnlishi(){
				uni.navigateTo({
					url:'/page_user/kabao/lishi'
				})
			},
			// 点击跳转到团购兑换
			btnhx(){
				uni.navigateTo({
					url:'/page_fenbaotwo/hexiao/index'
				})
			},
			// 点击切换tab
			btntab(num){
				this.activeindex = num
			},
			// 滚动到底部
			onScrollToLower(){
				console.log(11);
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F6F6F6;
	}
	.active{
		font-weight: 600 !important;
		font-size: 32rpx;
		color: #48893B !important;
		border-bottom: 2px solid #48893B;
	}
	.anniu{
		display: flex;
		justify-content: space-between;
		width: 750rpx;
		height: 152rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0,0,0,0.3);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		padding: 24rpx 36rpx;
		box-sizing: border-box;
		position: fixed;
		bottom: 0;
		left: 0;
		.tddh{
			width: 326rpx;
			height: 104rpx;
			border: 2rpx solid #B8B8B8;
			border-radius: 20rpx;
			font-weight: 600;
			font-size: 36rpx;
			color: #7C7C7C;
			text-align: center;
			line-height: 104rpx;
		}
		.gm{
			width: 326rpx;
			height: 104rpx;
			background: #48893B;
			font-weight: 600;
			font-size: 36rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 104rpx;
			border-radius: 20rpx;
		}
	}
	.list{
		padding-bottom: 50rpx;
		box-sizing: border-box;
		.list_item{
			width: 698rpx;
			max-height: 888rpx;
			margin: auto;
			margin-bottom: 50rpx;
			position: relative;
			.top{
				height: 236rpx;
				width: 100%;
				display: flex;
				justify-content: space-between;
				padding: 0 20rpx;
				box-sizing: border-box;
				.lt{
					margin-top: 38rpx;
					.time{
						font-weight: 600;
						font-size: 52rpx;
						color: #48893B;
						margin-bottom: 18rpx;
					}
					.wz{
						font-size: 24rpx;
						color: #48893B;
						margin-bottom: 8rpx;
					}
				}
				.leix{
					width: 144rpx;
					height: 52rpx;
					line-height: 52rpx;
					background: #48893B;
					font-weight: 600;
					font-size: 32rpx;
					color: #FFFFFF;
					position: absolute;
					top: 0;
					right: 0;
					text-align: center;
					border-radius: 0 0 0 10rpx;
				}
				.rt{
					font-size: 24rpx;
					color: #FFFFFF;
					width: 140rpx;
					height: 50rpx;
					text-align: center;
					line-height: 50rpx;
					background-color: #48893B;
					border-radius: 30rpx;
					// -webkit-text-stroke: 2px #48893B; /* 边框宽度和颜色 */
					// text-stroke: 2px #48893B;
					margin-top: 90rpx;
				}
			}
			.bots{
				width: 698rpx;
				max-height: 552rpx;
				background: #ECFAE9;
				font-size: 24rpx;
				color: #48893B;
				flex-wrap: wrap;
				padding: 20rpx;
				box-sizing: border-box;
			}
			image{
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				left: 0;
				z-index: -1;
			}
		}
	}
	.top{
		background-color: #fff;
	}
	.bot{
		width: 750rpx;
		height: 30rpx;
		background: #F6F6F6;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		display: flex;
		justify-content: space-between;
		padding: 0 40rpx;
		box-sizing: border-box;
		align-items: center;
		// margin-top: 16rpx;
		font-size: 24rpx;
		color: #7C7C7C;
		image{
			width: 22rpx;
			height: 22rpx;
			margin-right: 10rpx;
		}
	}
    .toptab{
		width: 100%;
		height: 80rpx;
		line-height: 90rpx;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		padding: 0 120rpx;
		font-size: 32rpx;
		color: #3D3D3D;
	}
</style>