<template>
	<view class="page">
		<u-navbar title="安全验证" :border-bottom="false" :background="bgc" title-color='#000' back-icon-color="000" title-size='36'
			height='50'></u-navbar>
        <view class="" v-if="indexlag == 2">
        	<view class="pass">
        		密码验证
        	</view>
			<view class="val" style="margin-top: 64rpx;">
				<view class="lt">
					密码
				</view>
				<input type="text" placeholder="请输入密码" />
			</view>
			<view class="btnmm" @click="btnnewpass">
				确定
			</view>
			<view class="ts">
				提示：请输入密码验证您的身份，成功后可更换手机号
			</view>
        </view>
		<!-- 短信验证码 -->
		<view class="" v-else>
			<view class="pass">
				输入短信验证码
			</view>
			<view class="" style="font-size: 30rpx;color: #3D3D3D;font-weight: 600;margin-top: 12rpx;padding-left: 50rpx;">
				已向<text style="color: #4C97E7;"> +86 158****1232</text> 发送验证码
			</view>
			<view class="val" style="margin-top: 64rpx;">
				<input type="text" placeholder="请输入验证码" />
			</view>
			<view class="ts" style="color: #4C97E7;" v-if="countdown == 60" @click="btnhuoqu">
				重新发送
			</view>
			<view v-else class="ts">
				{{countdown}}秒后重发
			</view>
			<view class="btnmm" @click="btnnewpass">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#F9F8FF",
				},
				countdown: 60,
				timer: null,
				indexlag:''
			}
		},
		onLoad(option) {
            this.indexlag = option.index
			if(option.index == 1){
				this.startCountdown()
			}
		},
		onUnload() {
		    // 页面卸载时清除定时器，防止内存泄漏  
		    clearInterval(this.timer);  
		},  
		// 分享到好友（会话）
		  onShareAppMessage: function () {  
		    return {  
		      title: '创想物联',  
		      path: '/pages/shouye/index'  
		    }  
		  },  
		  
		  // 分享到朋友圈  
		  onShareTimeline: function () {  
		    return {  
		      title: '创想物联',  
		      query: '',  
		      path: '/pages/shouye/index'  
		    }  
		  },
		onShow() {
			
		},

		methods: {
	      // 验证码倒计时
	      startCountdown() {
	            this.timer = setInterval(() => {  
	              if (this.countdown > 0) {  
	                this.countdown--
	              } else {  
	                clearInterval(this.timer); // 倒计时结束，清除定时器  
	                this.countdown = 60
	            }  
	          }, 1000); // 每秒更新一次  
	      }, 
	      // 点击获取验证码
	      btnhuoqu(){
	      	this.startCountdown()
	      },
		  // 点击跳转设置新密码页面
		  btnnewpass(){
			  uni.navigateTo({
			  	url:'/page_fenbao/statulist/fault/newpass'
			  })
		  }
			
		}
	}
</script>

<style lang="scss">
	.btnmm{
		width: 652rpx;
		height: 94rpx;
		background: #4C97E7;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
		opacity: 0.5;
		text-align: center;
		line-height: 94rpx;
		margin: auto;
		margin-top: 80rpx;
		font-size: 36rpx;
		color: #FFFFFF;
		font-weight: 600;
	}
	.ts{
		font-size: 24rpx;
		color: #808080;
		font-weight: 600;
		margin-top: 30rpx;
		padding-left: 50rpx;
		box-sizing: border-box;
	}
	.pass{
		font-size: 60rpx;
		color: #3D3D3D;
		font-weight: 600;
		padding-left: 50rpx;
		margin-top: 78rpx;
	}
	.val{
		width: 652rpx;
		height: 94rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
		border: 2rpx solid #808080;
		margin: auto;
		margin-top: 24rpx;
	    display: flex;
		align-items: center;
		.lt{
			font-size: 32rpx;
			color: #3D3D3D;
			font-weight: 600;
			border-right: 1rpx solid #D8D8D8;
			height: 66rpx;
			line-height: 66rpx;
			padding-right: 22rpx;
			padding-left: 26rpx;
			box-sizing: border-box;
		}
		input{
			margin-left: 22rpx;
		}
	}
	/deep/ .u-title{
		padding-bottom: 22rpx;
	}
	/deep/ .uicon-nav-back{
		padding-bottom: 22rpx;
	}
    
	page {
		// background: linear-gradient(180deg, #8883F0 0%, rgba(255, 255, 255, 0) 100%);
		background: #F4F5F7;
	}

	.page {
		width: 750rpx;
	}

	
	
</style>