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.
 
 
 
 
 
huazhiyu/pages/register/findPsw.vue

140 lines
3.3 KiB

<template>
<view class="page">
<view class="logo">
<image src="../../static/image/logo254.png" mode=""></image>
</view>
<!-- 填写区 -->
<view class="input-info">
<view class="info">
<input type="tel" v-model="form.mobile" maxlength="11" placeholder="手机号">
<view class="more"></view>
</view>
<view class="info">
<input type="tel" v-model="form.captcha" maxlength="6" placeholder="请输入验证码">
<view class="more">
<text class="mo" v-show="!codeSend" @click="getCode">获取验证码</text>
<text class="mo" v-show="codeSend">{{timeNum}}秒后重试</text>
</view>
</view>
<view class="info">
<input :password='!isPassword' maxlength="26" v-model="form.newpassword" placeholder="密码">
<view class="more">
<text class="iconfont" :class="isPassword?'icon-eye-on':'icon-eye-off'" @click="isPassword = !isPassword"></text>
</view>
</view>
<view class="info">
<input :password='!isPassword1' maxlength="26" v-model="form.newpassword1" placeholder="确认密码">
<view class="more">
<text class="iconfont" :class="isPassword1?'icon-eye-on':'icon-eye-off'" @click="isPassword1 = !isPassword1"></text>
</view>
</view>
<view class="btn-info">
<view class="btn" :style="isReset?'opacity:1':'opacity:0.4'" @click="isReset?submitModify():''">
<text>确定</text>
</view>
</view>
</view>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
import {forgetPsw,smsSend,smsCheck} from '@/common/api.js'
export default {
data() {
return {
// 表单
form:{
mobile: '',
newpassword: '',
captcha: '',
newpassword1:''
},
codeSend:false,
timeNum:59,
timer:null,
isPassword: false,
isPassword1: false,
isReset: false,
};
},
methods:{
getCode(){
if(!this.form.mobile){
this.$refs.uToast.show({
message:'请输入手机号码'
})
return;
}
smsSend({mobile:this.form.mobile,event:'resetpwd'}).then(res=>{
if(res.code==1){
this.codeSend = true;
this.$refs.uToast.show({
message:res.data.code
})
this.timer = setInterval(()=>{
if(this.timeNum>0){
this.timeNum--;
}else{
this.codeSend = false;
clearInterval(this.timer)
this.timer = null;
}
},1000)
}
})
},
submitModify(){
if(this.form.newpassword1!=this.form.newpassword){
this.$refs.uToast.show({
message:'两次密码输入不一致'
})
return;
}
smsCheck({mobile:this.form.mobile,captcha:this.form.captcha,event:'resetpwd'}).then(res=>{
if(res.code==1){
//校验通过
forgetPsw(this.form).then(res=>{
if(res.code==1){
this.$refs.uToast.show({
message:res.msg
})
setTimeout(()=>{
uni.redirectTo({
url: '/pages/login/login'
},500)
})
}
})
}
})
},
},
destroyed() {
clearInterval(this.timer)
this.timer = null;
},
watch:{
form:{
handler(newValue, oldValue) {
if(newValue.mobile && newValue.newpassword&& newValue.captcha&&newValue.newpassword1){
this.isReset = true;
}else{
this.isReset = false;
}
},
deep: true
}
}
}
</script>
<style scoped lang="scss">
@import 'register.scss';
</style>