url替换方法支持锚点,下单确认页面业务选择自动定位锚点
parent
2cff734c29
commit
5c9178a715
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
<!-- 销售+自提 -->
|
||||
{{if $common_site_type eq 4}}
|
||||
<div data-am-widget="tabs" class="am-tabs am-tabs-d2 buy-header-nav">
|
||||
<div id="buy-items-tabs" data-am-widget="tabs" class="am-tabs am-tabs-d2 buy-header-nav">
|
||||
<ul class="am-tabs-nav am-cf">
|
||||
<li {{if isset($base['site_model']) and $base['site_model'] eq 0}}class="am-active"{{/if}}><a href="javascript:;" data-value="0">快递邮寄</a></li>
|
||||
<li {{if isset($base['site_model']) and $base['site_model'] eq 2}}class="am-active"{{/if}}><a href="javascript:;" data-value="2">自提点取货</a></li>
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
<!-- 快递 - 用户地址 -->
|
||||
{{if isset($base['site_model']) and $base['site_model'] eq 0}}
|
||||
<div class="address user-address-container">
|
||||
<div id="buy-items-address" class="address user-address-container">
|
||||
<div class="control">
|
||||
<h3>
|
||||
确认收货地址
|
||||
|
|
@ -118,7 +118,7 @@
|
|||
|
||||
<!-- 自提点 - 自提地址 -->
|
||||
{{if isset($base['site_model']) and $base['site_model'] eq 2}}
|
||||
<div class="address extraction-address-container">
|
||||
<div id="buy-items-address" class="address extraction-address-container">
|
||||
<div class="control">
|
||||
<h3>确认自提点地址</h3>
|
||||
{{if !empty($base['address'])}}
|
||||
|
|
@ -522,7 +522,7 @@
|
|||
|
||||
<!-- 支付方式 -->
|
||||
{{if $base['actual_price'] gt 0 and $common_order_is_booking neq 1}}
|
||||
<div class="buy-items business-item payment" data-field="payment_id">
|
||||
<div id="buy-items-payment" class="buy-items business-item payment" data-field="payment_id">
|
||||
<h3>选择支付</h3>
|
||||
{{if !empty($payment_list)}}
|
||||
<ul class="payment-list">
|
||||
|
|
|
|||
|
|
@ -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__));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue