<template>
	<view class="main">
		<view :style="{height:iSMT+'px'}"></view>

		<view style="height:1.5vh;" />

		<view class="top">
			<view class="top-list">
				<view class="left">
					<img src="/static/my/bindedEmail.png" />
					<text class="label">已绑邮箱：{{ email }}</text>
				</view>
			</view>

			<view class="top-list">
				<view class="left">
					<img src="/static/my/changeEmail.png" />
					<text class="label">+86</text>
					<input type="number" placeholder="请输入您的换绑邮箱" class="input" />
				</view>
				<view class="right">
					<button class="verification" :class="{ 'disabled': gettingCode }" @click="getVerification"
						:disabled="gettingCode">
						{{ gettingCode ? `重新发送 ${time}s` : '获取验证码' }}
					</button>
				</view>
			</view>

			<view class="top-list">
				<view class="left">
					<img src="/static/my/verification.png" />
					<input type="text" placeholder="请输入验证码" class="input" />
				</view>
			</view>
		</view>

		<view class="bottom">
			<button class="change-btn">换绑</button>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue'
	const iSMT = ref(0)
	const email = ref('analsak@16.com')
	const gettingCode = ref(false)
	const time = ref(60)

	const getVerification = () => {
		if (gettingCode.value) return
		gettingCode.value = true

		time.value = 60
		const timer = setInterval(() => {
			time.value--
			if (time.value <= 0) {
				clearInterval(timer)
				gettingCode.value = false
			}
		}, 1000)
	}

	onMounted(() => {
		// 状态栏高度
		iSMT.value = uni.getSystemInfoSync().statusBarHeight;
		console.log('看看高度', iSMT.value)
	})
</script>

<style>
	.top {
		height: auto;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.top-list {
		width: 630rpx;
		height: 7vh;
		margin: 0rpx 40rpx;
		display: flex;
		align-items: center;
		border-bottom: 1rpx solid #eee;
	}

	.left {
		flex: 1;
		display: flex;
		align-items: center;
	}

	.label {
		font-size: 28rpx;
		margin-left: 10rpx;
	}

	.right {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.input {
		flex: 1;
		height: 70rpx;
		font-size: 29rpx;
		margin-left: 20rpx;
	}

	.verification {
		font-size: 24rpx;
		border-radius: 10rpx;
		background-color: rgb(230, 230, 230);
	}

	.bottom {
		height: 22vh;
		background-color: white;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.change-btn {
		height: 85rpx;
		width: 610rpx;
		padding:0 20rpx;
		background-color: black;
		color: white;
		border-radius: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>