优化右侧弹出购物车 Ui 等交互

This commit is contained in:
pushuo 2022-11-07 16:12:49 +08:00 committed by Edward Yang
parent d766dfbe36
commit 3e6d1db82a
11 changed files with 46 additions and 30 deletions

View File

@ -110,6 +110,7 @@ class CartController extends Controller
$data['html'] = view('cart/mini', $reloadData)->render(); $data['html'] = view('cart/mini', $reloadData)->render();
$data['quantity'] = $reloadData['quantity']; $data['quantity'] = $reloadData['quantity'];
$data['quantity_all'] = $reloadData['quantity_all'];
return json_success(trans('common.success'), $data); return json_success(trans('common.success'), $data);
} }

View File

@ -137,25 +137,24 @@ class CartService
* 获取购物车相关数据 * 获取购物车相关数据
* *
* @param array $carts * @param array $carts
* @param bool $showAll
* @return array * @return array
*/ */
public static function reloadData(array $carts = [], bool $showAll = false): array public static function reloadData(array $carts = []): array
{ {
if (empty($carts)) { if (empty($carts)) {
$carts = CartService::list(current_customer()); $carts = CartService::list(current_customer());
} }
$cartList = collect($carts); $cartList = collect($carts)->where('selected', 1);
if (!$showAll) {
$cartList = collect($carts)->where('selected', 1);
}
$quantity = $cartList->sum('quantity'); $quantity = $cartList->sum('quantity');
$quantityAll = collect($carts)->sum('quantity');
$amount = $cartList->sum('subtotal'); $amount = $cartList->sum('subtotal');
$data = [ $data = [
'carts' => $carts, 'carts' => $carts,
'quantity' => $quantity, 'quantity' => $quantity,
'quantity_all' => $quantityAll,
'amount' => $amount, 'amount' => $amount,
'amount_format' => currency_format($amount), 'amount_format' => currency_format($amount),
]; ];

View File

@ -77,10 +77,21 @@ footer {
} }
.footer-bottom { .footer-bottom {
height: 60px;
display: flex; display: flex;
align-items: center; align-items: center;
background: #EFEFF4; background: #EFEFF4;
color: #666; color: #666;
@media (min-width:768px) {
height: 60px;
}
@media (max-width:768px) {
padding: 10px 0;
}
.right-img {
max-height: 42px;
}
} }
} }

View File

@ -106,6 +106,10 @@ body[class^="page-account-"] {
padding-bottom: 10px; padding-bottom: 10px;
margin-bottom: 2rem; margin-bottom: 2rem;
@media (max-width: 992px) {
font-size: 1rem;
}
&:after { &:after {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
@ -275,4 +279,16 @@ body[class^="page-account-"] {
table.table thead th, .fw-bold, h1,h2,h3, h4, h5, h6, b, strong, .card .card-header { table.table thead th, .fw-bold, h1,h2,h3, h4, h5, h6, b, strong, .card .card-header {
font-family: 'Poppins-Medium', sans-serif; font-family: 'Poppins-Medium', sans-serif;
}
.text-size-min {
font-size: 12px;
}
.text-truncate-2 {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
} }

View File

@ -274,7 +274,6 @@ header {
padding: 1rem 0; padding: 1rem 0;
border-top: 1px solid #eee; border-top: 1px solid #eee;
.left { .left {
width: 80px; width: 80px;
flex: 0 0 80px; flex: 0 0 80px;
@ -288,14 +287,6 @@ header {
} }
.right { .right {
.name {
overflow: hidden;
text-overflow:ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.price { .price {
input { input {
margin-left: 10px; margin-left: 10px;

View File

@ -3,7 +3,7 @@
* @link https://beikeshop.com * @link https://beikeshop.com
* @Author pu shuo <pushuo@guangda.work> * @Author pu shuo <pushuo@guangda.work>
* @Date 2022-09-09 19:16:39 * @Date 2022-09-09 19:16:39
* @LastEditTime 2022-09-28 17:23:48 * @LastEditTime 2022-11-07 09:29:34
*/ */
export default { export default {
@ -15,10 +15,10 @@ export default {
$(document).ready(() => { $(document).ready(() => {
$http.get('carts/mini', null, {hload: true}).then((res) => { $http.get('carts/mini', null, {hload: true}).then((res) => {
$('#offcanvas-right-cart').html(res.data.html); $('#offcanvas-right-cart').html(res.data.html);
if (!res.data.quantity) { if (!res.data.quantity_all) {
$('.cart-badge-quantity').hide(); $('.cart-badge-quantity').hide();
} else { } else {
$('.cart-badge-quantity').show().html(res.data.quantity > 99 ? '99+' : res.data.quantity); $('.cart-badge-quantity').show().html(res.data.quantity_all > 99 ? '99+' : res.data.quantity_all);
} }
}) })
}) })

View File

@ -12,7 +12,7 @@
return [ return [
'index' => 'Steps', 'index' => 'Steps',
'cart' => 'Cart', 'cart' => 'Cart',
'checkout' => 'Checkouts', 'checkout' => 'Checkout',
'submitted_successfully' => 'Submitted Successfully', 'submitted_successfully' => 'Placed Order',
'payment' => 'Payment', 'payment' => 'Payment',
]; ];

View File

@ -48,8 +48,8 @@
</div> </div>
</td> </td>
<td> <td>
<div class="name mb-1 fw-bold" v-text="product.name"></div> <div class="name text-truncate-2 mb-1 fw-bold" v-text="product.name"></div>
<div class="attr text-muted">@{{ product.variant_labels }}</div> <div class="text-size-min text-muted mb-1">@{{ product.variant_labels }}</div>
<div class="price text-muted">@{{ product.price_format }}</div> <div class="price text-muted">@{{ product.price_format }}</div>
</td> </td>
<td> <td>

View File

@ -2,7 +2,7 @@
<h5 id="offcanvasRightLabel" class="mx-auto mb-0">{{ __('shop/carts.mini') }}</h5> <h5 id="offcanvasRightLabel" class="mx-auto mb-0">{{ __('shop/carts.mini') }}</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button> <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div> </div>
<div class="offcanvas-body"> <div class="offcanvas-body pt-0">
@php $check = 0 @endphp @php $check = 0 @endphp
@if ($carts) @if ($carts)
@ -16,8 +16,8 @@
<div class="product-info d-flex align-items-center"> <div class="product-info d-flex align-items-center">
<div class="left"><a href="{{ shop_route('products.show', $cart['product_id']) }}" class="d-flex justify-content-between align-items-center h-100"><img src="{{ $cart['image'] }}" class="img-fluid"></a></div> <div class="left"><a href="{{ shop_route('products.show', $cart['product_id']) }}" class="d-flex justify-content-between align-items-center h-100"><img src="{{ $cart['image'] }}" class="img-fluid"></a></div>
<div class="right flex-grow-1"> <div class="right flex-grow-1">
<a href="{{ shop_route('products.show', $cart['product_id']) }}" class="name fs-sm fw-bold mb-2 text-dark" title="{{ $cart['name'] }}">{{ $cart['name'] }}</a> <a href="{{ shop_route('products.show', $cart['product_id']) }}" class="name fs-sm fw-bold mb-2 text-dark text-truncate-2" title="{{ $cart['name'] }}">{{ $cart['name'] }}</a>
<div class="attr text-muted">{{ $cart['variant_labels'] }}</div> <div class="text-muted mb-1 text-size-min">{{ $cart['variant_labels'] }}</div>
<div class="product-bottom d-flex justify-content-between align-items-center"> <div class="product-bottom d-flex justify-content-between align-items-center">
<div class="price d-flex align-items-center"> <div class="price d-flex align-items-center">
{{ $cart['price_format'] }} x {{ $cart['price_format'] }} x

View File

@ -157,9 +157,7 @@
<div class="item" v-for="cart, index in source.carts.carts" :key="index"> <div class="item" v-for="cart, index in source.carts.carts" :key="index">
<div class="image"> <div class="image">
<img :src="cart.image" class="img-fluid"> <img :src="cart.image" class="img-fluid">
<div class="name"> <div class="name text-truncate-2" :title="cart.name" v-text="cart.name"></div>
<span v-text="cart.name"></span>
</div>
</div> </div>
<div class="price text-end"> <div class="price text-end">
<div>@{{ cart.price_format }}</div> <div>@{{ cart.price_format }}</div>

View File

@ -73,7 +73,7 @@
{!! $footer_content['bottom']['copyright'][$locale] ?? '' !!} {!! $footer_content['bottom']['copyright'][$locale] ?? '' !!}
</div> </div>
@if (isset($footer_content['bottom']['image'])) @if (isset($footer_content['bottom']['image']))
<div class="col-auto"> <div class="col-auto right-img">
<img src="{{ image_origin($footer_content['bottom']['image']) }}" class="img-fluid"> <img src="{{ image_origin($footer_content['bottom']['image']) }}" class="img-fluid">
</div> </div>
@endif @endif