
function  decNum(obj,id){
         var cur_num = $(obj).siblings('.ipt').val();
		 if(cur_num==1){
					$(obj).siblings('.ipt').val(1);
				}else{
					cur_num--;
					$(obj).siblings('.ipt').val(cur_num);
					 $.post(dec_url,{id:id},function(data){
				  $('.tNum').text(data.count);
				  $('.tSum').text("¥"+data.total);
				  $('.cart_num').text(data.sum);	
	   });
				}
        
	   
		
     }

	  function  incNum(obj,id){
         var cur_num = $(obj).siblings('.ipt').val();
		       if(cur_num >= 99){
					$(obj).siblings('.ipt').val(99);
				}else{
					cur_num++;
					$(obj).siblings('.ipt').val(cur_num);
				}
        
	    $.post(inc_url,{id:id},function(data){
				  $('.tNum').text(data.count);
				  $('.tSum').text("¥"+data.total);
				  $('.cart_num').text(data.sum);	
	   });
		
     }	
	 
	function cancelCart(obj,sku_id){ 
		      
				$.post(del_url,{id:sku_id},function(data){   
					 if(data.status){ 
						  $('.item'+sku_id).remove();	 
						  $('#item'+sku_id).remove();
						  if(!data.sum){
						    var html='<div class="hide"><div class="pic fl"><img src="'+img_path+'/wdgwc_pic_01.gif"/></div><div class="none_txt fl"><p class="p_01">您的购物车还是空的，赶紧行动吧！您可以：</p><p class="p_02">看看 <a href="javascript:;">我的收藏</a></p><p class="p_03">看看 <a href="javascript:;">已买到的宝贝</a></p></div></div>';
					        $(" .wdgwc_main_top").html(html);
							var html='<p class="none_tips" style="margin:50px 0;text-align:center;"><i> </i>购物车中没有商品，赶紧去选购！</p>';
						    $(".checkout_box").hide(); 
						    $(".minicart_list .list_detail ul").empty();
						    $(".minicart_list .list_detail ul").append(html);
						  }
						 
						  $('.tNum').text(data.count);
				          $('.tSum').text("¥"+data.total);
						  var num="("+data.sum+")";
				          $('.cart_num').html(num);
					}
					 else{
					    alert(data.info);
					 }
                });
		
	}

function dos(html=''){
	//创建DOM
	var 
	quickHTML = document.querySelector("div.quick_link_mian"),
	quickShell = $(document.createElement('div')).html(quickHTML).addClass('quick_links_wrap'),
	quickLinks = quickShell.find('.quick_links');
	quickPanel = quickLinks.next();
	quickShell.appendTo('.mui-mbar-tabs');
	
	if(!html){
		var html=$("#carthtml").html();	
	}
	//具体数据操作 
	var 
	quickPopXHR,
	loadingTmpl = '<div class="loading" style="padding:30px 80px"><i></i><span>Loading...</span></div>',
	popTmpl = '<a href="javascript:;" class="ibar_closebtn" title="关闭"></a><div class="ibar_plugin_title"><h3><%=title%></h3></div><div class="pop_panel"><%=content%></div><div class="arrow"><i></i></div><div class="fix_bg"></div>',
	historyListTmpl = '<ul><%for(var i=0,len=items.length; i<5&&i<len; i++){%><li><a href="<%=items[i].productUrl%>" target="_blank" class="pic"><img alt="<%=items[i].productName%>" src="<%=items[i].productImage%>" width="60" height="60"/></a><a href="<%=items[i].productUrl%>" title="<%=items[i].productName%>" target="_blank" class="tit"><%=items[i].productName%></a><div class="price" title="单价"><em>&yen;<%=items[i].productPrice%></em></div></li><%}%></ul>',
	newMsgTmpl = '<ul><li><a href="#"><span class="tips">新回复<em class="num"><b><%=items.commentNewReply%></b></em></span>商品评价/晒单</a></li><li><a href="#"><span class="tips">新回复<em class="num"><b><%=items.consultNewReply%></b></em></span>商品咨询</a></li><li><a href="#"><span class="tips">新回复<em class="num"><b><%=items.messageNewReply%></b></em></span>我的留言</a></li><li><a href="#"><span class="tips">新通知<em class="num"><b><%=items.arrivalNewNotice%></b></em></span>到货通知</a></li><li><a href="#"><span class="tips">新通知<em class="num"><b><%=items.reduceNewNotice%></b></em></span>降价提醒</a></li></ul>',
	quickPop = quickShell.find('#quick_links_pop'),
	quickDataFns = {
		//购物信息
		message_list: {
			title: '购物车',
			content: html,
			init:$.noop
		},
		
		//我的资产
		history_list: {
			title: '我的资产',
			content: $("#zichang").html(),
			init: $.noop
		},
		//给客服留言
		leave_message: {
			title: '我关注的产品',
			content: $("#ibar_gzcp").html(),
			init:$.noop
		},
		mpbtn_histroy:{
			title: '我的足迹',
			content:$("#liulan").html(),
			init: $.noop
		},
		mpbtn_wdsc:{
			title: '收藏的产品',
			content:  $("#collecthtml").html(),
			init: $.noop
		},
		mpbtn_recharge:{
			title: '手机充值',
			content: $("#chong").html(),
			init: $.noop
		}
	};
	
	//showQuickPop
	var 
	prevPopType,
	prevTrigger,
	doc = $(document),
	popDisplayed = false,
	hideQuickPop = function(){
		if(prevTrigger){
			prevTrigger.removeClass('current');
		}
		popDisplayed = false;
		prevPopType = '';
		quickPop.hide();
		quickPop.animate({left:280,queue:true});
	},
	showQuickPop = function(type){
		if(quickPopXHR && quickPopXHR.abort){
			quickPopXHR.abort();
		}
		if(type !== prevPopType){
			var fn = quickDataFns[type];
			quickPop.html(ds.tmpl(popTmpl, fn));
			fn.init.call(this, fn);
		}
		doc.unbind('click.quick_links').one('click.quick_links', hideQuickPop);

		quickPop[0].className = 'quick_links_pop quick_' + type;
		popDisplayed = true;
		prevPopType = type;
		quickPop.show();
		quickPop.animate({left:0,queue:true});
	};
	quickShell.bind('click.quick_links', function(e){
		e.stopPropagation();	
		
	});
	quickPop.delegate('a.ibar_closebtn','click',function(){
		quickPop.hide();
		quickPop.animate({left:280,queue:true});
		if(prevTrigger){
			prevTrigger.removeClass('current');
		}
	});

	//通用事件处理
	var 
	view = $(window),
	quickLinkCollapsed = !!ds.getCookie('ql_collapse'),
	getHandlerType = function(className){
		return className.replace(/current/g, '').replace(/\s+/, '');
	},
	showPopFn = function(){
		var type = getHandlerType(this.className);
		if(popDisplayed && type === prevPopType){
			return hideQuickPop();
		}
		showQuickPop(this.className);
		if(prevTrigger){
			prevTrigger.removeClass('current');
		}
		prevTrigger = $(this).addClass('current');
	},
	quickHandlers = {
		//购物车，最近浏览，商品咨询
		my_qlinks: showPopFn,
		message_list: showPopFn,
		history_list: showPopFn,
		leave_message: showPopFn,
		mpbtn_histroy:showPopFn,
		mpbtn_recharge:showPopFn,
		mpbtn_wdsc:showPopFn,
		//返回顶部
		return_top: function(){
			ds.scrollTo(0, 0);
			hideReturnTop();
		}
	};
	quickShell.delegate('a', 'click', function(e){
		//$(".quick_links_wrap").toggleClass("w320");
        var i=$(this).parent("li").find("i").attr("class");
      
       if(localStorage.lastname&&localStorage.lastname==i){
		if($(".quick_links_wrap").width()>0){
		      $(".quick_links_wrap").removeClass("w320");
		}else{
			$(".quick_links_wrap").addClass("w320");
		}
		}
		if(!localStorage.lastname){
		   $(".quick_links_wrap").addClass("w320");
		}
	   if(localStorage.lastname&&localStorage.lastname!==i){
		if($(".quick_links_wrap").width()>0){
		     
		}else{
			$(".quick_links_wrap").addClass("w320");
		}
		}
		localStorage.lastname=i;
		var type = getHandlerType(this.className);
		if(type && quickHandlers[type]){
			quickHandlers[type].call(this);
			e.preventDefault();
		}
		if(localStorage.lastname!=="message"&&is_login<1){
		
		      //$(".quick_links_wrap").removeClass("w320");
		
		}
	});

	
	//Return top
	var scrollTimer, resizeTimer, minWidth = 1350;

	function resizeHandler(){
		clearTimeout(scrollTimer);
		scrollTimer = setTimeout(checkScroll, 160);
	}
	
	function checkResize(){
		quickShell[view.width() > 1340 ? 'removeClass' : 'addClass']('quick_links_dockright');
	}
	function scrollHandler(){
		clearTimeout(resizeTimer);
		resizeTimer = setTimeout(checkResize, 160);
	}
	function checkScroll(){
		view.scrollTop()>100 ? showReturnTop() : hideReturnTop();
	}
	function showReturnTop(){
		quickPanel.addClass('quick_links_allow_gotop');
	}
	function hideReturnTop(){
		quickPanel.removeClass('quick_links_allow_gotop');
	}
	view.bind('scroll.go_top', resizeHandler).bind('resize.quick_links', scrollHandler);
	quickLinkCollapsed && quickShell.addClass('quick_links_min');
	resizeHandler();
	scrollHandler();
	
}
