<template>
	<view class="charge">
		<view class="tops">
			<img class="nav-img" src="https://www.jiubaotongxue.love/image/nav10.png" alt="" @click="getNavs" />
			<view class="title">
				次卡办理
			</view>
		</view>
		<view class="topss">

		</view>
		<scroll-view class="scrol" scroll-y="true">
			<view class="charge-header">
				<view class="charge-header-box">
					<view class="charge-header-box-left">
						<view class="title">
							<img class="title-i" src="https://www.jiubaotongxue.love/image/demo53.png" alt="" />
							<text class="title-t">次数剩余（次）</text>
						</view>
						<view class="strongeTxt">
							{{rechageCardData.cardNumber}}
						</view>
						<view class="bt">
							当前洗卡适用于平台全门店
						</view>
					</view>
					<view class="charge-header-box-right">
						<view class="jiaobiao">
							门店次卡
						</view>
						<img class="header-img" :src="wxImg ? wxImg :'https://www.jiubaotongxue.love/image/demo32.png'" alt="" />
					</view>
				</view>
				<view class="charge-header-bottom">
					<view class="charge-header-bottom-left" @click="explainBtn">
						次卡说明
					</view>
					|
					<view class="charge-header-bottom-left" @click="secondBright">
						次卡明细
					</view>
				</view>
			</view>
			<view class="charge-body">
				<view class="charge-body-title">
					请选择次卡套餐办理
				</view>
				<view class="charge-body-box">
					<view class="box" :class="{boxacc:cardIndex===index}" v-for="(item,index) in rechageCardData.cards" :key="item.id" @click="getCheck(index)">
						<view class="box-titles">
							{{item.number}}次卡
						</view>
						<view class="box-conters">
							{{item.period}}个月
						</view>
						<view class="box-center">
							￥{{item.amount}}
						</view>
						<view class="box-bottoms">
							每次使用上线{{item.minute}}分钟
						</view>
						<img class="box-actives" src="https://www.jiubaotongxue.love/image/demo50.png" alt="" v-if="cardIndex===index" />
					</view>
					<view class="ding">

					</view>
				</view>
			</view>
			<view class="charge-play">
				<view class="charge-body-title">
					请选择次卡套餐办理
				</view>
				<view class="charge-play-icon">
					<view class="icon-left">
						<img class="icon-img" src="https://www.jiubaotongxue.love/image/demo54.png" alt="" />
						<text>微信支付</text>
					</view>
					<view class="icon-right icon-active">

					</view>
				</view>
			</view>
			<view class="dings">

			</view>
		</scroll-view>

		<view class="charge-btnPlay">
			<text class="charge-btnPlay-left">支付：<text class="pricess">{{rechageCardData.cards[cardIndex].amount}}</text> </text>
			<view class="plays" @click="goPlays">
				去支付
			</view>
		</view>
	</view>
	<explain v-if="explainShow===1" @close="close"></explain>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad
	} from "@dcloudio/uni-app"
	import {
		rechagePlay
	} from '../../stor/rechagePlay/rechagePlay.js'
	import {
		storeToRefs
	} from 'pinia';
	import {
		storindex
	} from '../../stor/index.js'
	const wxImg = ref()
	const r = rechagePlay()
	const s = storindex()
	// const {}  =storeToRefs(s)
	const {
		rechageCardData
	} = storeToRefs(r)
	const titles = ref('次卡购买')
	const bgcolor = ref('#fff')
	const color = ref('#000')
	const explainShow = ref(0)
	const cardIndex = ref(0)
	onLoad((options) => {
		console.log(options.id);
		r.getRechageCardApi(options.id)
		wxImg.value=uni.getStorageSync('wxImg')
	})
	const explainBtn = () => {
		explainShow.value = 1
	}
	const close = (val) => {
		explainShow.value = val
	}
	const secondBright = () => {
		uni.navigateTo({
			url: "/pages/secondBright/secondBright"
		})
	}
	const getNavs = () => {
		console.log(1);
		uni.navigateBack()
	}
	
	const getCheck = (index)=>{
		cardIndex.value = index
	}
	const goPlays=()=>{
		console.log(rechageCardData.value.cards[cardIndex.value]);
		s.wxPlayss(rechageCardData.value.cards[cardIndex.value])
	}
</script>

<style lang="scss">
	.charge {
		width: 100%;
		height: 100%;
		position: absolute;
		background-color: #f2f2f2;

		.tops {
			width: 100%;
			position: fixed;
			height: 318rpx;
			// background: linear-gradient(113deg, #65AAFB 0%, #60A7FB 100%);
			background-image: url("https://www.jiubaotongxue.love/image/demo56.png");
			background-size: 100% 100%;
			// z-index: 9;

			.nav-img {
				width: 64rpx;
				height: 64rpx;
				position: absolute;
				top: 100rpx;
				left: 20rpx;
			}

			.title {
				width: 100%;
				height: 50rpx;
				line-height: 50rpx;
				font-size: 36rpx;
				position: absolute;
				top: 108rpx;
				left: 304rpx;
			}
		}

		.topss {
			width: 100%;
			height: 318rpx;
		}

		.scrol {
			width: 100%;
			height: 80%;
			position: relative;
			// z-index: 20;
			margin-top: -80rpx;

			.charge-header {
				width: 90%;
				height: 308rpx;
				background: linear-gradient(270deg, #1B7BEA 0%, #7EB6FE 100%);
				border: 1rpx solid #02a7f0;
				border-bottom: none;
				margin-left: 50%;
				transform: translateX(-50%);
				// margin-top: -80rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;

				.charge-header-box {
					width: 100%;
					height: 244rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.charge-header-box-left {
						width: 70%;
						height: 244rpx;

						.title {
							width: 100%;
							height: 40rpx;
							display: flex;
							margin-top: 40rpx;

							.title-i {
								display: block;
								width: 40rpx;
								height: 40rpx;
								margin-left: 40rpx;

							}

							.title-t {
								display: block;
								font-size: 28rpx;
								color: white;
								margin-left: 10rpx;
							}
						}

						.strongeTxt {
							width: 100%;
							height: 90rpx;
							line-height: 90rpx;
							font-size: 64rpx;
							box-sizing: border-box;
							padding-left: 40rpx;
							color: white;
							margin-top: 6rpx;
						}

						.bt {
							width: 100%;
							height: 32rpx;
							line-height: 32rpx;
							box-sizing: border-box;
							padding-left: 30rpx;
							font-size: 22rpx;
							color: white;
							margin-top: 10rpx;
						}

					}

					.charge-header-box-right {
						width: 30%;
						height: 224rpx;

						.jiaobiao {
							width: 124rpx;
							height: 52rpx;
							background: linear-gradient(90deg, #75B5FF 0%, #E0EFFF 100%);
							font-size: 22rpx;
							margin-top: 12rpx;
							text-align: center;
							line-height: 52rpx;
							margin-left: 79rpx;
							border-radius: 20rpx 0rpx 0rpx 20rpx;
							color: #0061D1;
						}

						.header-img {
							width: 96rpx;
							height: 96rpx;
							border-radius: 50%;
							margin-top: 38rpx;
							margin-left: 80rpx;
						}
					}
				}

				.charge-header-bottom {
					// margin-top: 20rpx;
					width: 100%;
					height: 64rpx;
					background-color: #2e8af5;
					border-radius: 0rpx 20rpx 0rpx 20rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 26rpx;
					color: white;

					.charge-header-bottom-left {
						width: 50%;
						height: 80rpx;
						text-align: center;
						line-height: 80rpx;
						font-size: 26rpx;
					}
				}
			}

			.charge-body {
				width: 92%;
				// height: 400rpx;
				// background-color: #ffffff;
				margin-left: 50%;
				transform: translateX(-50%);
				margin-top: 60rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;

				.charge-body-title {
					width: 100%;
					height: 80rpx;
					box-sizing: border-box;
					line-height: 80rpx;
					padding-left: 20rpx;
					font-size: 32rpx;
					font-weight: 700;
					padding-top: 15rpx;
					color: #666;
				}

				.charge-body-box {
					width: 100%;
					position: relative;
					display: flex;
					justify-content: space-between;
					flex-wrap: wrap;

					.box {
						margin-left: 15rpx;
						margin-right: 15rpx;
						width: 43%;
						margin-top: 20rpx;
						height: 230rpx;
						background-color: #ffffff;
						border-radius: 20rpx 20rpx 20rpx 20rpx;
						position: relative;

						.box-titles {
							width: 120rpx;
							height: 40rpx;
							background-color: #D7D7D7;
							font-size: 22rpx;
							text-align: center;
							line-height: 40rpx;
							color: white;
							border-radius: 20rpx 0rpx 20rpx 0rpx;
						}

						.box-conters {
							// width: 100%;
							margin-left: 30rpx;
							height: 42rpx;
							font-size: 30rpx;
							margin-top: 28rpx;
							font-weight: 600;
						}

						.box-center {
							font-size: 40rpx;
							margin-left: 30rpx;
							font-weight: 600;
							color: #FF7733;
							margin-top: 8rpx;
						}

						.box-bottoms {
							font-size: 22rpx;
							color: #999999;
							margin-top: 5rpx;
							margin-left: 30rpx;

						}

						.box-actives {
							position: absolute;
							width: 48rpx;
							height: 48rpx;
							bottom: 0rpx;
							right: -5rpx;
						}

					}

					.boxacc {
						border: 5rpx solid #1276F7;

						.box-titles {
							margin-left: -5rpx;
							background: linear-gradient(107deg, #838EFF 0%, #1276F7 100%);

						}
					}

					.ding {
						width: 100%;
						height: 40rpx;
					}
				}

				.active {
					background-color: #02a7f0;

					.box-title {
						color: #d9001b;

						.q {
							color: black;

							.colors {
								color: #d9001b;
							}
						}
					}

					.box-bottom {
						color: white;
					}
				}
			}

			.charge-play {
				width: 92%;
				height: 200rpx;
				// background-color: #ffffff;
				margin-left: 50%;
				transform: translateX(-50%);
				// margin-top: 30rpx;
				border-radius: 20rpx 20rpx 20rpx 20rpx;

				.charge-body-title {
					width: 100%;
					height: 80rpx;
					box-sizing: border-box;
					line-height: 80rpx;
					padding-left: 20rpx;
					font-size: 32rpx;
					font-weight: 700;
					color: #666;
				}

				.charge-play-icon {
					width: 100%;
					height: 110rpx;
					margin-top: 15rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					background-color: white;
					border-radius: 20rpx 20rpx 20rpx 20rpx;

					.icon-left {
						width: 260rpx;
						height: 90rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						font-size: 28rp;

						.icon-img {
							width: 60rpx;
							height: 60rpx;
							border-radius: 50%;
							margin-left: 30rpx;
						}
					}

					.icon-right {
						width: 44rpx;
						height: 44rpx;
						border-radius: 50%;
						border: 1rpx solid #666;
						margin-right: 50rpx;
					}

					.icon-active {
						border: none;
						background-size: 100% 100%;
						background-image: url("https://www.jiubaotongxue.love/image/xuanzhong.png");
					}
				}
			}

			.dings {
				width: 100%;
				height: 300rpx;
				background-color: #f2f2f2;
			}
		}

		.charge-btnPlay {
			position: fixed;
			bottom: 0rpx;
			width: 100%;
			height: 140rpx;
			background-color: white;
			line-height: 140rpx;
			color: white;
			display: flex;
			justify-content: space-between;
			// bottom: constant(safe-area-inset-bottom);
			// bottom: env(safe-area-inset-bottom);
			box-sizing: border-box;
			padding-left: 30rpx;

			.charge-btnPlay-left {
				color: black;
				font-size: 30rpx;

				.pricess {
					font-size: 40rpx;
					color: #FF7733;
				}
			}

			.plays {
				width: 280rpx;
				height: 96rpx;
				background: linear-gradient(135deg, #4D97FF 0%, #3377FF 100%), linear-gradient(276deg, #1C9FF7 0%, #1275F7 100%);
				box-shadow: 0rpx 8rpx 18rpx 0rpx rgba(5, 128, 255, 0.2);
				border-radius: 50rpx;
				text-align: center;
				line-height: 96rpx;
				margin-right: 30rpx;
				margin-top: 20rpx;
			}
		}
	}
</style>