右侧快捷导航新增购物车
parent
08a5eb3fd3
commit
e0222e2bef
|
|
@ -11,6 +11,22 @@
|
|||
|
||||
// 应用公共文件
|
||||
|
||||
/**
|
||||
* 金额格式化
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2019-02-20
|
||||
* @desc description
|
||||
* @param [float] $value [金额]
|
||||
* @param [int] $decimals [保留的位数]
|
||||
* @param [string] $dec_point [保留小数分隔符]
|
||||
*/
|
||||
function PriceNumberFormat($value, $decimals = 2, $dec_point = '.')
|
||||
{
|
||||
return number_format($value, $decimals, $dec_point, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* json带格式输出
|
||||
* @author Devil
|
||||
|
|
@ -1215,6 +1231,32 @@ function ParamsChecked($data, $params)
|
|||
return $v['error_msg'];
|
||||
}
|
||||
break;
|
||||
|
||||
// 最小
|
||||
case 'min' :
|
||||
if (!isset($v['checked_data']))
|
||||
{
|
||||
return '验证最小值未定义';
|
||||
}
|
||||
$fun = $v['checked_data'];
|
||||
if($data[$v['key_name']] < $v['checked_data'])
|
||||
{
|
||||
return $v['error_msg'];
|
||||
}
|
||||
break;
|
||||
|
||||
// 最大
|
||||
case 'max' :
|
||||
if (!isset($v['checked_data']))
|
||||
{
|
||||
return '验证最大值未定义';
|
||||
}
|
||||
$fun = $v['checked_data'];
|
||||
if($data[$v['key_name']] > $v['checked_data'])
|
||||
{
|
||||
return $v['error_msg'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace app\plugins\commonrightnavigation;
|
|||
|
||||
use think\Controller;
|
||||
use app\service\AnswerService;
|
||||
use app\service\BuyService;
|
||||
|
||||
/**
|
||||
* 右侧快捷导航 - 前端
|
||||
|
|
@ -36,5 +37,31 @@ class Index extends Controller
|
|||
$params['user'] = session('user');
|
||||
return AnswerService::Add($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-02-07T08:21:54+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public function cart($params = [])
|
||||
{
|
||||
// 购物车
|
||||
$cart_list = BuyService::CartList(['user'=>session('user')]);
|
||||
|
||||
// 基础数据
|
||||
$base = [
|
||||
'total_price' => empty($cart_list['data']) ? '0.00' : PriceNumberFormat(array_sum(array_column($cart_list['data'], 'total_price'))),
|
||||
'cart_count' => empty($cart_list['data']) ? 0 : count($cart_list['data']),
|
||||
'ids' => empty($cart_list['data']) ? '' : implode(',', array_column($cart_list['data'], 'id')),
|
||||
];
|
||||
$data = [
|
||||
'cart_list' => $cart_list['data'],
|
||||
'base' => $base,
|
||||
];
|
||||
return DataReturn('操作成功', 0, $data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -33,18 +33,18 @@
|
|||
</a>
|
||||
|
||||
<!-- 购物车 -->
|
||||
<div class="base-nav cart commonrightnavigation-cart">
|
||||
<div class="base-nav cart commonrightnavigation-cart" data-cart-ajax-url="{{:PluginsHomeUrl('commonrightnavigation', 'index', 'cart')}}" data-cart-delete-ajax-url="{{:MyUrl('index/cart/delete')}}">
|
||||
<a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/cart/index')}}{{/if}}" class="nav-a {{$login_event_class}} {{if isset($data['is_goods_page_show_cart']) and $data['is_goods_page_show_cart'] eq 1 and $module_controller_action eq 'indexgoodsindex'}} cart-show{{/if}}">
|
||||
<i class="am-icon-opencart"></i>
|
||||
<div class="cart-text">
|
||||
购物车
|
||||
<div class="cart-count common-cart-total am-badge am-badge-danger">{{if $cart_total > 9}}9+{{else /}}{{$cart_total}}{{/if}}</div>
|
||||
<div class="cart-count common-cart-total {{if $cart_total gt 0}}am-badge am-badge-danger{{/if}}">{{if $cart_total > 9}}9+{{else /}}{{$cart_total}}{{/if}}</div>
|
||||
</div>
|
||||
</a>
|
||||
<div class="mui-mbar-popup am-animation-slide-left cart-content">
|
||||
{{if !empty($cart_list)}}
|
||||
<!-- 商品列表 -->
|
||||
<div class="cart-items">
|
||||
<!-- 商品列表 -->
|
||||
<div class="cart-items" style="display: {{if !empty($cart_list)}}block{{else /}}none{{/if}};">
|
||||
{{if !empty($cart_list)}}
|
||||
<table class="am-table">
|
||||
{{foreach $cart_list as $goods}}
|
||||
<tr id="data-list-{{$goods.id}}" data-id="{{$goods.id}}" data-goods-id="{{$goods.goods_id}}" class="{{if $goods['is_shelves'] neq 1}}am-warning{{/if}} {{if $goods['is_delete_time'] neq 0}}am-danger{{/if}}">
|
||||
|
|
@ -65,48 +65,48 @@
|
|||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="total-price am-hide-sm-only">
|
||||
<td class="total-price">
|
||||
<strong class="total-price-content">¥{{$goods.total_price}}</strong>
|
||||
<span class="cart-number">x{{$goods.stock}}</span>
|
||||
</td>
|
||||
<td class="operation">
|
||||
<a href="javascript:;" class="submit-delete" data-url="{{:MyUrl('index/cart/delete')}}" data-id="{{$goods.id}}" data-view="reload">删除</a>
|
||||
<a href="javascript:;" class="submit-delete" data-url="{{:MyUrl('index/cart/delete')}}" data-id="{{$goods.id}}" data-view="fun" data-value="PluginsCartViewDeleteBack" data-is-confirm="0">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</table>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<!-- 导航 -->
|
||||
<div class="cart-nav">
|
||||
<form action="{{:MyUrl('index/buy/index')}}" method="post">
|
||||
<span class="selected-tips">共 <strong>{{$base.cart_count}}</strong> 种商品</span>
|
||||
<span class="total-price-tips">共计:</span>
|
||||
<strong class="nav-total-price">¥{{$base.total_price}}</strong>
|
||||
<input type="hidden" name="ids" value="{{$base.ids}}" />
|
||||
<input type="hidden" name="buy_type" value="cart" />
|
||||
<button type="submit" class="am-btn am-btn-primary separate-submit am-fr">结算</button>
|
||||
</form>
|
||||
<!-- 导航 -->
|
||||
<div class="cart-nav" style="display: {{if !empty($cart_list)}}block{{else /}}none{{/if}};">
|
||||
<form action="{{:MyUrl('index/buy/index')}}" method="post">
|
||||
<span class="selected-tips">共 <strong>{{$base.cart_count}}</strong> 种商品</span>
|
||||
<span class="total-price-tips">共计:</span>
|
||||
<strong class="nav-total-price">¥{{$base.total_price}}</strong>
|
||||
<input type="hidden" name="ids" value="{{$base.ids}}" />
|
||||
<input type="hidden" name="buy_type" value="cart" />
|
||||
<button type="submit" class="am-btn am-btn-primary separate-submit am-fr">结算</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 空购物车 -->
|
||||
<div class="mixed-tips" style="display: {{if empty($cart_list)}}block{{else /}}none{{/if}};">
|
||||
<i class="am-icon-cart-plus am-fl icon"></i>
|
||||
<div class="mixed-tips-content am-fl">
|
||||
<h1>您的购物车还是空的,您可以</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<span>看看</span>
|
||||
<a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/userfavor/goods')}}{{/if}}" class="{{if empty($user)}}login-event{{/if}}">我的收藏夹</a>
|
||||
</li>
|
||||
<li>
|
||||
<span>看看</span>
|
||||
<a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/order/index')}}{{/if}}" class="{{if empty($user)}}login-event{{/if}}">我的订单</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if empty($cart_list)}}
|
||||
<div class="mixed-tips">
|
||||
<i class="am-icon-cart-plus am-fl icon"></i>
|
||||
<div class="mixed-tips-content am-fl">
|
||||
<h1>您的购物车还是空的,您可以</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<span>看看</span>
|
||||
<a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/userfavor/goods')}}{{/if}}" class="{{if empty($user)}}login-event{{/if}}">我的收藏夹</a>
|
||||
</li>
|
||||
<li>
|
||||
<span>看看</span>
|
||||
<a href="{{if empty($user)}}javascript:;{{else /}}{{:MyUrl('index/order/index')}}{{/if}}" class="{{if empty($user)}}login-event{{/if}}">我的订单</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -178,4 +178,33 @@
|
|||
<div class="mui-mbar-arr mui-mbar-tab-tip-arr">◆</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// 返回处理
|
||||
function PluginsCartViewDeleteBack(e)
|
||||
{
|
||||
if(e.code == 0)
|
||||
{
|
||||
$.AMUI.progress.done();
|
||||
Prompt(e.msg, 'success');
|
||||
$('#data-list-'+e.data_id).remove();
|
||||
HomeCartNumberTotalUpdate(parseInt(e.data));
|
||||
|
||||
// 为空的时候处理
|
||||
if(e.data <= 0)
|
||||
{
|
||||
var $this = $('.commonrightnavigation-cart');
|
||||
$this.find('.mixed-tips').show();
|
||||
$this.find('.cart-nav').hide();
|
||||
$this.find('.cart-items').hide();
|
||||
$this.find('.cart-nav .selected-tips strong').text(0);
|
||||
$this.find('.cart-nav .nav-total-price').text('¥0.00');
|
||||
$this.find('.cart-nav input[name="ids"]').val('');
|
||||
}
|
||||
} else {
|
||||
$.AMUI.progress.done();
|
||||
Prompt(e.msg);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -47,6 +47,12 @@ class BuyService
|
|||
'key_name' => 'stock',
|
||||
'error_msg' => '购买数量有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'min',
|
||||
'key_name' => 'stock',
|
||||
'checked_data' => 1,
|
||||
'error_msg' => '购买数量有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
|
|
@ -275,6 +281,12 @@ class BuyService
|
|||
'key_name' => 'stock',
|
||||
'error_msg' => '购买数量有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'min',
|
||||
'key_name' => 'stock',
|
||||
'checked_data' => 1,
|
||||
'error_msg' => '购买数量有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
|
|
@ -322,6 +334,12 @@ class BuyService
|
|||
'key_name' => 'stock',
|
||||
'error_msg' => '购买数量有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'min',
|
||||
'key_name' => 'stock',
|
||||
'checked_data' => 1,
|
||||
'error_msg' => '购买数量有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'goods_id',
|
||||
|
|
|
|||
|
|
@ -785,97 +785,118 @@ function DataDelete(e)
|
|||
var url = e.data('url');
|
||||
var view = e.data('view') || 'delete';
|
||||
var value = e.data('value') || null;
|
||||
var title = e.data('title') || '温馨提示';
|
||||
var msg = e.data('msg') || '删除后不可恢复、确认操作吗?';
|
||||
var ext_delete_tag = e.data('ext-delete-tag') || null;
|
||||
|
||||
AMUI.dialog.confirm({
|
||||
title: title,
|
||||
content: msg,
|
||||
onConfirm: function(options)
|
||||
if((id || null) == null || (url || null) == null)
|
||||
{
|
||||
Prompt('参数配置有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 请求删除数据
|
||||
$.ajax({
|
||||
url:url,
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:10000,
|
||||
data:{"id":id},
|
||||
success:function(result)
|
||||
{
|
||||
if((id || null) == null || (url || null) == null)
|
||||
if(result.code == 0)
|
||||
{
|
||||
Prompt('参数配置有误');
|
||||
} else {
|
||||
// 请求删除数据
|
||||
$.ajax({
|
||||
url:url,
|
||||
type:'POST',
|
||||
dataType:"json",
|
||||
timeout:10000,
|
||||
data:{"id":id},
|
||||
success:function(result)
|
||||
{
|
||||
if(result.code == 0)
|
||||
Prompt(result.msg, 'success');
|
||||
|
||||
switch(view)
|
||||
{
|
||||
// 成功则删除数据列表
|
||||
case 'delete' :
|
||||
Prompt(result.msg, 'success');
|
||||
$('#data-list-'+id).remove();
|
||||
if(ext_delete_tag != null)
|
||||
{
|
||||
Prompt(result.msg, 'success');
|
||||
|
||||
switch(view)
|
||||
{
|
||||
// 成功则删除数据列表
|
||||
case 'delete' :
|
||||
Prompt(result.msg, 'success');
|
||||
$('#data-list-'+id).remove();
|
||||
if(ext_delete_tag != null)
|
||||
{
|
||||
$(ext_delete_tag).remove();
|
||||
}
|
||||
break;
|
||||
|
||||
// 刷新
|
||||
case 'reload' :
|
||||
Prompt(result.msg, 'success');
|
||||
setTimeout(function()
|
||||
{
|
||||
window.location.reload();
|
||||
}, 1500);
|
||||
break;
|
||||
|
||||
// 回调函数
|
||||
case 'fun' :
|
||||
if(IsExitsFunction(value))
|
||||
{
|
||||
result['data_id'] = id;
|
||||
window[value](result);
|
||||
} else {
|
||||
Prompt('['+value+']配置方法未定义');
|
||||
}
|
||||
break;
|
||||
|
||||
// 跳转
|
||||
case 'jump' :
|
||||
Prompt(result.msg, 'success');
|
||||
if(value != null)
|
||||
{
|
||||
setTimeout(function()
|
||||
{
|
||||
window.location.href = value;
|
||||
}, 1500);
|
||||
}
|
||||
break;
|
||||
|
||||
// 默认提示成功
|
||||
default :
|
||||
Prompt(result.msg, 'success');
|
||||
}
|
||||
// 成功则删除数据列表
|
||||
$('#data-list-'+id).remove();
|
||||
} else {
|
||||
Prompt(result.msg);
|
||||
$(ext_delete_tag).remove();
|
||||
}
|
||||
},
|
||||
error:function(xhr, type)
|
||||
{
|
||||
Prompt('网络异常出错');
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
// 刷新
|
||||
case 'reload' :
|
||||
Prompt(result.msg, 'success');
|
||||
setTimeout(function()
|
||||
{
|
||||
window.location.reload();
|
||||
}, 1500);
|
||||
break;
|
||||
|
||||
// 回调函数
|
||||
case 'fun' :
|
||||
if(IsExitsFunction(value))
|
||||
{
|
||||
result['data_id'] = id;
|
||||
window[value](result);
|
||||
} else {
|
||||
Prompt('['+value+']配置方法未定义');
|
||||
}
|
||||
break;
|
||||
|
||||
// 跳转
|
||||
case 'jump' :
|
||||
Prompt(result.msg, 'success');
|
||||
if(value != null)
|
||||
{
|
||||
setTimeout(function()
|
||||
{
|
||||
window.location.href = value;
|
||||
}, 1500);
|
||||
}
|
||||
break;
|
||||
|
||||
// 默认提示成功
|
||||
default :
|
||||
Prompt(result.msg, 'success');
|
||||
}
|
||||
// 成功则删除数据列表
|
||||
$('#data-list-'+id).remove();
|
||||
} else {
|
||||
Prompt(result.msg);
|
||||
}
|
||||
},
|
||||
onCancel: function(){}
|
||||
error:function(xhr, type)
|
||||
{
|
||||
Prompt('网络异常出错');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* [ConfirmDataDelete 数据删除]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2018-09-24T08:24:58+0800
|
||||
* @param {[object]} e [当前元素对象]
|
||||
*/
|
||||
function ConfirmDataDelete(e)
|
||||
{
|
||||
var title = e.data('title') || '温馨提示';
|
||||
var msg = e.data('msg') || '删除后不可恢复、确认操作吗?';
|
||||
var is_confirm = (e.data('is-confirm') == undefined || e.data('is-confirm') == 1) ? 1 : 0;
|
||||
|
||||
if(is_confirm == 1)
|
||||
{
|
||||
AMUI.dialog.confirm({
|
||||
title: title,
|
||||
content: msg,
|
||||
onConfirm: function(options)
|
||||
{
|
||||
DataDelete(e);
|
||||
},
|
||||
onCancel: function(){}
|
||||
});
|
||||
} else {
|
||||
DataDelete(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [ConfirmNetworkAjax 确认网络请求]
|
||||
* @author Devil
|
||||
|
|
@ -987,7 +1008,7 @@ $(function()
|
|||
*/
|
||||
$(document).on('click', '.submit-delete', function()
|
||||
{
|
||||
DataDelete($(this));
|
||||
ConfirmDataDelete($(this));
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ $(function()
|
|||
// 阻止事件冒泡
|
||||
$('.address-submit-delete').on('click', function(e)
|
||||
{
|
||||
DataDelete($(this));
|
||||
ConfirmDataDelete($(this));
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ function CartAdd(e)
|
|||
{
|
||||
// 参数
|
||||
var type = e.attr('data-type');
|
||||
var stock = $('#text_box').val();
|
||||
if((stock || 0) <= 0)
|
||||
var stock = $('#text_box').val() || 0;
|
||||
if(stock <= 0 || stock < 1)
|
||||
{
|
||||
PromptCenter('购买数量有误');
|
||||
return false;
|
||||
|
|
@ -491,6 +491,26 @@ $(function() {
|
|||
$('.goods-video-submit-start').removeClass('none');
|
||||
});
|
||||
|
||||
//获得文本框对象
|
||||
var t = $('#text_box');
|
||||
|
||||
//数量增加操作
|
||||
$('#add').on('click', function() {
|
||||
var stock = parseInt($('.stock-tips .stock').text());
|
||||
var number = parseInt(t.val());
|
||||
if(number < stock)
|
||||
{
|
||||
t.val(number + 1)
|
||||
} else {
|
||||
Prompt('超出库存数量');
|
||||
}
|
||||
});
|
||||
//数量减少操作
|
||||
$('#min').on('click', function() {
|
||||
var value = parseInt(t.val())-1 || 1;
|
||||
t.val((value <= 1) ? 1 : value);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 浏览器窗口实时事件
|
||||
|
|
@ -503,25 +523,4 @@ $(window).resize(function()
|
|||
} else {
|
||||
poptit_pc_show();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
//获得文本框对象
|
||||
var t = $('#text_box');
|
||||
|
||||
//数量增加操作
|
||||
$('#add').on('click', function() {
|
||||
var stock = parseInt($('.stock-tips .stock').text());
|
||||
var number = parseInt(t.val());
|
||||
if(number < stock)
|
||||
{
|
||||
t.val(number + 1)
|
||||
}
|
||||
});
|
||||
//数量减少操作
|
||||
$('#min').on('click', function() {
|
||||
var value = parseInt(t.val())-1 || 1;
|
||||
t.val(value);
|
||||
})
|
||||
|
||||
});
|
||||
|
|
@ -12,7 +12,7 @@ $(function()
|
|||
// 阻止事件冒泡
|
||||
$('.address-submit-delete').on('click', function(e)
|
||||
{
|
||||
DataDelete($(this));
|
||||
ConfirmDataDelete($(this));
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
position: absolute;
|
||||
right: 35px;
|
||||
display: none;
|
||||
box-shadow: -5px 5px 15px 0px rgba(0,0,0,.4);
|
||||
box-shadow: -5px 0px 15px 5px rgba(0,0,0,.4);
|
||||
}
|
||||
.commonrightnavigation-right-nav .base-nav:hover {
|
||||
background: #d2364c;
|
||||
|
|
@ -188,7 +188,7 @@
|
|||
bottom: 0;
|
||||
width: 400px;
|
||||
min-height: 100px;
|
||||
max-height: 300px;
|
||||
max-height: 360px;
|
||||
background: #fff;
|
||||
color: #666;
|
||||
}
|
||||
|
|
@ -200,6 +200,7 @@
|
|||
.commonrightnavigation-right-nav .favor-content,
|
||||
.commonrightnavigation-right-nav .qrcode-content,
|
||||
.commonrightnavigation-right-nav .cart-content,
|
||||
.commonrightnavigation-right-nav .commonrightnavigation-cart a.nav-a,
|
||||
.commonrightnavigation-right-nav .go-top .mui-mbar-tab-tip,
|
||||
.commonrightnavigation-right-nav .answer-content {
|
||||
display: none;
|
||||
|
|
@ -254,7 +255,7 @@
|
|||
}
|
||||
.commonrightnavigation-cart .cart-content .cart-items {
|
||||
min-height: 60px;
|
||||
max-height: 260px;
|
||||
max-height: 320px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.commonrightnavigation-cart .cart-content .goods-detail img {
|
||||
|
|
@ -337,6 +338,11 @@
|
|||
.commonrightnavigation-cart .cart-content .cart-nav .nav-total-price {
|
||||
margin-right: 5px;
|
||||
}
|
||||
.commonrightnavigation-cart .cart-content .mixed-tips .icon {
|
||||
margin-top: 25px;
|
||||
.commonrightnavigation-cart .cart-content .mixed-tips {
|
||||
margin-bottom: 2%;
|
||||
margin-top: 2%;
|
||||
}
|
||||
|
||||
.commonrightnavigation-cart .cart-content .mixed-tips-content {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
|
@ -10,4 +10,90 @@ $(function()
|
|||
$("#plugins-commonrightnavigation").fadeOut(1000);
|
||||
}
|
||||
});
|
||||
|
||||
// 购物车查询
|
||||
$('.commonrightnavigation-cart').on('mouseenter', function()
|
||||
{
|
||||
// 当前鼠标是否还在元素上,防止鼠标直接进入子级元素导致重复执行事件
|
||||
if($(this).attr('data-is-has-mouse') == 1)
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
$(this).attr('data-is-has-mouse', 1);
|
||||
}
|
||||
|
||||
// url
|
||||
var $this = $(this);
|
||||
var ajax_url = $this.data('cart-ajax-url');
|
||||
var delete_url = $this.data('cart-delete-ajax-url');
|
||||
|
||||
// ajax请求
|
||||
$.ajax({
|
||||
url: ajax_url,
|
||||
type: 'post',
|
||||
dataType: "json",
|
||||
timeout: 10000,
|
||||
data: {},
|
||||
success: function(result)
|
||||
{
|
||||
if(result.code == 0 && result.data.cart_list.length > 0)
|
||||
{
|
||||
var html = '<table class="am-table">';
|
||||
for(var i in result.data.cart_list)
|
||||
{
|
||||
html += '<tr id="data-list-'+result.data.cart_list[i]['id']+'" data-id="'+result.data.cart_list[i]['id']+'" data-goods-id="'+result.data.cart_list[i]['id']+'" class="'+(result.data.cart_list[i]['is_shelves'] != 1 ? 'am-warning' : '')+(result.data.cart_list[i]['is_delete_time'] != 0 ? 'am-danger' : '')+'">';
|
||||
html += '<td class="base">';
|
||||
html += '<div class="goods-detail">';
|
||||
html += '<a href="'+result.data.cart_list[i]['goods_url']+'" target="_blank">';
|
||||
html += '<img src="'+result.data.cart_list[i]['images']+'">';
|
||||
html += '</a>';
|
||||
html += '<div class="goods-base">';
|
||||
html += '<a href="'+result.data.cart_list[i]['goods_url']+'" target="_blank" class="goods-title">'+result.data.cart_list[i]['title']+'</a>';
|
||||
if((result.data.cart_list[i]['spec'] || null) != null)
|
||||
{
|
||||
html += '<ul class="goods-attr">';
|
||||
for(var s in result.data.cart_list[i]['spec'])
|
||||
{
|
||||
html += '<li>'+result.data.cart_list[i]['spec'][s]['type']+':'+result.data.cart_list[i]['spec'][s]['value']+'</li>';
|
||||
}
|
||||
html += '</ul>';
|
||||
}
|
||||
html += '<td class="total-price">';
|
||||
html += '<strong class="total-price-content">¥'+result.data.cart_list[i]['total_price']+'</strong>';
|
||||
html += '<span class="cart-number"> x'+result.data.cart_list[i]['stock']+'</span>';
|
||||
html += '</td>';
|
||||
html += '<td class="operation">';
|
||||
html += '<a href="javascript:;" class="submit-delete" data-url="'+delete_url+'" data-id="'+result.data.cart_list[i]['id']+'" data-view="fun" data-value="PluginsCartViewDeleteBack" data-is-confirm="0">删除</a>';
|
||||
html += '</td>';
|
||||
html += '</tr>';
|
||||
}
|
||||
html += '</table>';
|
||||
$this.find('.cart-items').html(html);
|
||||
$this.find('.mixed-tips').hide();
|
||||
$this.find('.cart-nav').show();
|
||||
$this.find('.cart-items').show();
|
||||
$this.find('.cart-nav .selected-tips strong').text(result.data.base.cart_count);
|
||||
$this.find('.cart-nav .nav-total-price').text('¥'+result.data.base.total_price);
|
||||
$this.find('.cart-nav input[name="ids"]').val(result.data.base.ids);
|
||||
HomeCartNumberTotalUpdate(result.data.base.cart_count);
|
||||
} else {
|
||||
$this.find('.mixed-tips').show();
|
||||
$this.find('.cart-nav').hide();
|
||||
$this.find('.cart-items').hide();
|
||||
$this.find('.cart-nav .selected-tips strong').text(0);
|
||||
$this.find('.cart-nav .nav-total-price').text('¥0.00');
|
||||
$this.find('.cart-nav input[name="ids"]').val('');
|
||||
HomeCartNumberTotalUpdate(0);
|
||||
}
|
||||
},
|
||||
error: function(xhr, type)
|
||||
{
|
||||
Prompt('服务器错误');
|
||||
}
|
||||
});
|
||||
}).mouseleave(function()
|
||||
{
|
||||
// 鼠标离开元素标记
|
||||
$(this).attr('data-is-has-mouse', 0);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue