<script setup>
	import {
		reactive
	} from "vue";
	import {
		onLoad
	} from '@dcloudio/uni-app';
	const tools = require("../../../static/etcUtil/tools.js");
	import {
		request
	} from "@/utils/network/request.js";
	import {
		stringToJson
	} from "@/utils/network/encryption.js";
	import * as IFCODE from "@/utils/network/api.js";
	const state = reactive({
		channelId: "",
		newCodeStatus: '获取验证码',
		newCodeBtnDisabled: false,
		codeInterval: 59,
		code: "", //短信验证码
		mobile: "15885137270", //手机号
	})

	onLoad((option) => {

	})

	//发送验证码
	const sendCodeToNewPhone = () => {
		if (state.newCodeBtnDisabled) {
			return;
		}
		if (!state.mobile) {
			tools.showToastAlert("手机号不能为空");
			return;
		}
		state.newCodeBtnDisabled = true;
		state.newCodeStatus = "正在发送";

		let second = state.codeInterval;

		let interval = setInterval(function() {
			if (second <= 0) {
				clearInterval(interval);

				state.newCodeStatus = '获取验证码';
				state.newCodeBtnDisabled = false;

			} else {

				state.newCodeStatus = second + ' s';
				second--;
			}
		}, 1000);

		// const options = {
		//   type: 2,
		//   data: {},
		//   method: "POST",
		//   showLoading: true,
		// };
		// request(IFCODE.gongWuCheLogin, options).then((res) => {


		// });

	}

	//确定认领
	const bindSubmit = () => {
		console.log("bindSubmit", state);
	}
</script>
<template>
	<view class="wrapper">
		<view class="mainView">
			<view class="li">
				<text>车牌号：</text>
				{{state.newCodeStatus}}
			</view>
			<view class="li">
				<text>车牌颜色：</text>
				{{state.newCodeStatus}}
			</view>
			<view class="li">
				<text>ETC卡号：</text>
				{{state.newCodeStatus}}
			</view>
			<view class="li">
				<text>卡版本号：</text>
				{{state.newCodeStatus}}
			</view>
			<view class="li">
				<text>OBU号：</text>
				{{state.newCodeStatus}}
			</view>
			<view class="li">
				<text>OBU版本号：</text>
				{{state.newCodeStatus}}
			</view>
			<view class="li phone">
				<text>手机号：</text>
				<input class="input" placeholder="手机号" v-model="state.mobile" type="number" maxlength="11"
					disabled="false" />
				<button class="right" @click="sendCodeToNewPhone"
					:disabled="state.newCodeBtnDisabled">{{state.newCodeStatus}}</button>
			</view>
			<view class="li">
				<text>验证码：</text>
				<input class="input" placeholder="请输入验证码" v-model="state.code" type="number" maxlength="6" />
			</view>
			<view class="li" style="border: none;">
				<text>推广码：</text>
				<input class="input" placeholder="请输入推广码" v-model="state.channelId" />
			</view>
		</view>
		<view class="comfirm_btn" @click="bindSubmit">确认领取</view>
	</view>
</template>


<style>
	page {
		background: #eef7f7;
	}
</style>


<style scoped>
	.li {
		padding: 25rpx 30rpx;
		border-bottom: 1px dashed #cccccc;
		color: #333333;
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 32rpx;
	}

	.mainView {
		margin: 50rpx 40rpx;
		border-radius: 16rpx;
		box-shadow: 0rpx 6rpx 25rpx 0rpx rgba(0, 0, 0, 0.3);
	}

	.li>text {
		color: black;
		font-size: 30rpx;
	}

	.li input {
		font-size: 30rpx;
	}

	.phone input {
		flex: 1;
	}

	.comfirm_btn {
		width: calc(100% - 60rpx);
		margin-left: 30rpx;
		margin-top: 100rpx;
		height: 80rpx;
		border-radius: 40rpx;
		line-height: 80rpx;
		text-align: center;
		color: #fff;
		font-size: 32rpx;
		background: linear-gradient(to right, #13E7C1, #43A1E0);
	}

	.comfirm_btn:active {
		background: #43A1E0;
	}
	
	.right {
		/* width: calc(40% - 30rpx); */
		width: 180rpx;
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		/* margin: 15rpx 30rpx; */
		background: linear-gradient(to right, #13E7C1, #43A1E0);
		color: #fff;
		border-radius: 8rpx;
		font-size: 24rpx;
	}
	.right::after{
		border: none;
	}

	.right[disabled] {
		background: #e7e7e7;
		color: #666;
		border: 1px solid #ccc;
	}
</style>
