<template>
	<view class="container">
		<image class="banner" src="@/static/images/mine/back.png" mode="aspectFill" />
		<view class="title" :style="{ top: `${paddingTop * 2}rpx` }">
			<view class="title_back" @click="handleBack">
				<wd-icon name="thin-arrow-left" color="#001713" size="18"></wd-icon>
			</view>

			电子交通卡
		</view>

		<view class="body">
			<!-- 交通卡区域 -->
			<view class="body_card" :class="[{ excellent: cardType == '优行卡' }, { teacher: cardType == '教师卡' }, { warm: cardType == '暖心卡' }]">
				<view class="card_type">
					<view class="type_name">
						<image v-if="cardType == '优行卡'" class="img" src="/static/images/transportation/logo.png" mode="aspectFill"></image>
						<image v-if="cardType == '教师卡'" class="img" src="/static/images/transportation/logo2.png" mode="aspectFill"></image>
						<image v-if="cardType == '暖心卡'" class="img" src="/static/images/transportation/logo3.png" mode="aspectFill"></image>
						{{ cardType }}
					</view>
					<view class="type_au" @click="goPage('/pages/identity/identity')">
						<text class="text">身份认证</text>
						<wd-icon name="arrow-right" color="#376477" size="8"></wd-icon>
					</view>
				</view>
				<view class="card_num">
					可用余额：
					<text class="text">100元</text>
				</view>
				<view class="">充值余额：100元 补贴金额度：100元</view>

				<view
					class="card_btn"
					:class="[{ btn_excellent: cardType == '优行卡' }, { btn_teacher: cardType == '教师卡' }, { btn_warm: cardType == '暖心卡' }]"
					@click="handleDetail"
				>
					查看使用明细
				</view>
				<view class="card_line" :class="[{ line_excellent: cardType == '优行卡' }, { line_teacher: cardType == '教师卡' }, { line_warm: cardType == '暖心卡' }]"></view>
			</view>

			<!-- 按钮区域 -->
			<view class="body_btns">
				<view class="btn pull" @click="handlePull">点击充值</view>

				<view class="btn refund" @click="handleRefund">点击退款</view>
			</view>

			<!-- 使用规则区域 -->
			<view class="body_rule">交通卡使用规则</view>
		</view>
	</view>

	<!-- 退款弹窗区域 -->
	<wd-popup v-model="popShow" position="bottom" safe-area-inset-bottom :close-on-click-modal="false">
		<view class="pop">
			<view class="pop_title">
				<view class="title_close" @click="closePop">
					<wd-icon name="close" size="16"></wd-icon>
				</view>
			</view>
			<view class="pop_tips">退款余额为50</view>

			<view class="pop_msg">退款后可用余额为0，主余额为0补贴余额为0</view>

			<view class="pop_btn">立即退款</view>
		</view>
	</wd-popup>
</template>

<script setup>
import { onMounted, ref } from 'vue'

// 胶囊按钮距离页面顶部的距离
const paddingTop = ref(0)

// 交通卡类型
const cardType = ref('优行卡')

// 退款弹窗显示隐藏控制
const popShow = ref(false)

onMounted(() => {
	paddingTop.value = uni.getMenuButtonBoundingClientRect().top
})

// 查看使用明细按钮回调
const handleDetail = () => {
	uni.navigateTo({
		url: '/pages/useDetail/useDetail'
	})
}

// 点击充值按钮回调
const handlePull = () => {
	uni.navigateTo({
		url: '/pages/pay/pay'
	})
}

// 跳转页面
const goPage = (url) => {
	uni.navigateTo({
		url
	})
}

// 点击退款按钮回调
const handleRefund = () => {
	popShow.value = true
}

// 弹窗关闭按钮回调
const closePop = () => {
	popShow.value = false
}

// 顶部返回图标回调
const handleBack = () => {
	uni.navigateBack()
}
</script>

<style lang="scss" scoped>
.container {
	position: relative;
	height: 100vh;
	color: #001713;
	background-color: #fff;
	overflow-y: auto;

	.banner {
		width: 100%;
		height: 482rpx;
	}

	.title {
		position: absolute;
		display: flex;
		align-items: center;
		width: 100vh;
		font-size: 40rpx;

		.title_back {
			margin-left: 26rpx;
			margin-right: 232rpx;
		}
	}

	.body {
		position: absolute;
		top: 160rpx;
		box-sizing: border-box;
		padding: 0 40rpx;
		width: 100%;

		.body_card {
			box-sizing: border-box;
			padding: 40rpx 50rpx 30rpx;
			width: 100%;
			height: 316rpx;
			font-size: 24rpx;
			border-radius: 60rpx;
			border-radius: 30px;
			box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);

			.card_type {
				display: flex;
				align-items: center;
				font-weight: bold;

				.type_name {
					display: flex;
					align-items: center;
					font-size: 40rpx;

					.img {
						margin-right: 10rpx;
						width: 40rpx;
						height: 40rpx;
					}
				}

				.type_au {
					display: flex;
					align-items: center;
					margin-left: 40rpx;
					font-size: 24rpx;

					.text {
						margin-right: 5rpx;
					}
				}
			}

			.card_num {
				margin-top: 22rpx;
				margin-bottom: 18rpx;

				.text {
					font-weight: bold;
				}
			}

			.card_btn {
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 20rpx;
				margin-left: auto;
				width: 234rpx;
				height: 50rpx;
				font-size: 28rpx;
				font-weight: bold;
				border-radius: 8rpx;
			}

			.btn_excellent {
				color: #2b507a;
				border: 2rpx solid #2d537d;
				background-color: #cfe0eb;
			}

			.btn_teacher {
				color: #a46509;
				border: 2rpx solid #c77417;
				background-color: #fddb9f;
			}

			.btn_warm {
				color: #1580ed;
				border: 2rpx solid #0d71fb;
				background-color: #e2eef9;
			}

			.card_line {
				margin-top: 16rpx;
				width: 100%;
				height: 8rpx;
				border-radius: 10rpx;
			}

			.line_excellent {
				background: linear-gradient(90deg, #72a8d2 0%, #2b507a 100%);
			}

			.line_teacher {
				background: linear-gradient(90deg, #f1a045 0%, #bf6c0f 100%);
			}

			.line_warm {
				background: linear-gradient(90deg, #218dfb 0%, #0c70fb 100%);
			}
		}

		.excellent {
			color: #2b507a;
			background: linear-gradient(146.58deg, rgba(243, 245, 245, 0.5) 0%, rgba(229, 240, 244, 0.5) 100%);
		}

		.teacher {
			color: #9f5300;
			background: linear-gradient(148.48deg, rgba(254, 228, 182, 0.5) 0%, rgba(253, 205, 121, 0.5) 59.21%, rgba(248, 212, 140, 0.5) 100%);
		}

		.warm {
			color: #1580ed;
			background: linear-gradient(146.58deg, rgba(243, 245, 245, 0.5) 0%, rgba(201, 229, 255, 0.5) 100%);
		}

		.body_btns {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin: 40rpx 0;

			.btn {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 310rpx;
				height: 72rpx;
				font-size: 32rpx;
				border-radius: 16rpx;
			}

			.pull {
				color: #fff;
				background-color: #ff8205;
			}

			.refund {
				color: #ff8205;
				border: 2rpx solid #ff8205;
			}
		}

		.body_rule {
			font-size: 36rpx;
		}
	}
}

.pop {
	display: flex;
	flex-direction: column;
	align-items: center;
	box-sizing: border-box;
	padding-bottom: 60rpx;
	font-size: 32rpx;
	color: #001713;
	line-height: 46rpx;

	.pop_title {
		position: relative;
		height: 60rpx;
		width: 100%;
		background-color: #ff8205;

		.title_close {
			position: absolute;
			top: 6rpx;
			right: 30rpx;
		}
	}

	.pop_tips {
		margin-top: 24rpx;
	}

	.pop_msg {
		margin: 50rpx 0;
		width: 456rpx;
	}

	.pop_btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 480rpx;
		height: 72rpx;
		color: #ff8205;
		border-radius: 16rpx;
		border: 2rpx solid #ff8205;
	}
}
</style>
