diff --git a/public/build/beike/shop/default/css/app.css b/public/build/beike/shop/default/css/app.css index 6c20b694..3f2c1876 100644 --- a/public/build/beike/shop/default/css/app.css +++ b/public/build/beike/shop/default/css/app.css @@ -213,12 +213,17 @@ header .header-content .right-btn .nav-link i { border-top: 1px solid #eee; } #offcanvas-right-cart .offcanvas-right-products .product-list .left { - width: 100px; + width: 90px; margin-right: 10px; } #offcanvas-right-cart .offcanvas-right-products .product-list .left img { - max-height: 100px; + max-height: 90px; } +#offcanvas-right-cart .offcanvas-right-products .product-list .right .offcanvas-products-delete { + cursor: pointer; + color: #999; +} + footer { background: #fafafa; margin-top: 5rem; diff --git a/public/build/beike/shop/default/js/app.js b/public/build/beike/shop/default/js/app.js index 54128ff6..eb1d7288 100644 --- a/public/build/beike/shop/default/js/app.js +++ b/public/build/beike/shop/default/js/app.js @@ -2488,7 +2488,36 @@ $(document).ready(function ($) { layer.closeAll('loading'); } }); - $('.quantity-wrap .right i').on('click', function (event) { + $http.get('/carts/mini', null, { + hload: true + }).then(function (res) { + $('.offcanvas-right-cart-amount').html(res.data.amount_format); + + if (res.data.carts.length) { + var html = ''; + res.data.carts.forEach(function (e) { + html += '
'; + html += "
"); + html += '
'; + html += "
".concat(e.name, "
"); + html += '
'; + html += "
".concat(e.price_format, "
"); + html += " \u5220\u9664"); + html += '
'; + html += '
'; + html += '
'; + }); + $('.offcanvas-right-products').html(html); + } + }); + $(document).on('click', '.offcanvas-products-delete', function (event) { + var $this = $(this); + var cartId = $(this).data('id'); + $http["delete"]("/carts/".concat(cartId)).then(function (res) { + $this.parents('.product-list').remove(); + }); + }); + $(document).on('click', '.quantity-wrap .right i', function (event) { event.stopPropagation(); var input = $(this).parent().siblings('input'); diff --git a/resources/beike/shop/default/css/header.scss b/resources/beike/shop/default/css/header.scss index d88a85f8..ca9fadc5 100644 --- a/resources/beike/shop/default/css/header.scss +++ b/resources/beike/shop/default/css/header.scss @@ -81,17 +81,18 @@ header { border-top: 1px solid #eee; .left { - width: 100px; + width: 90px; margin-right: 10px; img { - max-height: 100px; + max-height: 90px; } } .right { - .name { - + .offcanvas-products-delete { + cursor: pointer; + color: #999; } } } diff --git a/resources/beike/shop/default/js/app.js b/resources/beike/shop/default/js/app.js index cebd85fb..b9a52215 100644 --- a/resources/beike/shop/default/js/app.js +++ b/resources/beike/shop/default/js/app.js @@ -8,7 +8,38 @@ $(document).ready(function ($) { complete: function() { layer.closeAll('loading'); }, }); - $('.quantity-wrap .right i').on('click', function(event) { + $http.get('/carts/mini', null, {hload: true}).then((res) => { + $('.offcanvas-right-cart-amount').html(res.data.amount_format); + + if (res.data.carts.length) { + let html = ''; + res.data.carts.forEach(e => { + html += '
'; + html += `
`; + html += '
'; + html += `
${e.name}
`; + html += '
'; + html += `
${e.price_format}
`; + html += ` 删除`; + html += '
'; + html += '
'; + html += '
'; + }) + + $('.offcanvas-right-products').html(html) + } + }) + + $(document).on('click', '.offcanvas-products-delete', function(event) { + const $this = $(this) + const cartId = $(this).data('id') + + $http.delete(`/carts/${cartId}`).then((res) => { + $this.parents('.product-list').remove() + }) + }) + + $(document).on('click', '.quantity-wrap .right i', function(event) { event.stopPropagation(); let input = $(this).parent().siblings('input') diff --git a/themes/default/layout/header.blade.php b/themes/default/layout/header.blade.php index 1b1513e1..62ebe58e 100644 --- a/themes/default/layout/header.blade.php +++ b/themes/default/layout/header.blade.php @@ -1,3 +1,7 @@ +@push('header') + {{-- --}} +@endpush +
@@ -95,7 +99,7 @@
- @for ($i = 0; $i < 20; $i++) +{{-- @for ($i = 0; $i < 20; $i++)
@@ -107,17 +111,17 @@
- @endfor + @endfor --}}
- \ No newline at end of file +