<template>
	<view class="changecontainer">
		<view class="cardcontent">
			<view class="myswiper">
				<swiper class="swiper" circular :indicator-dots="true" :indicator-color="indicatorColor"
					:indicator-active-color="indicatorActiveColor" :autoplay="autoplay" :interval="interval"
					:duration="duration" :current="currentSwiperIndex" @change="onSwiperChange">
					<swiper-item v-for="item in banner3">
						<view class="swiper-item">
							<image :src="item.image" mode="widthFix"></image>
						</view>
					</swiper-item>

				</swiper>
				<view class="cardtitle">卡券信息</view>
			</view>
			<view class="cardinfobox">
				<view class="cardlist">
					<view class="cardinfolist">
						<view class="listitem">
							<view>卡券名称</view>
							<text>{{cardinfo.card?cardinfo.card.sku.name:""}}</text>
						</view>
						<view class="listitem">
							<view>卡券编号</view>
							<text>{{cardinfo.card_number}}</text>
						</view>
						<view class="listitem">
							<view>卡券状态</view>
							<text>{{status_label}}</text>
						</view>
						
					</view>
				</view>
				<view class="cardbtn" @click="toHome">返回首页</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		toast
	} from "@/common/util.js"
	export default {
		components: {},
		data() {
			return {
				autoplay: true,
				interval: 3000,
				duration: 500,
				indicatorColor: 'rgba(204,204,203,.5)',
				indicatorActiveColor: '#b98b44',
				currentSwiperIndex: 0,
				banner3: [],
				cardinfo: {},
				status_label:''
			}
		},
		onLoad() {
			this.banner3 = uni.getStorageSync("banner3") ? uni.getStorageSync("banner3") : []
			if (uni.getStorageSync("vuex_card_state")) {
				this.cardinfo = uni.getStorageSync("vuex_card_state")
				switch (this.cardinfo.card.status){
					case -1:
						this.status_label = '已销卡'
						break;
					case 0:
						this.status_label = '末出库'
						break;
					case 1:
						this.status_label = '待激活'
						break;
					case 2:
						this.status_label = '待使用'
						break;
					case 3:
						this.status_label = '已使用'
						break;
					default:
						break;
				}
				uni.removeStorageSync("vuex_card_state")
			} else {
				toast("未查询到卡券信息")
				uni.redirectTo({
					url: '/packages/card/index'
				})

			}
		},
		methods: {
			toHome(){
				uni.switchTab({
					url:"/pages/home/home"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.changecontainer {
		width: 100%;
		background-image: url(../../static/bg-change.jpg);
		background-position: center top;
		background-size: cover;
		height: 100vh;
		display: flex;
		align-items: center;
	}

	.cardcontent {
		width: 87.33%;
		margin: 0 auto;
		background: #fff;
		border-radius: 10rpx;
		overflow: hidden;
	}

	.myswiper {
		padding: 55rpx 44rpx 45rpx;
	}

	.myswiper image {
		width: 100%;
		height: auto;
		border-radius: 10rpx;
	}

	.cardtitle {
		margin-top: 54rpx;
		font-size: 36rpx;
		text-align: center;
		color: #b98b44;
	}

	.cardinfobox {
		position: relative;
		border-top: 1rpx dashed #a4a5a4;
		padding: 82rpx 25rpx;
	}

	.cardinfobox::before,
	.cardinfobox::after {
		content: " ";
		position: absolute;
		display: inline-block;
		width: 28rpx;
		height: 28rpx;
		border-radius: 50%;
		background: #4a4b4a;
		top: -14rpx;
	}

	.cardinfobox::before {
		left: -14rpx;
	}

	.cardinfobox::after {
		right: -14rpx;
	}

	.cardlist {
		border-radius: 10rpx;
		width: 100%;
		overflow: hidden;
		box-shadow: 0 5rpx 16rpx rgba(0, 0, 0, .32);
		position: relative;
		background-image: url(../../static/cardbg.jpg);
		background-position: center top;
		background-size: cover;
		margin-bottom: 78rpx;
	}

	.cardinfolist {
		padding: 16rpx 38rpx;
	}

	.cardinfolist .listitem {
		display: flex;
		border-bottom: 1rpx solid #f6d9b6;
	}

	.listitem:last-child {
		border-bottom: none;
	}

	.listitem view {
		padding-left: 6rpx;
		width: 140rpx;
		line-height: 80rpx;
		color: #fff;
		font-size: 26rpx;
		border-right: 1rpx solid #f6d9b6;
	}

	.listitem text {
		font-size: 26rpx;
		line-height: 80rpx;
		color: #f6d9b6;
		padding-left: 20rpx;
	}

	.cardbtn {
		width: 450rpx;
		height: 74rpx;
		line-height: 74rpx;
		background: #b98b44;
		font-size: 26rpx;
		color: #fff;
		margin: 0 auto;
		text-align: center;
		border-radius: 74rpx;
	}
</style>