jiuyiUniapp/jiuyi2/pages/login/forget.vue

148 lines
2.9 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<script setup>
/**
* 忘记密码
*/
import {
ref,
reactive,
} from 'vue'
// 工具库
import util from "@/common/js/util.js"
// 获取验证码
import getCode from '@/components/getCode/getCode.vue'
// 须知
import notice from '@/components/login/notice'
// api
import api from '@/api/index'
// 表单
const form = reactive({
// 设备imei
userImei: '',
// 手机号
userPhone: '',
// 密码
userPassword: '',
})
// 确认密码
const rePwd = ref('')
// 验证码
const cache = ref('')
// 阅读
const read = ref(false)
// 登录
function handleLogin() {
// 校验
if (!form.userPhone) {
util.alert('请输入手机号')
return
}
if (!cache.value) {
util.alert('请输入验证码')
return
}
if (!form.userPassword) {
util.alert('请输入密码')
return
}
if (form.userPassword !== rePwd.value) {
util.alert('两次输入密码不一致')
return
}
// 如果imei为空
if (!form.userImei) {
const info = uni.getSystemInfoSync()
//
form.userImei = info.deviceId
}
// 忘记密码找回
api.login.resetPassword({
data: form,
path: [cache.value],
}).then(rs => {
if (rs.code == 200) {
util.alert({
content: rs.msg,
showCancel: false,
})
setTimeout(() => {
uni.redirectTo({
url: '/pages/login/loginPhone'
})
}, 500)
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
</script>
<template>
<view class="appbw">
<view class="container">
<view class="logo mauto">
<image src="/static/Jiu Yi.png" mode="aspectFit" />
</view>
<view class="form mt60 mlr60 mb30">
<view class="title mtb30">忘记密码</view>
<view class="inputBox mtb30 ptb10 plr30">
<input type="text" v-model="form.userPhone" placeholder="请输入手机号" />
</view>
<view class="inputBox rows mtb30 ptb10 plr30">
<input type="text" v-model="cache" placeholder="请输入验证码" class="f1" />
<view class="getCode btn sm plr20">
<getCode event="reset_password" :phone="form.userPhone" />
</view>
</view>
<view class="inputBox mtb30 ptb10 plr30">
<input type="text" v-model="form.userPassword" placeholder="请输入密码" />
</view>
<view class="inputBox mtb30 ptb10 plr30">
<input type="text" v-model="rePwd" placeholder="请输入确认密码" />
</view>
<view class="rows c333 f24">
<navigator url="/pages/login/loginPhone" open-type="redirect">已有账号去登录</navigator>
<navigator url="/pages/login/retrieve" open-type="redirect">通过实名找回账号</navigator>
</view>
<view class="btn lg bar black mtb30" @click="handleLogin">确认</view>
</view>
</view>
<view class="footer">
<!-- <notice class="mb60" v-model:value="read" /> -->
</view>
</view>
</template>
<style lang="scss">
//
.container {
margin-top: 15vh;
// 标志
.logo {
width: 152rpx;
height: 80rpx;
}
}
// 获取验证码
.getCode {
color: #666;
background-color: #fff;
}
</style>