完全重写了后端,现在commit一下以前的更改,开始全新的适配

This commit is contained in:
高子兴 2024-07-01 20:16:07 +08:00
parent ac7272d59a
commit ea20be6058
2 changed files with 57 additions and 20 deletions

View File

@ -1,19 +1,19 @@
import axios from 'axios';
const state = {
user: null,
isAuthenticated: false,
user: null,
isAuthenticated: false,
};
const mutations = {
setUser(state, user) {
state.user = user;
state.isAuthenticated = true;
},
clearUser(state) {
state.user = null;
state.isAuthenticated = false;
},
setUser(state, user) {
state.user = user;
state.isAuthenticated = true;
},
clearUser(state) {
state.user = null;
state.isAuthenticated = false;
},
};
const actions = {

View File

@ -1,21 +1,58 @@
<script setup>
import { ref } from 'vue';
import { ElInput, ElButton, ElForm, ElFormItem, ElMessage } from 'element-plus';
import {ref} from 'vue';
import {ElButton, ElForm, ElFormItem, ElInput, ElMessage} from 'element-plus';
import 'element-plus/dist/index.css';
import axios from 'axios';
import {useRouter} from 'vue-router';
const companyName = ref('');
const contactInfo = ref('');
const password = ref('');
const verificationCode = ref('');
const router = useRouter();
const handleRegister = () => {
console.log('Registering with', { companyName: companyName.value, contactInfo: contactInfo.value, password: password.value, verificationCode: verificationCode.value });
//
const handleRegister = async () => {
console.log('Registering with', {
companyName: companyName.value,
contactInfo: contactInfo.value,
password: password.value,
verificationCode: verificationCode.value
});
try {
const response = await axios.post('/api/register', {
companyName: companyName.value,
contactInfo: contactInfo.value,
password: password.value,
verificationCode: verificationCode.value,
});
if (response.status === 200) {
ElMessage.success('注册成功');
router.push('/login');
} else {
ElMessage.error('注册失败,请稍后再试');
}
} catch (error) {
ElMessage.error('注册失败,请稍后再试');
}
};
const sendVerificationCode = () => {
const sendVerificationCode = async () => {
// try {
// const response = await axios.post('/api/send-verification-code', {
// contactInfo: contactInfo.value,
// });
//
// if (response.status === 200) {
// ElMessage.success('');
// } else {
// ElMessage.error('');
// }
// } catch (error) {
// ElMessage.error('');
// }
ElMessage.success('验证码已发送');
//
};
</script>
@ -26,15 +63,15 @@ const sendVerificationCode = () => {
<ElForm @submit.prevent="handleRegister">
<ElFormItem>
<label for="companyName">企业名称</label>
<ElInput v-model="companyName" type="text" id="companyName" placeholder="请输入企业名称" required />
<ElInput v-model="companyName" type="text" id="companyName" placeholder="请输入企业名称" required/>
</ElFormItem>
<ElFormItem>
<label for="contactInfo">企业联系方式</label>
<ElInput v-model="contactInfo" type="text" id="contactInfo" placeholder="请输入企业联系方式" required />
<ElInput v-model="contactInfo" type="text" id="contactInfo" placeholder="请输入企业联系方式" required/>
</ElFormItem>
<ElFormItem>
<label for="password">密码</label>
<ElInput v-model="password" type="password" id="password" placeholder="请输入密码" required />
<ElInput v-model="password" type="password" id="password" placeholder="请输入密码" required/>
</ElFormItem>
<ElFormItem>
<label for="verificationCode">验证码</label>