From 5c9178a71582f65c16c6cbd6193bc193278e11ac Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Mon, 29 Aug 2022 10:47:47 +0800 Subject: [PATCH] =?UTF-8?q?url=E6=9B=BF=E6=8D=A2=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=94=9A=E7=82=B9=EF=BC=8C=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E9=A1=B5=E9=9D=A2=E4=B8=9A=E5=8A=A1=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E8=87=AA=E5=8A=A8=E5=AE=9A=E4=BD=8D=E9=94=9A=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/view/default/buy/index.html | 8 ++++---- public/static/common/js/common.js | 20 +++++++++++++++----- public/static/index/default/js/buy.js | 22 ++++++++++++++-------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/app/index/view/default/buy/index.html b/app/index/view/default/buy/index.html index 9425e1625..69d61b3d9 100755 --- a/app/index/view/default/buy/index.html +++ b/app/index/view/default/buy/index.html @@ -47,7 +47,7 @@ {{if $common_site_type eq 4}} -
+
  • 快递邮寄
  • 自提点取货
  • @@ -57,7 +57,7 @@ {{if isset($base['site_model']) and $base['site_model'] eq 0}} -
    +

    确认收货地址 @@ -118,7 +118,7 @@ {{if isset($base['site_model']) and $base['site_model'] eq 2}} -
    +

    确认自提点地址

    {{if !empty($base['address'])}} @@ -522,7 +522,7 @@ {{if $base['actual_price'] gt 0 and $common_order_is_booking neq 1}} -
    +

    选择支付

    {{if !empty($payment_list)}}
      diff --git a/public/static/common/js/common.js b/public/static/common/js/common.js index c7cfb15db..b51eedda6 100755 --- a/public/static/common/js/common.js +++ b/public/static/common/js/common.js @@ -1508,20 +1508,30 @@ function FullscreenEscEvent() * @param {[string]} field [字段名称] * @param {[string]} value [字段值, null 则去除字段] * @param {[string]} url [自定义url] + * @param {[string]} anchor[锚点、传入空字符串则表示去除已存在的锚点] */ -function UrlFieldReplace(field, value, url) +function UrlFieldReplace(field, value, url = null, anchor = null) { // 当前页面url地址 url = url || window.location.href; // 锚点 - var anchor = ''; - if(url.indexOf('#') >= 0) + if(url.indexOf('#') != -1) { - anchor = url.substr(url.indexOf('#')); - url = url.substr(0, url.indexOf('#')); + var temp_url = url.split('#'); + url = temp_url[0]; + // 未指定锚点则使用url自带的 + if(temp_url.length > 1 && anchor === null) + { + anchor = temp_url[1]; + } + } + if((anchor || null) != null && anchor.indexOf('#') == -1) + { + anchor = '#'+anchor; } + // 是否存在问号参数 if(url.indexOf('?') >= 0) { var str = url.substr(0, url.lastIndexOf('.'+__seo_url_suffix__)); diff --git a/public/static/index/default/js/buy.js b/public/static/index/default/js/buy.js index 72b919e3f..120d411f7 100755 --- a/public/static/index/default/js/buy.js +++ b/public/static/index/default/js/buy.js @@ -17,7 +17,8 @@ $(function() if(store_address_use_status < $('ul.address-list li').length) { store.set(store_use_new_address_status_key, undefined); - window.location.href = UrlFieldReplace('address_id', $('ul.address-list li:first').data('value')); + var anchor = $('.address').attr('id') || ''; + window.location.href = UrlFieldReplace('address_id', $('ul.address-list li:first').data('value'), null, anchor); } } } @@ -34,15 +35,16 @@ $(function() e.stopPropagation(); } } else { - // 底部地址同步 - window.location.href = UrlFieldReplace('address_id', $(this).data('value')); + var anchor = $(this).parents('.address').attr('id') || ''; + window.location.href = UrlFieldReplace('address_id', $(this).data('value'), null, anchor); } }); // 手机模式下选择地址 $('.address').on('click', 'ul.address-list li', function() { - window.location.href = UrlFieldReplace('address_id', $(this).data('value')); + var anchor = $(this).parents('.address').attr('id') || ''; + window.location.href = UrlFieldReplace('address_id', $(this).data('value'), null, anchor); }); // 手机模式下关闭地址选中 @@ -62,11 +64,13 @@ $(function() // 混合列表选择 $('.business-item ul li').on('click', function() { - var field = $(this).parents('.business-item').data('field') || null; + var $parent = $(this).parents('.business-item'); + var field = $parent.data('field') || null; var value = $(this).data('value') || null; if(field != null && value != null) { - window.location.href = UrlFieldReplace(field, value); + var anchor = $parent.attr('id') || ''; + window.location.href = UrlFieldReplace(field, value, null, anchor); } }); @@ -125,7 +129,8 @@ $(function() $extraction_popup = $('#extraction-address-popup'); $extraction_popup.find('.extraction-address-item button').on('click', function() { - window.location.href = UrlFieldReplace('address_id', $(this).data('value')); + var anchor = $(this).parents('.address').attr('id') || ''; + window.location.href = UrlFieldReplace('address_id', $(this).data('value'), null, anchor); }); $('.extraction-default .extraction-address-item').on('click', function(e) { @@ -140,6 +145,7 @@ $(function() { var value = $(this).data('value') || 0; var url = UrlFieldReplace('address_id', null); - window.location.href = UrlFieldReplace('site_model', value, url); + var anchor = $(this).parents('.buy-header-nav').attr('id') || ''; + window.location.href = UrlFieldReplace('site_model', value, url, anchor); }); }); \ No newline at end of file