Compare commits
2 Commits
bdc40dfbdc
...
816de5f5ac
| Author | SHA1 | Date |
|---|---|---|
|
|
816de5f5ac | |
|
|
8d0f8f2147 |
|
|
@ -32,12 +32,11 @@ class Main extends Component
|
|||
]);
|
||||
|
||||
$response = (new \App\Http\Controllers\MobileApiController)->getAvailableMarksList($request);
|
||||
|
||||
$this->params['cars'] = collect($response->getData(true))->filter(function ($item) {
|
||||
return !empty($item['tariffs']);
|
||||
})->values();
|
||||
|
||||
// dd($class_filters, $started_at, $ended_at, $bodywork_filters);
|
||||
|
||||
// $response = Http::get('https://cvm10.a7.kz/api/mobile/getAvailableMarksList', [
|
||||
// 'started_at' => $started_at ?? Carbon::now()->toDateString(),
|
||||
// 'ended_at' => $ended_at ?? Carbon::now()->addDays(3)->toDateString(),
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@
|
|||
<div class="row custom-row w-100">
|
||||
@php $carsValues = array_values($cars->toArray()); @endphp
|
||||
@foreach($carsValues as $car)
|
||||
{{-- @dump($car)--}}
|
||||
<div class="col-12 col-md-6 mb-4">
|
||||
<div class="car-card flex-grow-1">
|
||||
<img class="img-fluid" src="{{ $car['photo'] ?? asset('img/default.png') }}" alt="Car Image">
|
||||
|
|
@ -129,6 +130,9 @@
|
|||
<small>Базовая ставка</small>
|
||||
@php
|
||||
$tariffWithMin1 = collect($car['tariffs'])->firstWhere('min', 1);
|
||||
$tariffWithMin3 = collect($car['tariffs'])->firstWhere('min', 3);
|
||||
$tariffWithMin6 = collect($car['tariffs'])->firstWhere('min', 6);
|
||||
$tariffWithMin15 = collect($car['tariffs'])->firstWhere('min', 15);
|
||||
@endphp
|
||||
<p class="m-0">
|
||||
@if($tariffWithMin1)
|
||||
|
|
@ -139,13 +143,18 @@
|
|||
<a href="#" class="btn btn-primary open-rent-modal"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#rentModal"
|
||||
data-car='@json($car)'
|
||||
data-photo="{{ $car['photo'] ?? asset('img/default.png') }}"
|
||||
data-brand="{{ $car['brand'] }}"
|
||||
data-mark="{{ $car['mark'] }}"
|
||||
data-year="{{ $car['year'] }}"
|
||||
data-fuel="{{ $car['fuel_type'] }}"
|
||||
data-people="{{ $car['people'] }}"
|
||||
data-id="{{ $car['id'] ?? '' }}">
|
||||
{{-- data-brand="{{ $car['brand'] }}"--}}
|
||||
{{-- data-mark="{{ $car['mark'] }}"--}}
|
||||
{{-- data-year="{{ $car['year'] }}"--}}
|
||||
{{-- data-fuel="{{ $car['fuel_type'] }}"--}}
|
||||
{{-- data-people="{{ $car['people'] }}"--}}
|
||||
{{-- data-tariffWithMin1 ="{{ $tariffWithMin1['price'] ?? '' }}"--}}
|
||||
{{-- data-tariffWithMin3="{{ $tariffWithMin3['price'] ?? '' }}"--}}
|
||||
{{-- data-tariffWithMin6="{{ $tariffWithMin6['price'] ?? '' }}"--}}
|
||||
{{-- data-tariffWithMin15="{{ $tariffWithMin15['price'] ?? '' }}"--}}
|
||||
>
|
||||
@lang('Арендовать')
|
||||
</a>
|
||||
|
||||
|
|
@ -196,11 +205,11 @@
|
|||
<div class="popup-block">
|
||||
<p>@lang('Базовая суточная ставка на аренду данного автомобиля уменьшается в зависимости от срока аренды')</p>
|
||||
<ul>
|
||||
<li><b>16-30 дня:</b> 13000 ₸</li>
|
||||
<li><b>3-5 дня:</b> 16000 ₸</li>
|
||||
<li><b>1-2 дня:</b> 18000 ₸</li>
|
||||
<li><b>6-15 дня:</b> 14500 ₸</li>
|
||||
<li><b>30+ дня:</b> 7800 ₸</li>
|
||||
<li><b>1-2 дня:</b><span id="tariffWithMin1"></span></li>
|
||||
<li><b>3-5 дней:</b><span id="tariffWithMin3"></span></li>
|
||||
<li><b>6-15 дней:</b><span id="tariffWithMin6"></span></li>
|
||||
<li><b>16-30 дней:</b><span id="tariffWithMin15"></span></li>
|
||||
<li><b>30+ дней:</b><span id="tariffWithMin30"></span></li>
|
||||
</ul>
|
||||
<p>@lang('Расчет итоговой суммы к оплате рассчитывается (кол-во дней * базовую ставку)')</p>
|
||||
</div>
|
||||
|
|
@ -251,26 +260,26 @@
|
|||
<div class="title-small mb-3">Базовая ставка</div>
|
||||
<div class="li-bl">
|
||||
<div class="li-sp">Без скидки</div>
|
||||
<div class="li-sp" id="base-without">32000 ₸</div>
|
||||
<div class="li-sp" id="base-without"></div>
|
||||
</div>
|
||||
<div class="li-bl">
|
||||
<div class="li-sp">Со скидки</div>
|
||||
<div class="li-sp" id="base-with">25 000 ₸</div>
|
||||
<div class="li-sp">Со скидкой</div>
|
||||
<div class="li-sp" id="base-with"></div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="title-small mb-3">Общая цена</div>
|
||||
<div class="li-bl">
|
||||
<div class="li-sp">Аренда без скидки</div>
|
||||
<div class="li-sp" id="summ-without">224 000 ₸</div>
|
||||
<div class="li-sp" id="summ-without"></div>
|
||||
</div>
|
||||
<div class="li-bl">
|
||||
<div class="li-sp">Аренда со скидки</div>
|
||||
<div class="li-sp" id="sunn-with">175 000 ₸</div>
|
||||
<div class="li-sp">Аренда со скидкой</div>
|
||||
<div class="li-sp" id="sunn-with"></div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="li-bl">
|
||||
<div class="title">Итого</div>
|
||||
<div class="title" id="total">175 000 ₸</div>
|
||||
<div class="title" id="total"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -308,6 +317,7 @@
|
|||
const endedAtPicker = new AirDatepicker('#ended_at', datepickerConfig);
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const toggleBtn = document.getElementById('toggleFilterBtn');
|
||||
const filterCard = document.getElementById('filterCard');
|
||||
|
||||
|
|
@ -334,7 +344,34 @@
|
|||
|
||||
localStorage.setItem('filterOpened', isExpanded);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
document.querySelectorAll('.open-rent-modal').forEach(button => {
|
||||
button.addEventListener('click', function () {
|
||||
const car = JSON.parse(this.getAttribute('data-car'));
|
||||
modal.setAttribute('data-car', JSON.stringify(car));
|
||||
document.getElementById('modalCarImage').src = this.getAttribute('data-photo');
|
||||
document.getElementById('modalCarTitle').innerText = `${car.brand} ${car.mark} - ${car.year}`;
|
||||
document.getElementById('modalFuel').innerHTML = ` ${car.fuel_type}`;
|
||||
document.getElementById('modalPeople').innerHTML = ` ${car.people} мест`;
|
||||
document.getElementById('mark_id').value = car.id;
|
||||
|
||||
const tariff1 = car.tariffs.find(t => t.min === 1)?.price ?? 0;
|
||||
const tariff3 = car.tariffs.find(t => t.min === 3)?.price ?? 0;
|
||||
const tariff6 = car.tariffs.find(t => t.min === 6)?.price ?? 0;
|
||||
const tariff15 = car.tariffs.find(t => t.min === 15)?.price ?? 0;
|
||||
|
||||
document.getElementById('tariffWithMin1').innerHTML = ` ${tariff1} ₸`;
|
||||
document.getElementById('tariffWithMin3').innerHTML = ` ${tariff3} ₸`;
|
||||
document.getElementById('tariffWithMin6').innerHTML = ` ${tariff6} ₸`;
|
||||
document.getElementById('tariffWithMin15').innerHTML = ` ${tariff15} ₸`;
|
||||
document.getElementById('tariffWithMin30').innerHTML = ` ${(tariff1 * 0.4).toFixed(0)} ₸`;
|
||||
|
||||
updateReturnDate();
|
||||
});
|
||||
|
||||
const modal = document.getElementById('rentModal');
|
||||
const pickUpDateInput = document.getElementById('pick-up-date');
|
||||
const returnDateInput = document.getElementById('return-date');
|
||||
const daysInput = document.getElementById('days');
|
||||
|
|
@ -359,32 +396,55 @@
|
|||
const returnDd = String(pickUpDate.getDate()).padStart(2, '0');
|
||||
returnDateInput.value = `${returnYyyy}-${returnMm}-${returnDd}`;
|
||||
}
|
||||
calculateOther(parseInt(daysInput.value));
|
||||
}
|
||||
|
||||
updateReturnDate();
|
||||
|
||||
daysInput.addEventListener('input', updateReturnDate);
|
||||
pickUpDateInput.addEventListener('change', updateReturnDate);
|
||||
|
||||
const modal = document.getElementById('rentModal');
|
||||
function calculateOther(days) {
|
||||
let discountRate = null;
|
||||
if (!days || isNaN(days)) {
|
||||
days = 1;
|
||||
}
|
||||
|
||||
document.querySelectorAll('.open-rent-modal').forEach(button => {
|
||||
button.addEventListener('click', function () {
|
||||
const photo = this.getAttribute('data-photo');
|
||||
const brand = this.getAttribute('data-brand');
|
||||
const mark = this.getAttribute('data-mark');
|
||||
const year = this.getAttribute('data-year');
|
||||
const fuel = this.getAttribute('data-fuel');
|
||||
const people = this.getAttribute('data-people');
|
||||
const id = this.getAttribute('data-id');
|
||||
const car = JSON.parse(modal.getAttribute('data-car'));
|
||||
|
||||
document.getElementById('modalCarImage').src = photo;
|
||||
document.getElementById('modalCarTitle').innerText = `${brand} ${mark} - ${year}`;
|
||||
document.getElementById('modalFuel').innerHTML = ` ${fuel}`;
|
||||
document.getElementById('modalPeople').innerHTML = ` ${people} мест`;
|
||||
document.getElementById('mark_id').value = id;
|
||||
});
|
||||
});
|
||||
const tariffs = car['tariffs'];
|
||||
const baseRate = car.tariffs.find(t => t.min === 1)?.price ?? 0;
|
||||
const matchedRange = tariffs.find(range => days >= range.min && days <= range.max);
|
||||
|
||||
const baseWith = document.getElementById('base-with');
|
||||
const baseWithout = document.getElementById('base-without');
|
||||
const summWithout = document.getElementById('summ-without');
|
||||
const summWith = document.getElementById('sunn-with');
|
||||
const total = document.getElementById('total');
|
||||
|
||||
|
||||
if (matchedRange) {
|
||||
discountRate = matchedRange.price;
|
||||
} else if (days > 30) {
|
||||
discountRate = baseWithout * 0.4;
|
||||
}
|
||||
|
||||
const totalWithoutDiscount = baseRate * days;
|
||||
const totalWithDiscount = discountRate * days;
|
||||
|
||||
baseWith.textContent = formatNumberWithSpaces(discountRate) + ' ₸';
|
||||
baseWithout.textContent = formatNumberWithSpaces(baseRate) + ' ₸';
|
||||
summWithout.textContent = formatNumberWithSpaces(totalWithoutDiscount) + ' ₸';
|
||||
summWith.textContent = formatNumberWithSpaces(totalWithDiscount) + ' ₸';
|
||||
total.textContent = formatNumberWithSpaces(totalWithDiscount) + ' ₸';
|
||||
if (isNaN(days) || days < 1) {
|
||||
summWithout.textContent = 0 + ' ₸';
|
||||
summWith.textContent = 0 + ' ₸';
|
||||
total.textContent = 0 + ' ₸';
|
||||
}
|
||||
}
|
||||
|
||||
function formatNumberWithSpaces(number) {
|
||||
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('input[name="class_filters[]"]').forEach(checkbox => {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -444,6 +444,10 @@ iframe {
|
|||
border-radius: 10px;
|
||||
box-shadow: #0000001a 0 20px 25px -5px, #0000000a 0 10px 10px -5px;
|
||||
transition: .3s all ease;
|
||||
|
||||
span {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue