<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"  style="font-size: 36rpx;">
				余额充值
			</view>
		</view>
		<view class="topss">

		</view>
		<scroll-view class="scrol" scroll-y="true">
		<view class="charge-header" :class="{chargeActive:rechageData.vip===1}">
			<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">
						{{rechageData.balance}}
					</view>
					<view class="bt">
						当前余额适用于平台全门店
					</view>
				</view>
				<view class="charge-header-box-right">
					<text class="jiaobiao" v-if="rechageData.vip===1">至尊会员</text>
					<img class="jiaobiao" src="https://www.jiubaotongxue.love/image/vip6.png" alt="" v-if="rechageData.vip===0"  />
					<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:rechageIndex===index}" v-for="(item,index) in rechageData.recharges"
						:key="item.id" @click="getActives(index)">
						<view class="titles">
							<text class="color-r">{{item.amount}}</text>元
						</view>
						<view class="minBox">
							送<text class="color-r">{{item.giveAmount}}</text>元
						</view>
						<img class="box-activesa" src="https://www.jiubaotongxue.love/image/demo55.png" alt="" v-if="rechageIndex===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" @click="goPlays">
			去充值
		</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 r = rechagePlay()
	const s = storindex()
	const wxImg = ref()
	// const {}  =storeToRefs(s)
	const {
		rechageData
	} = storeToRefs(r)
	onLoad((options)=>{
		r.getRechageApi(options.id)
		wxImg.value=uni.getStorageSync('wxImg')
	})
	const titles = ref('次卡购买')
	const bgcolor = ref('#fff')
	const color = ref('#000')
	const explainShow = ref(0)
	const rechageIndex = ref(0)
	const rechageQuery = ([])
	const explainBtn = () => {
		explainShow.value = 1
	}
	const close = (val) => {
		explainShow.value = val
	}
	const secondBright = () => {
		uni.navigateTo({
			url: "/pages/balance/balance"
		})
	}
	const getNavs = () => {
		uni.navigateBack()
	}

	const getActives = (index) => {
		rechageIndex.value=index
		console.log(rechageData.value.recharges[index]);
	}
	const goPlays = ()=>{
		s.wxPlays(rechageData.value.recharges[rechageIndex.value])
	}
</script>

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

		.tops {
			width: 100%;
			position: fixed;
			height: 318rpx;
			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: 32rpx;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			background-size: 100% 100%;
			background-repeat: no-repeat;
		
			.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 {
						display: block;
						width: 124rpx;
						height: 52rpx;
						margin-top: 12rpx;
						margin-left: 79rpx;
						border-radius: 20rpx 0rpx 0rpx 20rpx;
						background-color: #797372;
						font-size: 22rpx;
						color: #fad590;
						text-align: center;
						line-height: 52rpx;
					}
		
					.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;
				}
			}
		}
		.chargeActive{
			background-image: url("https://www.jiubaotongxue.love/image/zhizun1.png");
			.charge-header-bottom{
				background-color: #3e3d3a;
				color:#fad590
			}
		}


			.charge-body {
				width: 92%;
				// height: 400rpx;
				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-body-box {
					width: 100%;
					position: relative;
					display: flex;
					flex-wrap: wrap;

					.box {
						margin-left: 10rpx;
						width: 218rpx;
						height: 132rpx;
						margin-top: 22rpx;
						background-color: white;
						border-radius: 20rpx 20rpx 20rpx 20rpx;
						position: relative;

						.titles {
							width: 100%;
							font-size: 26rpx;
							text-align: center;
							margin-top: 25rpx;

							.color-r {
								font-size: 40rpx;
							}
						}

						.minBox {
							width: 100%;
							text-align: center;
							font-size: 22rpx;
						}

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

					.boxacc {
						background-color: #F6B01C;
						color: white;
					}

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

			.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: 100rpx;
			background: linear-gradient(276deg, #1C9FF7 0%, #1275F7 100%);
			box-shadow: 0rpx 8rpx 18rpx 0rpx rgba(5, 128, 255, 0.2);
			border-radius: 50rpx;
			bottom: constant(safe-area-inset-bottom);
			bottom: env(safe-area-inset-bottom);
			text-align: center;
			line-height: 100rpx;
			font-size: 30rpx;
			color: white;

		}
	}
</style>