generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
149 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,124 @@ | ||
<template> | ||
<div> | ||
<h1>Оформление кредита</h1> | ||
<p>Форма для оформления кредита.</p> | ||
<div class="loan-application"> | ||
<h1>Оформление кредита</h1> | ||
<p>Заполните информацию в профиле или проверьте ее актуальность!</p> | ||
|
||
<h2>Оформление кредита наличными: {{ loanType }}</h2> <!-- Название кредита, переданное из других компонентов --> | ||
|
||
<label for="loanAmount">Желаемая сумма кредита:</label> | ||
<input | ||
type="number" | ||
id="loanAmount" | ||
v-model="loanAmount" | ||
placeholder="Сумма кредита" | ||
@input="validateLoanAmount" | ||
/> | ||
<div class="amount-range"> | ||
<span>Минимальная сумма: {{ minLoanAmount }}</span> | ||
<span>Максимальная сумма: {{ maxLoanAmount }}</span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'LoanApplication' | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
</style> | ||
|
||
<label for="loanTerm">Срок:</label> | ||
<select id="loanTerm" v-model="loanTerm"> | ||
<option v-for="term in loanTerms" :key="term" :value="term">{{ term }} месяцев</option> | ||
</select> | ||
<div class="term-range"> | ||
<span>Минимальный срок: {{ minLoanTerm }} месяцев</span> | ||
<span>Максимальный срок: {{ maxLoanTerm }} месяцев</span> | ||
</div> | ||
|
||
<label for="coBorrowers">Созаемщики:</label> | ||
<input | ||
type="text" | ||
id="coBorrowers" | ||
v-model="coBorrowers" | ||
placeholder="Контактный телефон 1, контактный телефон 2, ..." | ||
/> | ||
|
||
<label for="collateral">Залог:</label> | ||
<input | ||
type="text" | ||
id="collateral" | ||
v-model="collateral" | ||
placeholder="Сумма залога" | ||
/> | ||
|
||
<div class="application-summary"> | ||
<h3>Заявка на потребительский кредит</h3> | ||
<Button text="Оформить" @click="submitApplication" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Button from '../components/Button.vue'; // Импортируем компонент кнопки | ||
export default { | ||
name: 'LoanApplication', | ||
components: { | ||
Button | ||
}, | ||
data() { | ||
return { | ||
loanType: 'Кредит наличными', // Это значение может быть передано из другого компонента | ||
loanAmount: '', | ||
minLoanAmount: 10000, // Минимальная сумма кредита | ||
maxLoanAmount: 500000, // Максимальная сумма кредита | ||
loanTerm: '', | ||
loanTerms: [6, 12, 24, 36], // Доступные сроки в месяцах | ||
minLoanTerm: 6, // Минимальный срок | ||
maxLoanTerm: 36, // Максимальный срок | ||
coBorrowers: '', | ||
collateral: '' | ||
}; | ||
}, | ||
methods: { | ||
validateLoanAmount() { | ||
// Здесь можно добавить валидацию суммы кредита | ||
}, | ||
submitApplication() { | ||
// Логика отправки заявки на кредит | ||
console.log('Заявка на кредит:', { | ||
loanType: this.loanType, | ||
loanAmount: this.loanAmount, | ||
loanTerm: this.loanTerm, | ||
coBorrowers: this.coBorrowers, | ||
collateral: this.collateral | ||
}); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.loan-application { | ||
display: flex; | ||
flex-direction: column; | ||
max-width: 600px; | ||
margin: auto; | ||
} | ||
label { | ||
margin-top: 10px; | ||
} | ||
input[type='number'], | ||
input[type='text'], | ||
select { | ||
margin-top: 5px; | ||
padding: 10px; | ||
border-radius: 4px; | ||
border: 1px solid #ccc; | ||
} | ||
.amount-range, | ||
.term-range { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
.application-summary { | ||
margin-top: 20px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
<script> | ||
import Button from '../components/Button.vue'; | ||
import axios from 'axios'; | ||
export default { | ||
components: { | ||
|
@@ -28,13 +29,29 @@ export default { | |
}; | ||
}, | ||
methods: { | ||
submitForm() { | ||
if (this.email === '[email protected]' && this.password === '123') { | ||
localStorage.setItem('authToken', true); | ||
this.$router.push('/'); | ||
} | ||
else { | ||
alert('Неверный email или пароль'); | ||
async submitForm() { | ||
try { | ||
// поменять '/api/login' на нужный | ||
const response = await axios.post('/api/login', { | ||
email: this.email, | ||
password: this.password | ||
}); | ||
if (response.data.token) { | ||
localStorage.setItem('authToken', response.data.token); | ||
this.$router.push('/'); | ||
} | ||
else { | ||
alert('Неверный email или пароль'); | ||
} | ||
} catch (error) { | ||
// надо чтоб на бэке кинули ошибку | ||
if (error.response && error.response.status === 401) { | ||
alert('Неверный email или пароль'); | ||
} | ||
else { | ||
alert('Произошла ошибка. Пожалуйста, попробуйте позже.'); | ||
} | ||
} | ||
} | ||
} | ||
|