83 lines
2.3 KiB
Vue
83 lines
2.3 KiB
Vue
|
<template lang="">
|
||
|
<div class='text-center mx-auto'>
|
||
|
<p class='h3 m-3'>Авторизация</p>
|
||
|
<p class='h6 m-3'> Имя:</p>
|
||
|
<textarea v-model='firstName' id="firstNameTF" cols="30" rows="1" style="resize: none;"></textarea>
|
||
|
<p class='h6 m-3' > Фамилия:</p>
|
||
|
<textarea v-model='lastName' id="lastNameTF" cols="30" rows="1" style="resize: none;"></textarea>
|
||
|
<p class='h6 m-3'> Отчество:</p>
|
||
|
<textarea v-model='middleName' id="middleNameTF" cols="30" rows="1" style="resize: none;"></textarea>
|
||
|
|
||
|
<p class='mt-5'>
|
||
|
<button v-on:click="enterButtonClick" type='button' class='btn btn-primary'>Войти</button>
|
||
|
</p>
|
||
|
<p>
|
||
|
<button v-on:click="registerButtonClick" type='button' class='btn btn-success'>Регистрация</button>
|
||
|
</p>
|
||
|
<p>
|
||
|
<button type='button' class='btn btn-light'>Войти как администратор</button>
|
||
|
</p>
|
||
|
</div>
|
||
|
</template>
|
||
|
<script>
|
||
|
import axios from 'axios'
|
||
|
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
firstName: '',
|
||
|
lastName: '',
|
||
|
middleName: '',
|
||
|
abiturId: -1
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
async enterButtonClick() {
|
||
|
var abiturs = await (await axios.get('http://127.0.0.1:8080/api/abitur', )).data
|
||
|
abiturs.forEach(element => {
|
||
|
if (element['first_name'] == this.firstName && element['last_name'] == this.lastName && element['middle_name'] == this.middleName) {
|
||
|
this.abiturId = element['id']
|
||
|
console.log(this.abiturId)
|
||
|
}
|
||
|
});
|
||
|
this.$router.push(
|
||
|
{
|
||
|
name: "AbiturMain",
|
||
|
params: {
|
||
|
abiturId: this.abiturId
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
},
|
||
|
|
||
|
async registerButtonClick() {
|
||
|
let data = JSON.stringify({
|
||
|
"first_name": this.firstName,
|
||
|
"last_name": this.lastName,
|
||
|
"middle_name": this.middleName
|
||
|
});
|
||
|
|
||
|
let config = {
|
||
|
method: 'post',
|
||
|
maxBodyLength: Infinity,
|
||
|
url: 'http://127.0.0.1:8080/api/abitur',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
},
|
||
|
data : data
|
||
|
};
|
||
|
|
||
|
axios.request(config)
|
||
|
.then((response) => {
|
||
|
this.abiturId =response.data['id']
|
||
|
console.log(this.abiturId)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
<style lang="">
|
||
|
|
||
|
</style>
|