jiuyiUniapp/jiuyi2/pages/login/forget.vue

153 lines
3.1 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<script setup>
2024-12-31 14:46:56 +08:00
/**
* 忘记密码
*/
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'
2025-02-03 20:36:02 +08:00
// 加密
import CryptoJS from 'crypto-js';
2024-12-31 14:46:56 +08:00
// 表单
const form = reactive({
// 设备imei
userImei: '',
// 手机号
2025-02-03 20:36:02 +08:00
phoneNumber: '',
2024-12-31 14:46:56 +08:00
// 密码
2025-02-03 20:36:02 +08:00
password: '',
// 验证码
verifyCode: '',
2024-12-31 14:46:56 +08:00
})
// 确认密码
const rePwd = ref('')
// 阅读
const read = ref(false)
// 登录
function handleLogin() {
2025-02-03 20:36:02 +08:00
const data = {
...form
}
2024-12-31 14:46:56 +08:00
// 校验
2025-02-03 20:36:02 +08:00
if (!data.phoneNumber) {
2024-12-31 14:46:56 +08:00
util.alert('请输入手机号')
return
}
2025-02-03 20:36:02 +08:00
if (!data.verifyCode) {
2024-12-31 14:46:56 +08:00
util.alert('请输入验证码')
return
}
2025-02-03 20:36:02 +08:00
if (!data.password) {
2024-12-31 14:46:56 +08:00
util.alert('请输入密码')
return
}
2025-02-03 20:36:02 +08:00
if (data.password !== rePwd.value) {
2024-12-31 14:46:56 +08:00
util.alert('两次输入密码不一致')
return
}
2025-02-03 20:36:02 +08:00
data.password = CryptoJS.MD5(data.password).toString()
2024-12-18 15:46:27 +08:00
2024-12-31 14:46:56 +08:00
// 如果imei为空
2025-02-03 20:36:02 +08:00
if (!data.userImei) {
2024-12-31 14:46:56 +08:00
const info = uni.getSystemInfoSync()
//
2025-02-03 20:36:02 +08:00
data.userImei = info.deviceId
2024-12-31 14:46:56 +08:00
}
2024-12-18 15:46:27 +08:00
2024-12-31 14:46:56 +08:00
// 忘记密码找回
api.login.resetPassword({
2025-02-03 20:36:02 +08:00
data,
2024-12-31 14:46:56 +08:00
}).then(rs => {
if (rs.code == 200) {
util.alert({
content: rs.msg,
showCancel: false,
})
setTimeout(() => {
uni.redirectTo({
url: '/pages/login/loginPhone'
})
}, 500)
return
}
2024-12-18 15:46:27 +08:00
util.alert({
content: rs.msg,
showCancel: false,
})
})
2024-12-31 14:46:56 +08:00
}
2024-12-18 15:46:27 +08:00
</script>
<template>
<view class="appbw">
<view class="container">
<view class="logo mauto">
2024-12-31 14:46:56 +08:00
<image class="logo br10" src="/static/logo.png" mode="aspectFit" />
2024-12-18 15:46:27 +08:00
</view>
<view class="form mt60 mlr60 mb30">
<view class="title mtb30">忘记密码</view>
<view class="inputBox mtb30 ptb10 plr30">
2025-02-03 20:36:02 +08:00
<input type="text" v-model="form.phoneNumber" placeholder="请输入手机号" />
2024-12-18 15:46:27 +08:00
</view>
<view class="inputBox rows mtb30 ptb10 plr30">
2025-02-03 20:36:02 +08:00
<input type="text" v-model="form.verifyCode" placeholder="请输入验证码" class="f1" />
2024-12-18 15:46:27 +08:00
<view class="getCode btn sm plr20">
2025-02-03 20:36:02 +08:00
<getCode event="reset_password" :phone="form.phoneNumber" />
2024-12-18 15:46:27 +08:00
</view>
</view>
<view class="inputBox mtb30 ptb10 plr30">
2025-02-03 20:36:02 +08:00
<input type="text" v-model="form.password" placeholder="请输入密码" />
2024-12-18 15:46:27 +08:00
</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">
2024-12-31 14:46:56 +08:00
//
.container {
margin-top: 15vh;
// 标志
.logo {
width: 200rpx;
height: 200rpx;
}
2024-12-18 15:46:27 +08:00
}
2024-12-31 14:46:56 +08:00
// 获取验证码
.getCode {
color: #666;
background-color: #fff;
}
2024-12-18 15:46:27 +08:00
</style>