You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

208 lines
4.4 KiB

<template>
<view id="warp">
<view class="t_login_passList">
<view class="input_icon">手机号</view>
<input
class="input_css"
v-model="account"
type="number"
border="none"
placeholder="请输入手机号码"
></input>
</view>
<view class="t_login_passList">
<view class="input_icon">验证码</view>
<input
class="input_css2"
v-model="code"
type="number"
border="none"
placeholder="请输入验证码"
></input>
<view class="code">
<view v-if="!isGetCode" @tap="getCode" style="color:#1B64F8FF">获取验证码</view>
<view v-else style="color:#B2B2B2">{{codeTime}} 秒后重发</view>
</view>
</view>
<view class="t_login_passList">
<view class="input_icon">新密码</view>
<input
class="input_css"
v-model="passWord"
border="none"
:password="true"
placeholder="6-10位且包含字母和数字"
></input>
</view>
<view class="t_login_passList">
<view class="input_icon">确认密码</view>
<input
class="input_css"
v-model="rePassWord"
border="none"
:password="true"
placeholder="请再次输入密码"
></input>
</view>
<view class="btn_css">
<button class="btn" @tap="nextHandle">提交</button>
</view>
</view>
</template>
<script>
const {urlList,https} = require('@/static/api');
export default {
data() {
return {
account:'',
code:'',
passWord:'',
rePassWord:'',
isGetCode:false, //是否已经获取验证码
codeTime:60,
}
},
methods: {
// 获取验证码
getCode(){
const iphone = this.account;
const that = this;
if( !/^1[3456789]\d{9}$/.test(iphone) ){
uni.showToast({
title:'请输入手机号',
icon:'none',
duration:1500
})
return;
};
https(urlList.setPwdCode+'/'+iphone,'GET','','正在获取验证码').then(data => {
that.isGetCode = true;
uni.showToast({
title:'验证码获取成功',
icon:'none',
duration:1500,
});
let time = 60;
let Interval = setInterval(function () {
time--;
if (time > 0) {
that.codeTime = time;
} else {
clearInterval(Interval);
that.isGetCode = false;
that.codeTime = 60;
}
}, 1000)
}).catch(err => {
uni.showToast({
title:err,
icon:'none',
duration:1500
})
})
},
nextHandle(){
if(this.account == '' || this.code == ''){
uni.showToast({
title:'请输入手机号和验证码',
icon:'none',
duration:1500
})
return;
};
if(!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,10}$/.test(this.passWord)){
uni.showToast({
title:'密码格式为6-10位字母和数字组合',
icon:'none',
duration:1500
})
return;
};
if(this.passWord !== this.rePassWord){
uni.showToast({
title:'俩次输入的密码不一样',
icon:'none',
duration:1500
})
return;
}
let postData = {
account:this.account,
verifyCode:this.code,
passWord:this.passWord,
rePassWord:this.rePassWord
};
https(urlList.setPassword,'PUT',postData,'正在设置...').then(data => {
uni.showModal({
title: '提示',
content: '密码重置成功,请重新登录',
success: function (res) {
if (res.confirm) {
uni.navigateBack()
}
}
});
}).catch(err => {
uni.showToast({
title:err,
icon:'none',
duration:1500
})
})
},
}
}
</script>
<style lang="scss" scoped>
#warp{
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.t_login_passList{
width:650rpx;
padding: 20rpx 0rpx;
border-bottom: 1rpx solid #e6e6e6;
display: flex;
flex-direction: row;
align-items: center;
.input_icon{
width: 200rpx;
// border: 1px solid red;
margin-top: 5rpx;
display: flex;
align-items: center;
padding-left: 10rpx;
}
.input_css{
width:400rpx;
height: 70rpx;
}
.input_css2{
width: 200rpx;
height: 70rpx;
}
.code{
margin-left: 20rpx;
width: 200rpx;
display: flex;
justify-content: flex-end;
border-left: 1rpx solid #e6e6e6;
font-size: 31rpx;
}
}
.btn_css{
width: 650rpx;
margin-top:60rpx ;
display: block;
.btn{
background-color:#1B64F8FF;
color: white;
}
}
</style>