<template>
|
<view>
|
<view class="login-title">
|
<view class="login-title-1">重置密码</view>
|
</view>
|
<view class="login-list">
|
<view class="login-item">
|
<input type="tel" v-model="formData.phone" placeholder="请输入手机号" />
|
</view>
|
<view class="login-item">
|
<input type="password" v-model="formData.pass" placeholder="请输入新密码" />
|
</view>
|
<view class="login-item">
|
<input type="password" v-model="formData.tpass" placeholder="请确认新密码" />
|
</view>
|
<view class="login-item">
|
<input type="number" v-model="formData.code" maxlength="4" placeholder="请输入验证码" />
|
<text class="code2" v-if="leftTime < 60">{{leftTime}}S后获取</text>
|
<text class="code" @click="sendCode" v-else>获取验证码</text>
|
</view>
|
</view>
|
<view class="loginBtn">
|
<view class="loginBtn-desc">
|
<image @click="agreeClick" class="loginBtn-icon" :src="!loginAct ? '/static/imgs/check.png' : '/static/imgs/checked.png'" mode=""></image>
|
<text>我已阅读并同意</text>
|
<text class="blue" @tap="goAgree(1)">《注册协议》</text>
|
<text class="blue" @tap="goAgree(1)">《隐私政策》</text>
|
</view>
|
<view :class="loginAct ? 'login-btn active' : 'login-btn'" @click="findPassword">找回密码</view>
|
<view class="loginDesc">
|
<view class="fc" @tap="$util.goPages('/pages/login/login')">已有账号,立即登录</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
loginAct: false,
|
formData: {
|
phone: '',
|
pass: '',
|
tpass: '',
|
code: '',
|
},
|
phoneReg: /^\d{11}$/,
|
leftTime: 60,
|
}
|
},
|
onLoad(op) {
|
},
|
methods: {
|
agreeClick () {
|
this.loginAct = !this.loginAct
|
},
|
goAgree (t) {
|
// #ifdef APP-PLUS
|
let url = this.$baseUrl + '/?gp=' + t
|
plus.runtime.openURL(url)
|
// #endif
|
},
|
findPassword () {
|
let t = this
|
if(!t.loginAct) {
|
return uni.showToast({
|
title: '请阅读并同意协议政策',
|
icon: 'error'
|
})
|
}
|
if(t.formData.phone == '' || !t.phoneReg.test(t.formData.phone)){
|
return uni.showToast({
|
title: '手机号错误!',
|
icon: 'error',
|
})
|
}
|
if(t.formData.pass == ''){
|
return uni.showToast({
|
title: '请输入密码!',
|
icon: 'error',
|
})
|
}
|
if(t.formData.tpass == ''){
|
return uni.showToast({
|
title: '请输入确认密码!',
|
icon: 'error',
|
})
|
}
|
if(t.formData.tpass != t.formData.pass){
|
return uni.showToast({
|
title: '密码不一致!',
|
icon: 'error',
|
})
|
}
|
if(t.formData.code == ''){
|
return uni.showToast({
|
title: '请输入验证码!',
|
icon: 'error',
|
})
|
}
|
t.$util.post('User/findpass', this.formData).then(res => {
|
if(res.code == 1) {
|
uni.showToast({
|
title: res.msg || '操作成功'
|
})
|
setTimeout(() => {
|
t.$util.goPages('/pages/login/login')
|
}, 1500)
|
} else {
|
uni.showToast({
|
title: res.msg || '登录失败',
|
icon: 'error'
|
})
|
}
|
})
|
},
|
sendCode () {
|
let t = this
|
if(this.formData.phone == '' || !this.phoneReg.test(t.formData.phone)){
|
return uni.showToast({
|
title: '手机号错误!',
|
icon: 'error',
|
})
|
}
|
if (this.leftTime < 60) {
|
return false
|
}
|
this.$util.post('Sms/sendVerificationCode', {phone: this.formData.phone}).then(res => {
|
if(res.code == 1){
|
console.log(res)
|
t.countDown()
|
uni.showToast({
|
title:'发送成功',
|
icon:'none'
|
})
|
} else {
|
uni.showToast({
|
title: res.msg,
|
icon: 'none',
|
})
|
}
|
})
|
},
|
countDown() {
|
this.leftTime--
|
if (this.leftTime > 0) {
|
setTimeout(this.countDown, 1000)
|
} else {
|
this.leftTime = 60
|
}
|
},
|
}
|
}
|
</script>
|
|
<style>
|
@import url(/static/css/login.css);
|
</style>
|