mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-12 04:03:42 +08:00
feat: email registration function is ready
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<div class="user-info" id="user-info">
|
||||
<el-form v-if="user.id" :model="user" label-width="150px">
|
||||
<el-form-item label="账户">
|
||||
<span>{{ user.mobile }}</span>
|
||||
<span>{{ user.username }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="剩余对话次数">
|
||||
<el-tag>{{ user['calls'] }}</el-tag>
|
||||
@@ -54,17 +54,14 @@ const user = ref({
|
||||
username: '',
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
mobile: '',
|
||||
calls: 0,
|
||||
tokens: 0,
|
||||
chat_config: {api_keys: {OpenAI: "", Azure: "", ChatGLM: ""}}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 获取最新用户信息
|
||||
httpGet('/api/user/profile').then(res => {
|
||||
user.value = res.data
|
||||
user.value.chat_config.api_keys = res.data.chat_config.api_keys ?? {OpenAI: "", Azure: "", ChatGLM: ""}
|
||||
}).catch(e => {
|
||||
ElMessage.error("获取用户信息失败:" + e.message)
|
||||
});
|
||||
|
||||
@@ -7,21 +7,21 @@
|
||||
:title="title"
|
||||
>
|
||||
<div class="form" id="bind-mobile-form">
|
||||
<el-alert v-if="mobile !== ''" type="info" show-icon :closable="false" style="margin-bottom: 20px;">
|
||||
<p>当前用户已绑定手机号:{{ mobile }}, 绑定其他手机号之后自动解绑该手机号。</p>
|
||||
<el-alert v-if="username !== ''" type="info" show-icon :closable="false" style="margin-bottom: 20px;">
|
||||
<p>当前绑定账号:{{ username }},只允许使绑定有效的手机号或者邮箱地址作为登录账号。</p>
|
||||
</el-alert>
|
||||
|
||||
<el-form :model="form" label-width="120px">
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="form.mobile"/>
|
||||
<el-form-item label="新账号">
|
||||
<el-input v-model="form.username"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机验证码">
|
||||
<el-form-item label="验证码">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="16">
|
||||
<el-input v-model="form.code" maxlength="6"/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<send-msg size="" :mobile="form.mobile"/>
|
||||
<send-msg size="" :receiver="form.username"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
@@ -43,37 +43,36 @@ import {computed, ref} from "vue";
|
||||
import SendMsg from "@/components/SendMsg.vue";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {httpPost} from "@/utils/http";
|
||||
import {validateMobile} from "@/utils/validate";
|
||||
import {validateEmail, validateMobile} from "@/utils/validate";
|
||||
|
||||
const props = defineProps({
|
||||
show: Boolean,
|
||||
mobile: String
|
||||
username: String
|
||||
});
|
||||
|
||||
const showDialog = computed(() => {
|
||||
return props.show
|
||||
})
|
||||
|
||||
const title = ref('绑定手机号')
|
||||
const title = ref('重置登录账号')
|
||||
const form = ref({
|
||||
mobile: '',
|
||||
username: '',
|
||||
code: ''
|
||||
})
|
||||
|
||||
const emits = defineEmits(['hide']);
|
||||
|
||||
const save = () => {
|
||||
if (!validateMobile(form.value.mobile)) {
|
||||
return ElMessage.error("请输入正确的手机号码");
|
||||
if (!validateMobile(form.value.username) && !validateEmail(form.value.username)) {
|
||||
return ElMessage.error("请输入合法的手机号/邮箱地址")
|
||||
}
|
||||
if (form.value.code === '') {
|
||||
return ElMessage.error("请输入短信验证码");
|
||||
return ElMessage.error("请输入验证码");
|
||||
}
|
||||
|
||||
httpPost('/api/user/bind/mobile', form.value).then(() => {
|
||||
httpPost('/api/user/bind/username', form.value).then(() => {
|
||||
ElMessage.success({
|
||||
message: '绑定成功',
|
||||
appendTo: '#bind-mobile-form',
|
||||
duration: 1000,
|
||||
onClose: () => emits('hide', false)
|
||||
})
|
||||
@@ -10,16 +10,16 @@
|
||||
<div class="form">
|
||||
|
||||
<el-form :model="form" label-width="120px" label-position="left">
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="form.mobile"/>
|
||||
<el-form-item label="用户名">
|
||||
<el-input v-model="form.username" placeholder="手机号/邮箱地址"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机验证码">
|
||||
<el-form-item label="验证码">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="16">
|
||||
<el-input v-model="form.code" maxlength="6"/>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<send-msg size="" :mobile="form.mobile"/>
|
||||
<send-msg size="" :receiver="form.username"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
@@ -48,7 +48,7 @@ import {computed, ref} from "vue";
|
||||
import SendMsg from "@/components/SendMsg.vue";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {httpPost} from "@/utils/http";
|
||||
import {validateMobile} from "@/utils/validate";
|
||||
import {validateEmail, validateMobile} from "@/utils/validate";
|
||||
|
||||
const props = defineProps({
|
||||
show: Boolean,
|
||||
@@ -61,7 +61,7 @@ const showDialog = computed(() => {
|
||||
|
||||
const title = ref('重置密码')
|
||||
const form = ref({
|
||||
mobile: '',
|
||||
username: '',
|
||||
code: '',
|
||||
password: '',
|
||||
repass: ''
|
||||
@@ -70,11 +70,11 @@ const form = ref({
|
||||
const emits = defineEmits(['hide']);
|
||||
|
||||
const save = () => {
|
||||
if (!validateMobile(form.value.mobile)) {
|
||||
return ElMessage.error("请输入正确的手机号码");
|
||||
if (!validateMobile(form.value.username) && !validateEmail(form.value.username)) {
|
||||
return ElMessage.error("请输入正确的手机号码/邮箱地址");
|
||||
}
|
||||
if (form.value.code === '') {
|
||||
return ElMessage.error("请输入短信验证码");
|
||||
return ElMessage.error("请输入验证码");
|
||||
}
|
||||
if (form.value.repass !== form.value.password) {
|
||||
return ElMessage.error("两次输入密码不一致");
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
// 发送短信验证码组件
|
||||
import {ref} from "vue";
|
||||
import lodash from 'lodash'
|
||||
import {validateMobile} from "@/utils/validate";
|
||||
import {validateEmail, validateMobile} from "@/utils/validate";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {httpGet, httpPost} from "@/utils/http";
|
||||
import CaptchaPlus from "@/components/CaptchaPlus.vue";
|
||||
|
||||
const props = defineProps({
|
||||
mobile: String,
|
||||
receiver: String,
|
||||
size: String,
|
||||
});
|
||||
const btnText = ref('发送验证码')
|
||||
@@ -82,8 +82,8 @@ const handleConfirm = (dots) => {
|
||||
}
|
||||
|
||||
const loadCaptcha = () => {
|
||||
if (!validateMobile(props.mobile)) {
|
||||
return ElMessage.error("请输入合法的手机号")
|
||||
if (!validateMobile(props.receiver) && !validateEmail(props.receiver)) {
|
||||
return ElMessage.error("请输入合法的手机号/邮箱地址")
|
||||
}
|
||||
|
||||
showCaptcha.value = true
|
||||
@@ -96,8 +96,8 @@ const sendMsg = () => {
|
||||
}
|
||||
|
||||
canSend.value = false
|
||||
httpPost('/api/sms/code', {mobile: props.mobile, key: captKey.value, dots: dots.value}).then(() => {
|
||||
ElMessage.success('短信发送成功')
|
||||
httpPost('/api/sms/code', {receiver: props.receiver, key: captKey.value, dots: dots.value}).then(() => {
|
||||
ElMessage.success('验证码发送成功')
|
||||
let time = 120
|
||||
btnText.value = time
|
||||
const handler = setInterval(() => {
|
||||
@@ -112,7 +112,7 @@ const sendMsg = () => {
|
||||
}, 1000)
|
||||
}).catch(e => {
|
||||
canSend.value = true
|
||||
ElMessage.error('短信发送失败:' + e.message)
|
||||
ElMessage.error('验证码发送失败:' + e.message)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<el-form-item label="昵称">
|
||||
<el-input v-model="user['nickname']"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号">
|
||||
<span>{{ user.mobile }}</span>
|
||||
<el-form-item label="账号">
|
||||
<span>{{ user.username }}</span>
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="light"
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<template>
|
||||
<van-dialog v-model:show="showDialog"
|
||||
:title="title"
|
||||
:show-cancel-button="mobile !== ''"
|
||||
@confirm="save"
|
||||
@cancel="close">
|
||||
<van-cell-group inset>
|
||||
<van-field
|
||||
v-model="form.mobile"
|
||||
label="手机号"
|
||||
placeholder="请输入手机号"
|
||||
/>
|
||||
<van-field
|
||||
v-model.number="form.code"
|
||||
center
|
||||
clearable
|
||||
label="短信验证码"
|
||||
placeholder="请输入短信验证码"
|
||||
>
|
||||
<template #button>
|
||||
<send-msg size="small" :mobile="form.mobile"/>
|
||||
</template>
|
||||
</van-field>
|
||||
</van-cell-group>
|
||||
</van-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {computed, ref} from "vue";
|
||||
import {httpPost} from "@/utils/http";
|
||||
import {validateMobile} from "@/utils/validate";
|
||||
import {showNotify} from "vant";
|
||||
import SendMsg from "@/components/SendMsg.vue";
|
||||
|
||||
const props = defineProps({
|
||||
show: Boolean,
|
||||
mobile: String
|
||||
});
|
||||
|
||||
const showDialog = computed(() => {
|
||||
return props.show
|
||||
})
|
||||
|
||||
const title = ref('绑定手机号')
|
||||
const form = ref({
|
||||
mobile: '',
|
||||
code: ''
|
||||
})
|
||||
|
||||
const emits = defineEmits(['hide']);
|
||||
|
||||
const save = () => {
|
||||
if (!validateMobile(form.value.mobile)) {
|
||||
return showNotify({type: 'danger', message: '请输入正确的手机号码'});
|
||||
}
|
||||
if (form.value.code === '') {
|
||||
return showNotify({type: "danger", message: '请输入短信验证码'})
|
||||
}
|
||||
|
||||
httpPost('/api/user/bind/mobile', form.value).then(() => {
|
||||
showNotify({type: 'success', message: '绑定成功', duration: 1000, onClose: emits('hide', false)});
|
||||
}).catch(e => {
|
||||
showNotify({type: 'danger', message: '绑定失败:' + e.message, duration: 2000});
|
||||
})
|
||||
}
|
||||
|
||||
const close = function () {
|
||||
emits('hide', false);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user