完全重写了后端,现在commit一下以前的更改,开始全新的适配
This commit is contained in:
parent
ac7272d59a
commit
ea20be6058
@ -1,19 +1,19 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
user: null,
|
user: null,
|
||||||
isAuthenticated: false,
|
isAuthenticated: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setUser(state, user) {
|
setUser(state, user) {
|
||||||
state.user = user;
|
state.user = user;
|
||||||
state.isAuthenticated = true;
|
state.isAuthenticated = true;
|
||||||
},
|
},
|
||||||
clearUser(state) {
|
clearUser(state) {
|
||||||
state.user = null;
|
state.user = null;
|
||||||
state.isAuthenticated = false;
|
state.isAuthenticated = false;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
|||||||
@ -1,21 +1,58 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import {ref} from 'vue';
|
||||||
import { ElInput, ElButton, ElForm, ElFormItem, ElMessage } from 'element-plus';
|
import {ElButton, ElForm, ElFormItem, ElInput, ElMessage} from 'element-plus';
|
||||||
import 'element-plus/dist/index.css';
|
import 'element-plus/dist/index.css';
|
||||||
|
import axios from 'axios';
|
||||||
|
import {useRouter} from 'vue-router';
|
||||||
|
|
||||||
const companyName = ref('');
|
const companyName = ref('');
|
||||||
const contactInfo = ref('');
|
const contactInfo = ref('');
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
const verificationCode = ref('');
|
const verificationCode = ref('');
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const handleRegister = () => {
|
const handleRegister = async () => {
|
||||||
console.log('Registering with', { companyName: companyName.value, contactInfo: contactInfo.value, password: password.value, verificationCode: verificationCode.value });
|
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('验证码已发送');
|
ElMessage.success('验证码已发送');
|
||||||
// 处理发送验证码逻辑
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -26,15 +63,15 @@ const sendVerificationCode = () => {
|
|||||||
<ElForm @submit.prevent="handleRegister">
|
<ElForm @submit.prevent="handleRegister">
|
||||||
<ElFormItem>
|
<ElFormItem>
|
||||||
<label for="companyName">企业名称</label>
|
<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>
|
||||||
<ElFormItem>
|
<ElFormItem>
|
||||||
<label for="contactInfo">企业联系方式</label>
|
<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>
|
||||||
<ElFormItem>
|
<ElFormItem>
|
||||||
<label for="password">密码</label>
|
<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>
|
||||||
<ElFormItem>
|
<ElFormItem>
|
||||||
<label for="verificationCode">验证码</label>
|
<label for="verificationCode">验证码</label>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user