登录没问题了,正在写注册,但似乎要用ref之类的东西,这个版本是没有的,之后尝试修改

This commit is contained in:
MiLla 2024-06-25 16:22:01 +08:00
parent 1452208822
commit b613331464
6 changed files with 70 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import HelloWorld from './components/HelloWorld.vue' import HelloWorld from './components/HelloWorld.vue'
import authentication from "./views/authentication.vue"; import authentication from "./views/authentication_login.vue";
</script> </script>
<template> <template>

View File

@ -1,4 +1,4 @@
import authentication from '../views/authentication.vue' import authentication from '../views/authentication_login.vue'
export default [ export default [
{ path: '/login', component: authentication }, { path: '/login', component: authentication },

View File

@ -6,7 +6,7 @@ import meetingManagementRoutes from './meetingManagement'
import newsManagementRoutes from './newsManagement' import newsManagementRoutes from './newsManagement'
import organizationManagementRoutes from './organizationManagement' import organizationManagementRoutes from './organizationManagement'
import userManagementRoutes from './userManagement' import userManagementRoutes from './userManagement'
import authentication from "../views/authentication.vue"; import authentication from "../views/authentication_login.vue";
const routes = [ const routes = [
{ path: '/', component: HelloWorld }, { path: '/', component: HelloWorld },

View File

@ -10,11 +10,22 @@ export default {
return axios.post(url, data) return axios.post(url, data)
.then(response => { .then(response => {
alert(">login方法中<"); alert(">login方法中<");
alert(response.data); alert(response.data.username);
return response.data; return response.data;
}); });
}, },
register(){ register(user){
const url = `${apiUrl}/users/checkLogin`
const data = {
username: username,
password: password
};
return axios.post(url, data)
.then(response => {
alert(">login方法中<");
alert(response.data.username);
return response.data;
});
//跳转逻辑 //跳转逻辑
} }
} }

View File

@ -23,8 +23,9 @@
},methods:{ },methods:{
handleLogin(){ handleLogin(){
authenticationService.login(this.username,this.password).then(res=>{ authenticationService.login(this.username,this.password).then(res=>{
alert(res.username);
alert("login方法调用完毕"); alert("login方法调用完毕");
alert(res.data);
}); });
},handleRegister(){ },handleRegister(){
authenticationService.register(this.username,this.password).then(res=>{ authenticationService.register(this.username,this.password).then(res=>{

View File

@ -0,0 +1,51 @@
<script setup>
import authenticationService from "../services/authenticationService.js";
const username = ref('');
const password = ref('');
const fullname = ref('');
const organization = ref('');
const email = ref('');
const gender = ref('');
const phone = ref('');
const pname = ref('');
const handleBack = () => {
location.href = "/login";
};
const handleRegister = () => {
const user = {
username: username.value,
password: password.value,
fullname: fullname.value,
organization: organization.value,
email: email.value,
gender: gender.value,
phone: phone.value,
pname: pname.value,
};
authenticationService.register(user).then(res => {
alert(res);
});
};
</script>
<template>
<el-input v-model="username" placeholder="pls enter the username"></el-input>
<el-input v-model="password" placeholder="pls enter the password"></el-input>
<el-input v-model="fullname" placeholder="pls enter the fullname"></el-input>
<el-input v-model="organization" placeholder="pls enter the organization"></el-input>
<el-input v-model="email" placeholder="pls enter the email"></el-input>
<el-input v-model="gender" placeholder="pls enter the gender"></el-input>
<el-input v-model="phone" placeholder="pls enter the phone"></el-input>
<el-input v-model="pname" placeholder="pls enter the pname"></el-input>
<el-button type="success" @click="handleBack">BACK</el-button>
<el-button type="success" @click="handleRegister">REGISTER</el-button>
</template>
<style scoped>
</style>