校验短信验证码
This commit is contained in:
@@ -20,6 +20,10 @@ export const getLoginBySms = data => {
|
||||
export const getResetPassword = data => {
|
||||
return post('/api/butler/auth/forgetPassword', data)
|
||||
}
|
||||
// 忘记密码 校验短信验证码
|
||||
export const verifySmsCode = (data) =>{
|
||||
return post('/api/butler/auth/verifySmsCode',data)
|
||||
}
|
||||
|
||||
// ======首页=====
|
||||
// 获取小区列表
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!-- 手机号输入框 -->
|
||||
<view class="input-item">
|
||||
<view class="input-icon">
|
||||
<image src="http://wuye.ckdzkj.com/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
|
||||
<image src="https://wuye.ckdzkj.com/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
|
||||
</view>
|
||||
<uni-easyinput class="input-content" type="number" v-model="phoneNumber" trim="all"
|
||||
placeholder="请输入手机号" :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- 验证码输入 + 获取验证码按钮 -->
|
||||
<view class="input-item verify-item">
|
||||
<view class="input-icon">
|
||||
<image src="http://wuye.ckdzkj.com/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
|
||||
<image src="https://wuye.ckdzkj.com/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
|
||||
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
|
||||
</view>
|
||||
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" trim="all"
|
||||
@@ -29,21 +29,21 @@
|
||||
<!-- 下一步 -->
|
||||
<button
|
||||
class="forget-btn"
|
||||
:disabled="!canRegister"
|
||||
@click="handleNext"
|
||||
>
|
||||
下一步
|
||||
:disabled="!canRegister || submitting"
|
||||
@click="handleNext">
|
||||
{{ submitting ? '校验中...' : '下一步' }}
|
||||
</button>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, computed, onUnmounted } from 'vue';
|
||||
import {getSendCode} from '../../api/api.js'
|
||||
import {getSendCode,verifySmsCode} from '../../api/api.js'
|
||||
|
||||
// ====响应式数据======
|
||||
const phoneNumber = ref('')
|
||||
const verifyCode = ref('')
|
||||
const submitting = ref(false)
|
||||
|
||||
const countDown = ref(0)
|
||||
let timer = null;
|
||||
@@ -85,6 +85,11 @@ const getVerifyCode = () => {
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}).catch((err)=>{
|
||||
uni.showToast({
|
||||
title: err.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
@@ -99,18 +104,34 @@ const canRegister = computed(() => {
|
||||
});
|
||||
// 下一步
|
||||
const handleNext = () =>{
|
||||
if(!canRegister.value){
|
||||
uni.showToast({ title: '请输入正确的手机号和验证码',icon: 'error'});
|
||||
return
|
||||
}
|
||||
if(submitting.value) return
|
||||
submitting.value = true
|
||||
// 后端验证短信
|
||||
verifySmsCode({
|
||||
phone: phoneNumber.value,
|
||||
smsCode: verifyCode.value,
|
||||
scene: 'reset'
|
||||
}).then(res =>{
|
||||
// 把参数存到本地缓存
|
||||
uni.setStorageSync('tempChangePwdParams', {
|
||||
phoneNumber:phoneNumber.value,
|
||||
verifyCode: verifyCode.value
|
||||
});
|
||||
if(!canRegister.value){
|
||||
uni.showToast({ title: '请输入',icon: 'error'});
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/loginSub/change-pwd'
|
||||
});
|
||||
}).catch(err =>{
|
||||
uni.showToast({
|
||||
title: err.msg || '验证码错误',
|
||||
icon: 'none'
|
||||
});
|
||||
}).finally(() =>{
|
||||
submitting.value = false
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user