// 鍟嗗煄鍏叡
window.is_login=M['user_name']!=''?true:false,
$topcart=$("#topcart-body");
$(function(){
// 鍙充笂瑙掕喘鐗╄溅
if($topcart.length){
loadTopcart();
// 鍒犻櫎鍟嗗搧
$topcart.on('click','.topcart-remove',function(e){
e.preventDefault();
$(this).parents('.list-group-item').append('
'+METLANG.app_shop_emptycart+'
';
$('.dropdown-menu-footer').hide();
}else{
$('.dropdown-menu-footer').show();
topcartTotal(json);
}
$('.topcart-goodnum').html(num).removeAttr('hidden');
if(d&&!num || !d) $topcart.html(html);
},d);
}
// 璐墿杞︿环鏍
function topcartTotal(json){
$.ajax({
url: totalurl,
type: "GET",
cache: false,
dataType: "jsonp",
success: function(data) {
if(data.message == 'ok'){
$('.topcart-total').html(data.price.goods.total_str);
}
}
});
}
$.extend({
// 璐墿杞︽暟鎹
loadCartJson:function(func,d){
$.ajax({
url: jsonurl,
type: 'GET',
dataType:'json',
success: function(json) {
func(json);
}
});
}
});
// ajax璇锋眰杩斿洖鍚庨€氱敤澶勭悊
function metShopAjaxFun(result,false_fun,true_fun){
if(result.error){
alertify.error(result.error);
if(typeof false_fun =='function') false_fun();
}else if(result.success){
alertify.success(result.success);
if(typeof true_fun =='function'){
true_fun();
}else{
setTimeout(function(){
location.reload();
},500)
}
}
}