From b5cc1ba786e48681def419a4a63febd523c44636 Mon Sep 17 00:00:00 2001 From: pushuo Date: Sat, 20 May 2023 10:20:53 +0000 Subject: [PATCH] !104 Product Added Quick Preview * Added quick preview --- resources/beike/admin/js/app.js | 5 +- .../component/rich_text_i18n.blade.php | 3 +- resources/beike/shop/default/js/app.js | 18 +---- resources/beike/shop/default/js/common.js | 21 ++++-- resources/beike/shop/default/js/header.js | 31 +++++++- resources/lang/en/common.php | 1 + resources/lang/zh_cn/common.php | 1 + resources/lang/zh_hk/common.php | 1 + themes/default/account/wishlist.blade.php | 33 +++++---- themes/default/cart/mini.blade.php | 72 +++++++++---------- themes/default/design/product.blade.php | 65 ++++++++++------- themes/default/design/slideshow.blade.php | 17 ++++- themes/default/layout/header.blade.php | 10 +-- themes/default/product.blade.php | 49 ++++++++++--- themes/default/shared/product.blade.php | 8 +++ 15 files changed, 218 insertions(+), 117 deletions(-) diff --git a/resources/beike/admin/js/app.js b/resources/beike/admin/js/app.js index bf196a69..bad19ee1 100644 --- a/resources/beike/admin/js/app.js +++ b/resources/beike/admin/js/app.js @@ -3,7 +3,7 @@ * @link https://beikeshop.com * @Author pu shuo * @Date 2022-08-26 18:18:22 - * @LastEditTime 2023-02-08 15:35:25 + * @LastEditTime 2023-05-18 15:33:10 */ import http from "../../../js/http"; @@ -92,7 +92,8 @@ const tinymceInit = () => { toolbar_mode: 'wrap', font_formats: "微软雅黑='Microsoft YaHei';黑体=黑体;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Georgia=georgia,palatino;Helvetica=helvetica;Times New Roman=times new roman,times;Verdana=verdana,geneva", - fontsize_formats: "10px 12px 14px 18px 24px 36px", + fontsize_formats: "10px 12px 14px 18px 24px 36px 48px 56px 72px 96px", + lineheight_formats: "1 1.1 1.2 1.3 1.4 1.5 1.7 2.4 3 4", setup: function(ed) { const height = ed.getElement().dataset.tinymceHeight; // console.log(ed); diff --git a/resources/beike/admin/views/pages/design/builder/component/rich_text_i18n.blade.php b/resources/beike/admin/views/pages/design/builder/component/rich_text_i18n.blade.php index 28b94947..14454d7b 100644 --- a/resources/beike/admin/views/pages/design/builder/component/rich_text_i18n.blade.php +++ b/resources/beike/admin/views/pages/design/builder/component/rich_text_i18n.blade.php @@ -104,7 +104,8 @@ Vue.component('rich-text-i18n', { toolbar_mode: 'wrap', font_formats: "微软雅黑='Microsoft YaHei';黑体=黑体;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Georgia=georgia,palatino;Helvetica=helvetica;Times New Roman=times new roman,times;Verdana=verdana,geneva", - fontsize_formats: "10px 12px 14px 18px 24px 36px", + fontsize_formats: "10px 12px 14px 18px 24px 36px 48px 56px 72px 96px", + lineheight_formats: "1 1.1 1.2 1.3 1.4 1.5 1.7 2.4 3 4", relative_urls : true, // init_instance_callback: function (ed) { // let code = ed.getElement().dataset.code diff --git a/resources/beike/shop/default/js/app.js b/resources/beike/shop/default/js/app.js index 39650e99..9776a8b2 100644 --- a/resources/beike/shop/default/js/app.js +++ b/resources/beike/shop/default/js/app.js @@ -3,7 +3,7 @@ * @link https://beikeshop.com * @Author pu shuo * @Date 2022-08-29 17:32:51 - * @LastEditTime 2023-02-02 11:06:01 + * @LastEditTime 2023-05-18 10:18:09 */ import http from "../../../../js/http"; @@ -19,22 +19,6 @@ import './header' import './bootstrap-validation' $(document).ready(function ($) { - $(document).on('click', '.offcanvas-products-delete', function () { - const id = $(this).data('id'); - - $http.delete(`carts/${id}`).then((res) => { - $(this).parents('.product-list').remove(); - if (!res.data.quantity) { - $('.cart-badge-quantity').hide(); - } else { - $('.cart-badge-quantity').show().html(res.data.quantity > 99 ? '99+' : res.data.quantity); - } - - $('.offcanvas-right-cart-count').text(res.data.quantity); - $('.offcanvas-right-cart-amount').text(res.data.amount_format); - }) - }) - if ($(window).width() > 992 && $('.x-fixed-top').length) { $('.x-fixed-top').scrollToFixed({ zIndex: 999, diff --git a/resources/beike/shop/default/js/common.js b/resources/beike/shop/default/js/common.js index ab2f642e..59302043 100644 --- a/resources/beike/shop/default/js/common.js +++ b/resources/beike/shop/default/js/common.js @@ -3,7 +3,7 @@ * @link https://beikeshop.com * @Author pu shuo * @Date 2022-09-09 19:16:39 - * @LastEditTime 2023-05-17 13:49:44 + * @LastEditTime 2023-05-18 09:02:44 */ export default { @@ -31,7 +31,7 @@ export default { * @param {*} isBuyNow 是否立即购买 * @return {*} 返回Promise */ - addCart({sku_id, quantity = 1, isBuyNow = false}, event) { + addCart({sku_id, quantity = 1, isBuyNow = false}, event, callback) { if (!config.isLogin && !config.guestCheckout) { this.openLogin() return; @@ -46,8 +46,9 @@ export default { $http.post('/carts', {sku_id, quantity, buy_now: isBuyNow}, {hload: !!event}).then((res) => { this.getCarts(); layer.msg(res.message) - if (isBuyNow) { - location.href = 'checkout' + + if (callback) { + callback(res) } }).finally(() => {$btn.html(btnHtml).prop('disabled', false)}) }, @@ -96,6 +97,18 @@ export default { }); }, + productQuickView(id, callback) { + layer.open({ + type: 2, + title: '', + shadeClose: true, + scrollbar: false, + area: ['1000px', '600px'], + skin: 'login-pop-box', + content: `products/${id}?iframe=true` + }); + }, + getQueryString(name, defaultValue) { const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); const r = window.location.search.substr(1).match(reg); diff --git a/resources/beike/shop/default/js/header.js b/resources/beike/shop/default/js/header.js index 3b2d161d..9471686c 100644 --- a/resources/beike/shop/default/js/header.js +++ b/resources/beike/shop/default/js/header.js @@ -3,7 +3,7 @@ * @link https://beikeshop.com * @Author pu shuo * @Date 2022-08-16 18:47:18 - * @LastEditTime 2023-03-16 17:30:20 + * @LastEditTime 2023-05-18 10:27:58 */ $(function () { @@ -22,6 +22,35 @@ $(function () { }); } + // 购物车侧边栏弹出 + $(document).on("click", ".btn-right-cart", function () { + const currentUrl = window.location.pathname; + if (currentUrl == '/checkout' || currentUrl == '/carts') { + return; + } + + const offcanvasRightCart = new bootstrap.Offcanvas('#offcanvas-right-cart') + offcanvasRightCart.show() + }); + + // 侧边栏购物车删除商品 + $(document).on('click', '.offcanvas-products-delete', function () { + const id = $(this).data('id'); + + $http.delete(`carts/${id}`).then((res) => { + $(this).parents('.product-list').remove(); + if (!res.data.quantity) { + $('.cart-badge-quantity').hide(); + $('.empty-cart').removeClass('d-none'); + } else { + $('.cart-badge-quantity').show().html(res.data.quantity > 99 ? '99+' : res.data.quantity); + } + + $('.offcanvas-right-cart-count').text(res.data.quantity); + $('.offcanvas-right-cart-amount').text(res.data.amount_format); + }) + }) + // 响应式下弹窗菜单交互 $(document).on("click", ".mobile-open-menu", function () { const offcanvasMobileMenu = new bootstrap.Offcanvas('#offcanvas-mobile-menu') diff --git a/resources/lang/en/common.php b/resources/lang/en/common.php index 082eedb8..d998e907 100644 --- a/resources/lang/en/common.php +++ b/resources/lang/en/common.php @@ -81,6 +81,7 @@ return [ 'get_more' => 'Get More', 'view_more' => 'View more', 'view_details' => 'Check Details', + 'quick_view' => 'Quick View', 'id' => 'ID', 'created_at' => 'Created At', diff --git a/resources/lang/zh_cn/common.php b/resources/lang/zh_cn/common.php index e976f257..67c38daa 100644 --- a/resources/lang/zh_cn/common.php +++ b/resources/lang/zh_cn/common.php @@ -80,6 +80,7 @@ return [ 'get_more' => '获取更多', 'view_more' => '查看更多', 'view_details' => '查看详情', + 'quick_view' => '快速预览', 'id' => 'ID', 'created_at' => '创建时间', diff --git a/resources/lang/zh_hk/common.php b/resources/lang/zh_hk/common.php index c108631d..4ef90d33 100644 --- a/resources/lang/zh_hk/common.php +++ b/resources/lang/zh_hk/common.php @@ -80,6 +80,7 @@ return [ 'get_more' => '獲取更多', 'view_more' => '查看更多', 'view_details' => '查看詳情', + 'quick_view' => '快速預覽', 'id' => 'ID', 'created_at' => '創建時間', diff --git a/themes/default/account/wishlist.blade.php b/themes/default/account/wishlist.blade.php index 8e0b76c9..e49f2dc7 100644 --- a/themes/default/account/wishlist.blade.php +++ b/themes/default/account/wishlist.blade.php @@ -35,8 +35,9 @@ {{ $item['price'] }}
- {{ __('shop/account.wishlist.check_details') }} +
@@ -60,21 +61,23 @@ @push('add-scripts') @endpush diff --git a/themes/default/cart/mini.blade.php b/themes/default/cart/mini.blade.php index 47c3b3f3..afe16a97 100644 --- a/themes/default/cart/mini.blade.php +++ b/themes/default/cart/mini.blade.php @@ -6,48 +6,48 @@ @php $check = 0 @endphp @if ($carts) -
- @foreach ($carts as $cart) - @if ($cart['selected']) @php $check = $check + 1 @endphp @endif -
-
- -
-
-
-
- {{ $cart['name'] }} -
{{ $cart['variant_labels'] }}
-
-
- {{ $cart['price_format'] }} x - -
- - {{ __('common.delete') }} +
+ @foreach ($carts as $cart) + @if ($cart['selected']) @php $check = $check + 1 @endphp @endif +
+
+ +
+
+
+
+ {{ $cart['name'] }} +
{{ $cart['variant_labels'] }}
+
+
+ {{ $cart['price_format'] }} x +
+ + {{ __('common.delete') }}
- @endforeach -
- @else -
-
-
- -
-
-
{{ __('shop/carts.cart_empty') }}
-

{{ __('shop/carts.go_buy') }}

-
- +
+ @endforeach +
+ @endif + +
+
+
+ +
+
+
{{ __('shop/carts.cart_empty') }}
+

{{ __('shop/carts.go_buy') }}

+
+
- @endif +
@if ($carts) diff --git a/themes/default/design/product.blade.php b/themes/default/design/product.blade.php index 22c1e753..f917dec8 100644 --- a/themes/default/design/product.blade.php +++ b/themes/default/design/product.blade.php @@ -1,3 +1,8 @@ +@push('header') + + +@endpush +
@include('design._partial._module_tool') @@ -37,32 +42,44 @@
\ No newline at end of file diff --git a/themes/default/design/slideshow.blade.php b/themes/default/design/slideshow.blade.php index 95552c52..1908c192 100644 --- a/themes/default/design/slideshow.blade.php +++ b/themes/default/design/slideshow.blade.php @@ -1,3 +1,8 @@ +@push('header') + + +@endpush +
@include('design._partial._module_tool') @@ -18,8 +23,7 @@
\ No newline at end of file diff --git a/themes/default/layout/header.blade.php b/themes/default/layout/header.blade.php index ee6ba922..72d0da75 100644 --- a/themes/default/layout/header.blade.php +++ b/themes/default/layout/header.blade.php @@ -116,11 +116,15 @@ @endhookwrapper @@ -155,9 +159,7 @@
- @if (!equal_route('shop.carts.index')) -
- @endif +
diff --git a/themes/default/product.blade.php b/themes/default/product.blade.php index 847bd084..344072d9 100644 --- a/themes/default/product.blade.php +++ b/themes/default/product.blade.php @@ -11,15 +11,21 @@ @endpush -@section('content') - +@php + $iframeClass = request('iframe') ? 'd-none' : ''; +@endphp -
+@section('content') + @if (!request('iframe')) + + @endif + +
@if(!is_mobile()) -
+
@@ -143,11 +149,14 @@ @hook('product.detail.buy.after')
+ + @if (current_customer() || !request('iframe'))
+ @endif @else
{{ __('product.has_been_inactive') }}
@endif @@ -157,7 +166,7 @@
-
+ - @if ($relations) + @if ($relations && !request('iframe'))
{{ __('admin/product.product_relations') }}
@@ -219,6 +228,7 @@ @push('add-scripts') @endpush diff --git a/themes/default/shared/product.blade.php b/themes/default/shared/product.blade.php index 50d7f3d4..da8f837f 100644 --- a/themes/default/shared/product.blade.php +++ b/themes/default/shared/product.blade.php @@ -11,6 +11,14 @@
@if (!request('style_list') || request('style_list') == 'grid')
+