<template>
	<view class="conent">
		<view class="input-row">
			<text>183****9247</text>
		</view>
		<view class="input-row" >
			<view style="width: 65%;"><input maxlength="11" type="text" v-model="code" placeholder="请输入验证码" /></view>
			<view style="width: 30%;"><text v-if="codetimecode == false" style="font-size: 26upx;color: #3971E2;" @click="getCode()">获取验证码</text>
			<text v-else style="font-size: 26upx;margin-right: 20upx;color: #3971E2;" >{{countdown}}秒后重新获取</text></view>
		</view>
		<view class="forgetpsd"><button  class="primary log-btn" @click="registerck">修改密码</button></view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				account:'',
				password:'',
				newpassword:'',
				code:'',
				countdown: '60',
				timer: null,
				codetimecode: false
			}
		},
		methods:{
			getCode() {
				const data = {
					phone: this.account,
					codetype: '1'
				};
				api.code( data).then(res => {
					console.log(res, 'asok')
					if(res.code == 0){
						this.sendCode()
						this.codetimecode = true
						uni.showToast({
							title:'发送成功',
							icon:'none'
						})
					}else {
						uni.showToast({
							title: res.msg,
							icon:'none'
						})
					}
				})
			},
			sendCode(){
			    this.loading();  //启动定时器
			    this.timer = setInterval(() =>{
			         //创建定时器
			        if(this.countdown === 1){
			            this.clearTimer();  //关闭定时器
			            this.skipStep();
			        }else{
			            this.loading();
			        }
			    },1000);
			},
			      loading(){
			          //启动定时器
			          this.countdown--;  //定时器减1
			        },
					 clearTimer(){
					           //清除定时器
					           clearInterval(this.timer);
					           this.timer = null;
							   this.codetimecode = false
					        },


		}
	}
</script>

<style scoped>
	page {
		background-color: RGBA(252, 252, 252, 1);
	}

	.conent {
		width: 100vw;
		overflow: hidden;
	}

	.input-row {
		height: 100upx;
		display: flex;
		margin: 20upx 0;
		align-items: center;
		justify-content: space-between;
		padding: 0 20upx;
		background: #FFFFFF;
		border-bottom: 1upx solid #C8C7CC;
	}
	.input-row-password{
		height: 100upx;
		display: flex;
		justify-content: space-around;
		margin: 20upx 0;
		align-items: center;
		padding-left: 20upx;
		background: #FFFFFF;
	}
	.forgetpsd{
		margin: 40upx 20upx;
	}
	.log-btn {
		border-radius: 10upx;
		font-size: 34upx;
		color: #FFFFFF;
		background:  #20269B;
		box-shadow: 0px 16upx 32upx 0px rgba(2, 168, 244, 0.24);
	}
	
</style>
