// JavaScript Document
// 手工选择商品选中的商品列表
var product_list = [];
var search_goods_catid='';
var search_goods_keywords='';
$(function(){
    todaytime();
    clear_form();
    //积分抵现按钮
    $('.border').click(function(){
    	$(this).removeClass("disabled");
    	var icontype=$("#icontype").val();
    	if(icontype==0){	//选中
    		$(this).html("&#xe60e;");
    		$("#icontype").val(1);
    	}else{	//没选中
    		$(this).html("&#xe656;");
    		$("#icontype").val(0);
    	}
        total_price();//重新计算价格
    })
})
//当前日期，时间
function todaytime(){ 
  var date = new Date(); //创建时间对象 
  var year = date.getFullYear(); //获取年 
  var month = date.getMonth()+ 1;//获取月   
  var day = date.getDate(); //获取当日
  var h=date.getHours();
  var m=date.getMinutes();
  var s=date.getSeconds();
  var time = year+"-"+month+"-"+day+"&nbsp;&nbsp;"+h+':'+m+':'+s; //组合时间 
  $("#time").html(time);
  setTimeout("todaytime()",1000); 
}
//快捷键设置
document.onkeydown = function(e){
	var ev = document.all ? window.event : e;
	var keycode=ev.keyCode;
    var enter_id=$("input:focus").attr('id');
	if(keycode==13) {//回车 快捷键Enter
        if(enter_id=='login_name' || enter_id=='password' || enter_id=='verify'){//登录
            login();
        }
        if(enter_id=='serarch_sn'){//按编号查询商品
            search_by_sn();
        }
        if(enter_id=='user_card_no'){//按编号查询商品
            search_member();
        }
        if(enter_id=='search_keywords'){//按关键字查询商品
            get_goods_list(search_goods_catid,'',1);
        }
        if(enter_id=='cash_youhuiquan'){//验证优惠券
            checkquan();
        }
        
        if(enter_id=='pay_sn'){//扫码支付
            snpay();
        }
            
      //  alert(enter_id);
		//此处调商品搜索函数
		//order_user();return false;
	}
    if(enter_id!='serarch_sn' && enter_id!='search_keywords' && enter_id!='pay_password' && enter_id!='cash_youhuiquan'){
    	if(keycode==83) {		//商品搜索 快捷键S
    		//此处调商品搜索函数
    	}
    	/*if(keycode==67) {		//清空 快捷键C
            clear_form();
    	}*/
    	if(keycode==71) {		//挂单 快捷键G
    		//此处调商品挂单函数
    	}
    	if(keycode==77 && enter_id!='user_card_no') {		//会员卡 快捷键M
    	   card();//此处调会员卡函数
           $('#user_card_no').keyup(function(){
              $('#user_card_no').val('');
           });
           $('#user_card_no').bind('keyup', function() {
              $('#user_card_no').val('');
              $("#user_card_no").unbind('keyup');
           });
    	}
    }
}
//登录
function login(){
    var login_name=$("#login_name").val();
	if(!login_name){$.showErr('请输入账号',2,'hc');return false;}
    var pwd=$("#password").val();
	if(!pwd){$.showErr('请输入密码',2,'hc');return false;}
    var verify=$("#verify").val();
	if(!verify){$.showErr('请输入验证码',2,'hc');return false;}
    var query= new Object();
    query.login_name = login_name;
    query.password = pwd;
    query.verify = verify;
    $.ajax({
        type: "POST",
        url: APP + "Shop/Register/dologin",
        data: query,
        success: function(data){
            if(data.status == 1){
                $.showSuccess(data.info, 0, 'hc');
                window.location.href = APP + "Shop/cashier/index";
            }else{
                $.showErr(data.info,0,'hc');
				$("#verify_img").click();
            }
        }
    });
}
/*弹窗*/
function card(){//打开会员卡输入框
	$('.zhezhao').show();
	$('.user_card').show();
	$('body').css('overflow','hidden');
	$('#user_card_no').focus();
    $('#user_card_no').val('');
    return false;
}
function serchgoods(){//打开手动选择商品框
	$('.back1').show();
	$('.chooseGoods').show();
	$('body').css('overflow','hidden');
	product_list = [];
    get_goods_list(0,'null',1,1);//显示商品
}
//现金支付确认结算
function queding(){
    if ($('.queding').hasClass('submitting')) {showtoast('数据提交中，请勿重复提交');
		return;
    }
    $('.queding').addClass('submitting');
    addorder(1,'','.queding');
}
//现金支付
function xj(){
    var yingshou=parseFloat($('#yingshou').text());
    if(yingshou<=0 || isNaN(yingshou)){showtoast('请先选择商品');return false;}
    if ($('.queding').hasClass('submitting')) {$('.queding').removeClass('submitting');}
    closeall();
	$('.back2').show();
	$('.jiesuan').show();
	$('body').css('overflow','hidden')
}
//扫码支付
function sm(){
    var yingshou=parseFloat($('#yingshou').text());
    if(yingshou<=0 || isNaN(yingshou)){showtoast('请先选择商品');return false;}
    closeall();
    $('#pay_sn').val('');
    var uid=$('#user_id').val();
    $('.pay_money').text('￥'+yingshou);
	$('.back3').show();
	$('.pay_Wait').show();
	$('body').css('overflow','hidden');
    if(uid)$('#yuepay_sm').addClass('disabled');
    else $('#yuepay_sm').removeClass('disabled');
}

//扫码确认结算
function snpay(){
    var obj='#pay_sn';
    if ($(obj).hasClass('submitting')) {
        showtoast('数据提交中，请勿重复提交');
		return;
    }
    $(obj).addClass('submitting');    
    var number=$('#pay_sn').val();
    if(!number){$(obj).removeClass('submitting');
        showtoast('请扫微信或者支付宝付款码');return false;}   
    addorder(2,number,obj);
}
//余额支付
function ye(){
    if($('#yuepay').hasClass('disabled')){
        var yingshou=parseFloat($('#yingshou').text());
        if(yingshou<=0 || isNaN(yingshou)){showtoast('请先选择商品');return false;}
        var user_cash=parseFloat($('.js-user_cash').text());
        if(user_cash<=0 || isNaN(user_cash) || user_cash<yingshou){showtoast('余额不足不能支付');return false;}
        closeall();
        $('.pay_money').text('￥'+yingshou);
        $('.back5').show();
    	$('.pay_Wait').show();
    	$('body').css('overflow','hidden');
    }	
}
//余额确认支付
function zhifu(){
    var yingshou=parseFloat($('#yingshou').text());
    if(yingshou<=0 || isNaN(yingshou)){showtoast('请先选择商品');return false;}    
    if ($('.zhifu').hasClass('submitting')) {
        showtoast('数据提交中，请勿重复提交');
		return;
    }
    $('.zhifu').addClass('submitting');
    var number=$('#pay_password').val();
    if(!number){$('.zhifu').removeClass('submitting');showtoast('请填写支付密码');return false;}   
    addorder(3,number,'.zhifu');    
}

//到付确认支付
function dfzhifu(){
    var yingshou=parseFloat($('#yingshou').text());
    if(yingshou<=0 || isNaN(yingshou)){showtoast('请先选择商品');return false;}    
    var obj='.dfzhifu';
    if ($(obj).hasClass('submitting')) {
        showtoast('数据提交中，请勿重复提交');
		return;
    }
    $(obj).addClass('submitting');
    addorder(4,'',obj);    
}
//到付
function psi(){
    var yingshou=parseFloat($('#yingshou').text());
    if(yingshou<=0 || isNaN(yingshou)){showtoast('请先选择商品');return false;}
    init_daofu();//初始化到付时间/余额选择
	$('.zhezhao1').show();
	$('.peisongbox').show();    
    var uid=$('#user_id').val();
    $('#df_usermoney').find('.radiobox').removeClass("xuanzhong").addClass("daixuan");
    if(uid){
        var user_cash=parseFloat($('.js-user_cash').text());
        if(user_cash<=0 || isNaN(user_cash) || user_cash<yingshou){$('#df_usermoney').hide();}else{$('#df_usermoney').show();}
        var query = new Object;
        query.uid=uid;
        $.ajax({
            type: "POST",
            url: APP + "Shop/Cashier/getuseraddress",
            data: query,
            success: function(data){
                if(data.status == 1){
                    $('#user_address').show();
                    $('#user_add_sel').html('<option value="">请选择</option>'+data.info);
                    $('#user_add_sel').change(function(){
                        var selected=$('#user_add_sel option:selected');
                        var addid=selected.val();
                        if(addid){
                            var name=selected.data('consignee');
                            var mobile=selected.data('mobile');
                            var province=selected.data('province');
                            var city=selected.data('city');
                            var district=selected.data('district');
                            var pro_name=selected.data('pro_name');
                            var city_name=selected.data('city_name');
                            var dis_name=selected.data('dis_name');
                            var address=selected.data('address');
                            if(name)$('#add_name').val(name);
                            if(mobile)$('#add_mobile').val(mobile);
                            if(address)$('#add_address').val(address);
                            if(province)$('#province').val(province);
                            if(city){
                                $('#city_id').show();
                                $('#city_id').attr('disabled',false);
                                $('#city_id').html('<option value="'+city+'">'+city_name+'</option>');
                            }
                            if(district){
                                $('#district').show();
                                $('#district').attr('disabled',false);
                                $('#district').html('<option value="'+district+'">'+dis_name+'</option>');
                            }
                        }
                        
                    })
                }
            }
       });
    }   
}

function qxzf(){closeall();}//取消支付
function fqzf(){closeall();}//放弃支付
function s_sure(){clear_form();closeall();}//收款成功确认关闭
//添加订单并支付
//type 1 现金支付 number 空
//type 2 扫码支付 number 支付码
//type 3 余额支付 number 支付密码
//type 4 到付 number 空
function addorder(type,number,obj){
    if(!type)return false;
    var yingshou=parseFloat($('#yingshou').text());if(isNaN(yingshou))yingshou=0;
    if(yingshou<=0){$(obj).removeClass('submitting');showtoast('请先选择商品');return false;}
    var uid=parseInt($('#user_id').val());if(isNaN(uid))uid=0;    
    var query = new Object;
    if(type==3){
        if(uid<=0){$(obj).removeClass('submitting');showtoast('请选择会员');return false;}
        var user_cash=parseFloat($('.js-user_cash').text());
        if(user_cash<=0 || isNaN(user_cash) || user_cash<yingshou){$(obj).removeClass('submitting');showtoast('余额不足不能支付');return false;}
    }
    if(type==4){
        var user_money=$('#df_usermoney').find('.radiobox').hasClass('xuanzhong');$(obj).removeClass('submitting');
        if(user_money){
            if(uid<=0){$(obj).removeClass('submitting');showtoast('请选择会员');return false;}
            var user_cash=parseFloat($('.js-user_cash').text());
            if(user_cash<=0 || isNaN(user_cash) || user_cash<yingshou){$(obj).removeClass('submitting');showtoast('余额不足不能支付');return false;}
        }
        query.user_money=user_money?1:0;
        query.add_name=$('#add_name').val();
        query.add_mobile=$('#add_mobile').val();
        query.province=$('#province').val();
        query.city_id=$('#city_id').val();
        query.district=$('#district').val();
        query.add_address=$('#add_address').val();
        query.add_time=$('#add_time').val();
        query.psfs=$('#psfs').val();
        query.xpoint=$('#xpoint').val();
        query.ypoint=$('#ypoint').val();
        if(!$.minLength(query.add_name,2)){$('#add_name').focus();$(obj).removeClass('submitting');showtoast('请填写正确联系人');return false;}
        if(!$.checkMobilePhone(query.add_mobile)){$('#add_mobile').focus();$(obj).removeClass('submitting');showtoast('请填写正确联系电话');return false;}
        if(!$.minLength(query.add_address,3)){$('#add_address').focus();$(obj).removeClass('submitting');showtoast('请填写正确详细地址');return false;}
        //if(!psfs){showtoast('请选择派送方式');return false;}        
    }    
    var cash_jifen=parseInt($('#cash_jifen').val());//使用积分
    if(cash_jifen>0 && !isNaN(cash_jifen)){
        var user_point=parseInt($('.js-user_point').text());
        if(user_point<=0 || isNaN(user_point)){cash_jifen=0;
        }else{
            if(cash_jifen>user_point)cash_jifen=user_point;//实际可用用户积分总数
        }
    }else{cash_jifen=0;}    
    var cash_youhuiquan=$('#cash_id').val();//使用优惠券
    var code=$('#cash_youhuiquan').val();//优惠券code
    var cart_list =new Object;//获取商品列表
    $('.cart_list tr').each(function () {
		var obj = $(this);
        var product = {};
        var goods_index=obj.find('.goodsn').attr('index');
		product.goods_num = obj.find('#goods_type_'+goods_index).val();
		cart_list[goods_index] = product;
    });
    if(!cart_list){
        $(obj).removeClass('submitting');
         showMessage('请先选择商品',2000,true,'bounceInUp-hastrans','bounceOutDown-hastrans');return false;
    }
    query.cart_list=JSON.stringify(cart_list);
    query.uid=uid;
    query.cash_jifen=cash_jifen;
    query.cash_youhuiquan=cash_youhuiquan;
    query.code=code;
    query.pay_type=type;
    query.number=number;
    query.psfs=$("input[name='psfs']:checked").val();
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/addorder",
        data: query,
        success: function(data){
            $(obj).removeClass('submitting');
            if(data.status == 1){
                //$.showSuccess('支付成功!订单号:'+data.order_sn, 0, 'hc');
                showsuccess(data.order_sn);
                clear_form();
                if(data.printstatus==1){
                    showtoast(data.printhtml);
                    $('.pay_success a').hide();
                }else{
                    print_order(data.printhtml);
                    $('.pay_success a').show();
                }
                
                //展示支付成功页面 打印小票等
            }else{
                $.showErr(data.info,0,'hc');
            }
        }
   });
}
//打开选择优惠券
function quan(){
    var uid=$('#user_id').val();
    if(!uid){
        showMessage('暂无可用优惠券',2000,true,'bounceInUp-hastrans','bounceOutDown-hastrans');return ;
    }
    $('.quan').html('');
    $('#loading_quan').show();
	$('.bg3').show();$('.sale').show();$('body').css('overflow','hidden');
    var query= new Object();
    query.uid = uid;
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/quanlist",
        data: query,
        dataType: "JSON",
        success: function(ret){
            $('#loading_quan').hide();
            if(ret.status == 1){
                var data=ret.info;
                var html='<ul>';       
                
                for (var i in data) {                         
                    html+='<li class="stamp">';
					html+='<div class="par">';
    					html+='<p>'+data[i].name+'</p>';
                        if(data[i].rank_id=='CASH'){
                            html+='<sub class="sign">￥</sub>';
    					    html+='<span>'+data[i].reduce_cost+'</span>';
                        }else{
    					    html+='<span>'+data[i].discount+'</span>';
                            html+='<sub class="sign">折</sub>';
                        }    					
    					html+='<sub>'+data[i].coupons_name+'</sub>';
        			if(data[i].least_cost)	html+='<p>订单满'+data[i].least_cost+'元</p>';
    				html+='</div>';
    				html+='<div class="copy">副券<p>';
        				if(data[i].begin && data[i].end)html+=data[i].begin+'<br>'+data[i].end;
                        html+='</p>';
                        html+='<a href="#" onclick="usequan(\''+data[i].coupons_get+'\',\''+data[i].name+'\')">立即使用</a>';
    				html+='</div>';
				    html+='</li>';    
    			    
    			}            
                html+='</ul>';
                $('.quan').html(html);
            }else{
                closeall();
                showtoast(ret.info);
            }
        }
    });        
}
function usequan(id,name){
    $('#cash_id').val(id);
    $('#cash_name').val(name);
    $('#cash_youhuiquan').val(name);
    closeall();
    checkquan();
}
//验证券有效性
function checkquan(){
    var quannum=$('#cash_youhuiquan').val();
    var quanid=$('#cash_id').val();
    var quanname=$('#cash_name').val();
    if(!quannum)return false;
    if(quannum!=quanname){
        quanid=0;quanname='';
        $('#cash_id').val(0);$('#cash_name').val('');
    }
    var query= new Object();
    query.sn = quannum;
    query.id = quanid;
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/checkquan",
        data: query,
        dataType: "JSON",
        success: function(ret){
            $('#cash_type').val(0);$('#cash_discount').val(0);$('#cash_min').val(0);
            if(ret.status == 1){                
                $('#cash_type').val(ret.info.type);$('#cash_discount').val(ret.info.discount);$('#cash_min').val(ret.info.min);
                $('#cash_id').val(ret.info.cash_id);
                total_price();//重新计算价格
            }else{
                $('#cash_youhuiquan').val('');
                showtoast(ret.info);
            }
        }
    });
}
//打开属性窗口
function shuxing(){
    product_list = [];
    $('.attrbox .sureChoose').remove();
	$('.back10').show();$('.attrbox').show();
	$('body').css('overflow','hidden')
}
//关闭属性
function closeshuxing(){
	$('.back10').hide();$('.attrbox').hide();
	$('body').css('overflow','');
}
//收款成功
function showsuccess(orderNum){
    closeall();
    $('.back4').show();$('.zf_success').show();
    $('body').css('overflow','hidden')
    $('.orderNum').text('订单号:'+orderNum);
}
//打印订单
function print_order(printhtml){
    if(!printhtml){showtoast('未完成打印(01)');return false;}
    var obj=$('#printArea');
    obj.html(printhtml);
    obj.printArea();
    showtoast('打印中,请确保打印机连接正常!');return true;
}
//打印重试
function reprient(){
    var html=$('#printArea').html();
    print_order(html);
}
function sildedown(id){
	$('#sildecont'+id).slideToggle();
}

//打开退货窗口
function thblock(){
	$('.zhezhao2').show();
	$('.tuihuo').show();
	$('body').css('overflow','hidden');
    $('#ordersn').val('');
    $('#goodsbody').html('');
    $('#goodsbodytotal').html('');
}
//按订单号搜索商品
function searchordergoods(){
    var ordersn=$('#ordersn').val();
    if(!ordersn){showtoast('请输入订单号再搜索');return false;}
	$('.tuihoubox').show();
    var query= new Object();
    query.sn = ordersn;
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/orderbysn",
        data: query,
        dataType: "JSON",
        success: function(ret){
            if(ret.status == 1){
                //alert(JSON.stringify(ret));
                var bodyhtml=inserttuigoods(ret.ordergoods);
                if(bodyhtml){$('#goodsbody').html(bodyhtml);bind_tui_goods();}
                var totalhtml='<span><label>订单金额：</label>￥'+ret.order.order_amount+'</span>';                
				totalhtml+='<span><label>支付方式：</label>'+ret.order.pay_name+'</span>';             
				totalhtml+='<span><label>订单时间：</label>'+ret.order.format_addtime+'</span>';
				if(ret.order.used_score_money>0)totalhtml+='<span><label>积分优惠：</label>-￥'+ret.order.used_score_money+'</span>';
				if(ret.order.bonus_money>0)totalhtml+='<span><label>代金券优惠：</label>-￥'+ret.order.bonus_money+'</span>';
				totalhtml+='<span><label>退款金额：</label><input id="tuigoodsmoney" data-orderid="'+ret.order.id+'" type="text" value="0.00" class="thorder" style="border:1px solid #ddd;width:80px" /></span>';                
                if(ret.order.used_score_money>0)totalhtml+='<span><label>退积分：</label><input id="tuiorderjifen" type="text" value="0" class="thorder" style="border:1px solid #ddd;width:80px" /></span>';                
                else totalhtml+='<input id="tuiorderjifen" type="hidden" value="0"/>';
                $('#goodsbodytotal').html(totalhtml);
            }else{
                showtoast(ret.info);
            }
        }
    });
}
//插入要退的商品
function inserttuigoods(goods){
    if(!goods)return false;
    var html='';
    for(i = 0; i < goods.length; i ++ )
    {
        html+='<tr>';
			html+='<td>'+goods[i].goods_name+'</td>';
			html+='<td>'+goods[i].goods_attrname+'</td>';
			html+='<td><input class="ordergoods" id="ordergoods_'+goods[i].id+'" type="number" data-totalnum="'+goods[i].goods_number+'" value="'+goods[i].goods_number+'"/></td>';
			html+='<td>￥'+goods[i].goods_price+'</td>';
			html+='<td><span class="radiobox iconfont daixuan" data-id="'+goods[i].id+'" data-price="'+goods[i].goods_price+'"></span></td>';
			html+='';
		html+='</tr>';
    }return html;
}

//弹出商品选择框绑定事件
function bind_tui_goods(){
    $('#goodsbody .radiobox').click(function(){//商品选择
	  	if($(this).hasClass('daixuan')){// 选中状态
			$(this).removeClass("daixuan").addClass("xuanzhong");            
	  	}else{// 取消选中状态
		  	$(this).removeClass("xuanzhong").removeClass("disabled").addClass("daixuan");
	  	}
        counttuitotal();//重新计算退款金额
	});
    $('#goodsbody .ordergoods').change(function(){//商品数量
        var goods_total = $(this).data('totalnum');
        var goods_number = $(this).val();
	  	if(goods_number<1){$(this).val(1);}
	  	if(goods_number>goods_total){$(this).val(goods_total);}
        counttuitotal();//重新计算退款金额
	});
    $('.qrtuihuo').click(function(){
        submittui();
    });
}
//提交退货
function submittui(){
    var obj='.qrtuihuo';
    if ($(obj).hasClass('submitting')) {
        showtoast('数据提交中，请勿重复提交');
		return;
    }
    $(obj).addClass('submitting');    
    var goods= [];
    $('#goodsbody .xuanzhong').each(function(){
        var id=$(this).data('id');
        var num=parseFloat($('#ordergoods_'+id).val());
        goods[id]=num;
    });
    if(!goods || Object.keys(goods).length==0){
        $(obj).removeClass('submitting');
        showtoast('请选择要退货商品再提交');
		return;
    }
    var tuigoodsmoney=parseFloat($('#tuigoodsmoney').val());
    var tuiorderjifen=parseInt($('#tuiorderjifen').val());
    if(tuigoodsmoney<=0){$(obj).removeClass('submitting');
        showtoast('退货金额错误');
		return;
    }
    var query= new Object();
    query.goods = JSON.stringify(goods); //置空搜索框
    query.order_id =$('#tuigoodsmoney').data('orderid');
    query.tuigoodsmoney =tuigoodsmoney;
    query.tuiorderjifen =tuiorderjifen;   
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/returnorder",
        data: query,
        dataType: "JSON",
        success: function(ret){$(obj).removeClass('submitting');
            if(ret.status == 1){
                $.showSuccess(ret.info, 0, 'hc');
                clear_form();closeall(); 
            }else{
                showtoast(ret.info);
            }
        }
    });      
}
//计算退款金额
function counttuitotal(){
    var total=0;
    $('#goodsbody .xuanzhong').each(function(){
         var id=$(this).data('id');
         var goods_price=parseFloat($(this).data('price'));
         var num=parseFloat($('#ordergoods_'+id).val());
         var totalprice=parseFloat(num*goods_price);
         total =total+totalprice ;
    });
    total=formatmoney(total);
    $('#tuigoodsmoney').val(total);
}

//格式化价格
function formatmoney(price, len)
{
    price=parseFloat(price);
    if(price==0 || isNaN(price))return 0;
    len = len > 0 && len <= 20 ? len : 2;
    if(price<=0)price=0;
    price = parseFloat((price + "").replace(/[^\d\.-]/g, "")).toFixed(len) + "";
    var l = price.split(".")[0].split("").reverse(),
        r = price.split(".")[1];
    t = "";
    for(i = 0; i < l.length; i ++ )
    {
        t += l[i] ;
    }
    var re = t.split("").reverse().join("") + "." + r;
    return re.replace("-,","-");
}
//按编号查询商品
function search_by_sn(){
    var serarch_sn=$("#serarch_sn").val();
	if(!serarch_sn){showtoast('请输入商品编号');return false;}
    var query= new Object();
    
    var uid=$('#user_id').val();
    query.sn = serarch_sn;$('#serarch_sn').val(''); //置空搜索框
    query.uid =uid;
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/search_by_sn",
        data: query,
        dataType: "JSON",
        success: function(ret){
            if(ret.status == 1){                
                addtrtotable(ret.data);
                total_price();//重新计算价格
            }else if(ret.status == 2){//选择属性
                shuxing();
                $('.foodsDes_attr').html(ret.data);  
                
                $('.foodsDes_attr').append('<button class="sureChoose">确定</button>');              
                bind_select_goods();
            }else{
                showtoast(ret.info);
            }
        }
    });
}
//搜索商品
function get_goods_list(catid,keywords,page,cache){
    search_goods_catid=catid;
    if(keywords!='null'){
        if(keywords)search_goods_keywords=keywords;
        else keywords=search_goods_keywords;
    }else keywords='';
    if(!keywords)keywords=$('#search_keywords').val();
    var goods_html=$('.foodsKinds').html();
    if(cache){
        if(goods_html){format_search_select();return false;}
    }else{
        $('.foodsKinds').html('');
        $('.pages').html('');
    }
    $('.cate_list').removeClass('on');
    $('#cate_'+catid).addClass('on');
    $('#loading_goods').show();
    $('.foodsKinds').hide();
    var query= new Object();
    var uid=$('#user_id').val();
    query.catid = catid; //置空搜索框
    query.keywords = keywords; //置空搜索框
    query.uid =uid;
    var url;
    if(page!=1 && page){
        url=page;
    }else{
        url=APP + "Shop/Cashier/search_by_key"
    }
    $.ajax({
        type: "POST",
        url: url,
        data: query,
        dataType: "JSON",
        success: function(ret){            
            $('#loading_goods').hide();
            $('.foodsKinds').show();
            if(ret.status == 1){
                $('.foodsKinds').html(ret.data);
                $('.pages').html(ret.page+'<button class="sureChoose">确定</button>');
                
                // 产品恢复已经选中、数量、库存等信息
		        format_search_select();
                bind_select_goods();                
            }else{
                showtoast(ret.info);
            }
        }
    });
}
//产品恢复已经选中、数量、库存等信息
function format_search_select(){
    $('.foodsDes').each(function () {
		var obj = $(this);
		if (obj.find('#sildecont').size() > 0) {
			// 有多规格情况
			obj.find('.foodsDesitem').each(function () {
				var obj_sku_li = $(this);
                obj_sku_li.find('.radiobox').removeClass("xuanzhong").addClass("daixuan");
				obj_sku_li.find('.ber').text(1);
                var goods_index = obj_sku_li.find('.radiobox').data('index');
				for (var i in product_list) {
					if (i == goods_index) {
					    obj_sku_li.find('.radiobox').removeClass("daixuan").addClass("xuanzhong");
						obj_sku_li.find('.ber').text(product_list[i].goods_num);
						break;
					}
				}
			});
		} else {
		    var goods_index = obj.find('.radiobox').data('index');
            obj.find('.radiobox').removeClass("xuanzhong").addClass("daixuan");
			obj.find('.ber').text(1);
			// 无多规格情况
			for (var i in product_list) {
				if (i == goods_index) {
					obj.find('.radiobox').removeClass("daixuan").addClass("xuanzhong");
					obj.find('.ber').text(product_list[i].goods_num);
					break;
				}
			}
		}
	});
}
//弹出商品选择框绑定事件
function bind_select_goods(){
    $('.radiobox').click(function(){//商品选择
        var goods_index = $(this).data('index');
	  	if($(this).hasClass('daixuan')){// 选中状态
			$(this).removeClass("daixuan").addClass("xuanzhong");
            var goods_name=$(this).data('name');var goods_attr='';
            if(goods_name){
                goods_attr=$(this).parent().find('.foodtitle').text();
            }else{
                goods_name=$(this).parent().find('.foodtitle').text();
            }
            var num=parseInt($(this).parent().find('.ber').text());
            if(num<=0 || isNaN(num))num=1;
            var attr_price=parseFloat($(this).parent().find('.f_price').text());            
            if(attr_price<=0 || isNaN(attr_price))attr_price=$(this).data('attr_price');
            
            var product = {};
			product.goods_index = goods_index;
			product.goods_name = goods_name;
			product.goods_sn = $(this).data('goods_sn');;//编码
			product.goods_num = num;
			product.market_price = $(this).data('market_price');
			product.attr_price = attr_price;//卖价
			product.goods_attr = goods_attr;
			product.goods_stock = $(this).parent().find('.kucun').data('stock');
			product_list[goods_index] = product;
	  	}else{// 取消选中状态
		  	$(this).removeClass("xuanzhong").removeClass("disabled").addClass("daixuan"); 
            var product_list_tmp = [];
			for (var i in product_list) {
				if (i != goods_index) {
					product_list_tmp[i] = product_list[i];
				}
			}
			product_list = product_list_tmp; 
	  	}
	})
    $('.stock_add').click(function(){//加库存
        var index_span=$(this).parent().next();
        if(!index_span.hasClass('radiobox')){
            index_span=$(this).parent().next().next();
        }
        var kucun =parseInt($(this).parent().data('stock'));
        var num=parseInt($(this).parent().find('.ber').text());
        var new_num=num+1;
        if(new_num>kucun || isNaN(new_num))return false;
        if(index_span.hasClass('xuanzhong')){
            var goods_index = index_span.data('index');
            product_list[goods_index].goods_num=new_num;
        }     
        $(this).parent().find('.ber').text(new_num);
        
    });
    $('.stock_less').click(function(){//减库存
        var index_span=$(this).parent().next();
        if(!index_span.hasClass('radiobox')){
            index_span=$(this).parent().next().next();
        }        
        var num=parseInt($(this).parent().find('.ber').text());
        var new_num=num-1;
        if(new_num<=0 || isNaN(new_num))return false;
        if(index_span.hasClass('xuanzhong')){    
            var goods_index = index_span.data('index');
            product_list[goods_index].goods_num=new_num;
        }
        $(this).parent().find('.ber').text(new_num);
      
    });
    //选择商品
    $('.sureChoose').click(function(){
        if($.isEmptyObject(product_list)) {
			showtoast('请先选择商品再提交');return false;
		} else {
			if ($(this).hasClass('submitting')) {
			    showtoast('数据提交中，请勿重复提交');
				return;
			}			
			$(this).addClass('submitting');			
			var product_arr = [];
			for (var i in product_list) {
			    addtrtotable(product_list[i]);
			}
            total_price();//重新计算价格
            closeall();
            closeshuxing();
           // product_list=[];
            $(this).removeClass('submitting');	
            
		}
    });   
    // 产品搜索分页
    $('.pages .pagination a').each(function(){
        var url=$(this).attr('href');
        $(this).attr('href','javascript:void(0)');
        $(this).click(function(){
            get_goods_list(search_goods_catid,search_goods_keywords,url);
        })
    });
    //手动跳页
    $('.pages .pagination li #DO_PAGE').click(function(){
        var page=$('#PAGE_VALUE').val();
        page=parseInt(page);
        if(page==0 || isNaN(page)){showtoast('页数错误');return;}
        var url=APP + "Shop/Cashier/search_by_key/p/"+page;
        get_goods_list(search_goods_catid,search_goods_keywords,url)
    })
}
//根据返回数据添加到表格中
function addtrtotable(info,obj){
    if(!info)return false;
    var total_price=0;
    var goods_info=$('#goods_info').val();
    if(!goods_info)goods_info=',';
    if(goods_info.indexOf(','+info.goods_index+',')==-1){//添加新商品
        goods_info+=info.goods_index+",";
        $('#goods_info').val(goods_info); 
        total_price=info.goods_num*info.market_price;
        var html='<tr id="tr_1">'+
       		'<td width="160">'+info.goods_name+'</td>'+
       		'<td class="goodsn" index="'+info.goods_index+'" width="120">'+info.goods_sn+'</td>'+
       		'<td width="70">'+formatmoney(info.market_price)+'</td>'+
       		'<td width="70">'+formatmoney(info.attr_price)+'</td>'+
       		'<td id="attr_key" width="125">'+info.goods_attr+'</td>'+
       		'<td width="70"><input style="width:50px;" id="goods_type_'+info.goods_index+'" name="goods_type['+info.goods_index+']" value="'+info.goods_num+'" onchange="total_price()" type="number"></td>'+
       		'<td id="pay_money" width="70">'+formatmoney(total_price)+'</td>'+
       		'<td width="90"><a onclick="delCurrentRow(this)" style="cursor:pointer;">删除</a>'+
       		'<input type="hidden" id="goods_stock_'+info.goods_index+'" value="'+info.goods_stock+'" />'+
       		'</td></tr>';
        if(!obj)obj='.cart_list';
        var list_null = $(obj).attr('data-null');
        if(list_null==1){
            $(obj).html('');
            $(obj).attr('data-null',0);
        }
        $(obj).append(html);
    }else{//旧商品直接改数量
        var old_num=$('#goods_type_'+info.goods_index).val();
        var new_num=parseFloat(old_num) + parseFloat(info.goods_num);
        if(new_num>info.goods_stock){
            showtoast('库存不足');return false;
        }
        $('#goods_type_'+info.goods_index).val(new_num);
    }
}
//删除选中行
function delCurrentRow(obj){
    if(confirm("确定要删除这个商品吗?")){
      var tr=$(obj).parent().parent(); 
      tr.remove();
      var goods_info=$('#goods_info').val();
      goods_info=goods_info.replace(','+tr.children(":first").next().attr('index')+',',',');
      $('#goods_info').val(goods_info);  
      total_price();
      return false;
    }
}
//计算价格
function total_price(){
    var allmoney=0;//总金额
    var allnum=0;//总数量
    var discount=0;//折扣金额
    var yingshou=0;//应收
    var cash_jifen='';//使用积分
    var cash_youhuiquan=$('#cash_youhuiquan').val();//使用优惠券
    var uid=parseInt($('#user_id').val());
    var usejifen='';//页面里显示
    $(".goodsn").each(function(){
        var goods_price=parseFloat($(this).next().html());//原价
        var pay_money=parseFloat($(this).next().next().html());//实际价格
        var goods_index=$(this).attr('index');
        var goods_stock=parseInt($('#goods_stock_'+goods_index).val());//库存
        var num=parseFloat($('#goods_type_'+goods_index).val()); //数量 NAN
        if(num<=0 || isNaN(num)){
            num=1;$('#goods_type_'+goods_index).val(1);
        }
        if(num>goods_stock){
            var goods_name =$(this).prev().html();
            $('#goods_type_'+goods_index).val(goods_stock);
            showtoast(goods_name+'库存不足');
            num=goods_stock;
        }
        var goods_money=parseFloat(pay_money*num);
        $(this).next().next().next().next().next().html(formatmoney(goods_money));
        discount+=(goods_price-pay_money)*num;
        allmoney+=goods_money; 
        allnum+=num;
    });
    
    yingshou=allmoney;
    
    $('#cash_jifen_text').val('');
    $('#cash_jifen').val(0);
    if(allmoney>0 && uid>0){
        var user_point=parseInt($('.js-user_point').text());
        if(user_point<=0 || isNaN(user_point)){
            cash_jifen=0;
        }else{
            var icontype = $('#icontype').val();//是否使用积分
            cash_jifen=user_point;//实际可用用户积分总数
            var max_order_money=parseFloat(allmoney*point_pay_rate/100);//订单最大可用积分抵扣钱数
            var max_order_points=max_order_money*point_rate;//订单最大可用积分抵扣数
            
            if(cash_jifen>max_order_points)cash_jifen=max_order_points;                
            if(cash_jifen>0){
                cash_jifen=parseInt(cash_jifen);
                var order_points_money=parseFloat(cash_jifen/point_rate);//用户积分可抵扣钱数
                if(icontype==1)yingshou=yingshou-order_points_money;//抵扣后就收钱数
                usejifen='用'+cash_jifen+'积分,抵'+order_points_money+'元';
            }
            if(usejifen)$('#cash_jifen_text').val(usejifen);//使用积分抵现            
            if(icontype==1)$('#cash_jifen').val(cash_jifen);
            else $('#cash_jifen').val(0);
        }
    }
    if(cash_youhuiquan){
        var cash_type=$('#cash_type').val();
        var cash_discount=$('#cash_discount').val();
        var cash_min=$('#cash_min').val();
        var cash_dikou='';cash_discount=parseFloat(cash_discount);
        if(cash_type==1 && cash_discount>0){//满减                       
            cash_dikou='优惠券'
            if(cash_min>0)cash_dikou+='满'+cash_min;
            cash_dikou+='减'+cash_discount+'元';           
            if((yingshou>0 && cash_min>0 && yingshou>cash_min) || (yingshou>0 && cash_min==0 && cash_discount<yingshou)){
                yingshou=yingshou-cash_discount;  
                discount += cash_discount;
            }
        }
        if(cash_type==2 && cash_discount>0){//满折
            var cash_discount_money=allmoney*(1-cash_discount);
            var cash_zhe=cash_discount*10;
            cash_dikou='优惠券';
            if(cash_min>0)cash_dikou+='满'+cash_min+'元';
            cash_dikou+=cash_zhe+'折';
            if((yingshou>0 && cash_min>0 && yingshou>cash_min) || (yingshou>0 && cash_min==0 && cash_discount_money<yingshou)){
                yingshou=yingshou-cash_discount_money;
                discount +=cash_discount_money;
            }
        }
        if(cash_dikou){
            $('#cash_youhuiquan').attr('title',cash_dikou);
        }
    }
    
    $('#usejifen').html(0);
    if(uid>0 && yingshou>0){//赠送积分
        var zeng_jifen=parseInt(yingshou);
        var huodongnum=parseFloat($('#huodongnum').val());
        var huodongmin=parseFloat($('#huodongmin').val());
        if(huodongnum>1 && yingshou>huodongmin){
            zeng_jifen=parseInt(zeng_jifen*huodongnum);
        }        
        $('#usejifen').html(zeng_jifen);
    }
    $('#discount_text').text('');
    if(discount>0){//优惠金额
        $('#discount_text').text('优惠：￥'+formatmoney(discount));
    }
    
    $('#all_money').html(formatmoney(allmoney));
    $('#yingshou').html(formatmoney(yingshou));
    $('#g_num').html(allnum);
    shishoucount();
    return true;
    //$('#youhui_price').html(discount.toFixed(2));
    //$('#discount').val(discount);
}
//挂单
function guadan(){
    var goods_info=$('#goods_info').val();
    if(!goods_info || goods_info==','){
         showMessage('请先选择商品',2000,true,'bounceInUp-hastrans','bounceOutDown-hastrans');return false;
    }
    var cart_list =new Object;
    $('.cart_list tr').each(function () {
		var obj = $(this);
        var product = {};
        var goods_index=obj.find('.goodsn').attr('index');
		product.goods_index = goods_index;
		product.goods_name = obj.children(":first").text();
		product.goods_sn = obj.find('.goodsn').text();//编码
		product.goods_num = obj.find('#goods_type_'+goods_index).val();
		product.market_price = obj.find('td').eq(2).text();
		product.attr_price = obj.find('td').eq(3).text();
		product.goods_attr = obj.find('td').eq(4).text();
		product.goods_stock = obj.find('#goods_stock_'+goods_index).val();
		cart_list[goods_index] = product;
    });
    if(!cart_list){
         showMessage('请先选择商品',2000,true,'bounceInUp-hastrans','bounceOutDown-hastrans');return false;
    }
    
    var query= new Object();
    query.goods_info=goods_info;
    query.uid=$('#user_id').val();
    query.username=$('.js-user_nickname').text();
    query.total_price=$('#all_money').text();
    query.goods_table=JSON.stringify(cart_list);
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/guadan",
        data: query,
        dataType: "JSON",
        success: function(ret){
            if(ret.status == 1){
                clear_form();
                var num=$('.js-cashier_cart_list tr').length;
                var new_num=num+1;
                if(new_num%2==0){
                    var html='<tr class="active_bg_tr">';
                }else{
                    var html='<tr>';
                }
                var vo=ret.data;     
				html+='<td>'+new_num+'</td>'+
						'<td>'+vo.username+'</td>'+
						'<td>￥'+vo.total_price+'</td>'+
						'<td>'+vo.addtime+'</td>'+
						'<td class="delSpan1">'+
						'<a href="#" onclick="tidan('+vo.id+',this)" class="cart_use">提单</a>'+
						'<a href="#" onclick="del_guadan('+vo.id+',this)" class="cart_del">删除</a>'+
						'</td>'+
						'</tr>';
                $('.js-cashier_cart_list').append(html);
                closeall();
            }else{
                showtoast(ret.info);
            }
        }
    });
}
//提单
function tidan(id,obj){
    if(!id){showtoast('参数错误');return false;}
    var query= new Object();
    query.id=id;
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/tidan",
        data: query,
        dataType: "JSON",
        success: function(ret){
            if(ret.status == 1){
                $(obj).parent().parent().remove();
                sort_guadan_list();
                clear_form();
                if(ret.data.uid>0){
                    search_member(ret.data.uid)
                }
                var cart_list =ret.data.goods_table;
                for (var i in cart_list) {
    			    addtrtotable(cart_list[i]);
    			}
                $('#goods_info').val(ret.data.goods_info);
                total_price();
            }else{
                showtoast(ret.info);
            }
        }
    });
}
//删除挂单
function del_guadan(id,obj){
    if(!id){showtoast('参数错误');return false;}
    var query= new Object();
    query.id=id;
    $(obj).parent().parent().remove();
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/del_guadan",
        data: query,
        dataType: "JSON",
        success: function(ret){
            if(ret.status == 1){                
                sort_guadan_list();
            }else{
                showtoast(ret.info);
            }
        }
    });
}
//重置挂单排序及样式
function sort_guadan_list(){
    var num=$('.js-cashier_cart_list tr').length;
    if(num==0)return false;
    $(".js-cashier_cart_list tr").each(function(index, obj){
        var index_num=index+1;
        $(obj).children(":first").text(index_num);
        if(index_num%2==0){
            if(!$(obj).hasClass("active_bg_tr")){
                $(obj).addClass("active_bg_tr");
            }
        }else{
            if($(obj).hasClass("active_bg_tr")){
                $(obj).removeClass("active_bg_tr");
            }
        }
    })
}
//会员搜索
function search_member(uid){
    var query= new Object();
    if(uid){
        query.uid=uid;        
    }else{
        var card_no=$('#user_card_no').val();
        if(!card_no || card_no.length<6){
             showtoast('输入手机号或扫码录入会员');return false;
        }
        query.card_no=card_no;
    }    
    unset_userinfo();
    $.ajax({
        type: "POST",
        url: APP + "Shop/Cashier/search_member",
        data: query,
        dataType: "JSON",
        success: function(ret){
            if(ret.status == 1){
                var vo=ret.data;
                var is_update=0;
                if(vo.uid)$('#user_id').val(vo.uid);
                if(vo.nickname)$('.js-user_nickname').text(vo.nickname);
                if(vo.rankname)$('.js-user_degree').text(vo.rankname);
                if(vo.money)$('.js-user_cash').text(vo.money);
                if(vo.usepoints)$('.js-user_point').text(vo.usepoints);
                if(vo.header_img)$('.js-user_avatar').attr('src',vo.header_img);
                if(vo.user_discount){$('.js-user_discount').text(vo.user_discount);is_update=1;}     
                
                if(vo.huodong) $('.js-user_huodong').text(vo.huodong);
                if(vo.huodongnum) {$('#huodongnum').val(vo.huodongnum);if(is_update==0)total_price();}
                if(vo.huodongmin) $('#huodongmin').val(vo.huodongmin);
                
                if(is_update)updategoodsprice();
                closeall();
                $('#user_card_no').val('');
                $('#yuepay').addClass('disabled');
            }else{
                showtoast(ret.info);
            }
        }
    });
}
function updategoodsprice(){
    var uid=parseInt($('#user_id').val());if(isNaN(uid))uid=0;
    if(!uid)return false;
    var yingshou=parseFloat($('#yingshou').text());if(isNaN(yingshou))yingshou=0;
    if(yingshou<=0)return false;
    
    var zhekou=$('.js-user_discount').text(); 
    if(zhekou.indexOf('折')==-1)return false;
    zhekou=parseFloat(zhekou);
    var cart_list =new Object;//获取商品列表
    $('.cart_list tr').each(function () {
		var obj = $(this);
        var yuanjia=parseFloat(obj.find('td').eq(2).text());
        var xianjia=formatmoney(yuanjia*zhekou/10);
        obj.find('td').eq(3).text(xianjia);
    });
    total_price();
}
//计算实收找零
function shishoucount(){
    var shishou=parseFloat($('.ssh').val());
    if(shishou==0 || isNaN(shishou))return false;
    var yingshou=parseFloat($('#yingshou').text());
    if(yingshou==0 || isNaN(yingshou))return false;
    var zhaoling=formatmoney(shishou-yingshou);
    if(zhaoling>0){
        $('#zhaoling').text(zhaoling);
    }return false;
    
}



////////////////新加

//客服划动部分
$(function() {
	$("#contactusdiyou").hover(function() {
		$('#contactusdiyou').animate({right:'0'},300); 
	}, function() {
		$('#contactusdiyou').animate({right:'-320px'},300,function(){});
	});
});
$(function() {
	$("#condiyou").hover(function() {
		$('#condiyou').animate({right:'0'},300); 
	}, function() {
		$('#condiyou').animate({right:'-320px'},300,function(){});
	});
});

//初始化到付时间/余额选择
function init_daofu(){    
    $("#add_time").click(function(event){
        event.stopPropagation();
        $('.dropdown-menu').show();
        $('#new_id').val('1');
    });   
    $('.datetime-hours ul li').click(function(){
        $(this).addClass("active").siblings().removeClass("active");
        var time = $(this).html();
        var new_id = $('#new_id').val();
        if(new_id == 1){
            $('#add_time').val(time);
        }
        $('.dropdown-menu').hide();
    });
    $(document).click(function(){
        $(".dropdown-menu").hide();
    });
    $(".dropdown-menu").click(function(event){
        event.stopPropagation();
    });
    //初始化余额选择
    $('#df_usermoney').find('.radiobox').unbind('click');
    $('#df_usermoney').find('.radiobox').click(function(){
	  	if($(this).hasClass('daixuan')){// 选中状态
			$(this).removeClass("daixuan").addClass("xuanzhong");
	  	}else{// 取消选中状态
		  	$(this).removeClass("xuanzhong").removeClass("disabled").addClass("daixuan"); 
	  	}
	})
}

//清空表单
function clear_form(){
    var defaulttr='<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>';
    product_list = [];
    $('#serarch_sn').val('');$('#search_keywords').val('');
    $('#num').val('');
    $('#goods_info').val('');quan
    $('#usermoney').val('');
    $('.cart_list').html(defaulttr+defaulttr+defaulttr+defaulttr+defaulttr);$('.cart_list').attr('data-null',1);
    $('#all_money').text('0');$('#yingshou').text('0');
    $('#user_card_no').val('');
    $('#pay_password').val('');
    $('#usejifen').text(0);$('.ssh').val('');$('#zhaoling').text(0);$('#discount_text').text('');
    var uid=$('#user_id').val();
    if(uid){$('.foodsKinds').html('');$('.pages').html('');}
    $('#printArea').html('');$('#xpoint').val('');$('#ypoint').val('');$('.showlocation_xpointypoint').html('');
    unset_userinfo();
}

//重置会员信息
function unset_userinfo(){
    $('#user_id').val('');
    $('.js-user_nickname').text('游客');
    $('.js-user_degree').text('默认等级');
    $('.js-user_point').text('0');
    $('.js-user_cash').text('0.00');
    $('.js-user_avatar').attr('src',DEFAULT_USER_HEADERIMG);
    $('.js-user_discount').text('无');
    $('.js-user_huodong').text('无');$('#huodongnum').val(0);$('#huodongmin').val(0);
    
    $('#cash_id').val(0);$('#cash_name').val('');
    $('#cash_jifen').val(0);$('#cash_jifen_text').val('');$('#cash_type').val(0);$('#cash_discount').val(0);$('#cash_min').val(0);
    $('#cash_youhuiquan').attr('title','使用优惠券');$('#cash_youhuiquan').val('');$('.quan').html('');
    $('.border').html("&#xe656;");$("#icontype").val(0);
    $('#yuepay').removeClass('disabled');
    
    $('#user_address').hide();$('#user_add_sel').html('');$('#add_name').val('');$('#add_mobile').val('');$('#add_address').val('');$('#add_time').val('');
    $('#df_usermoney').hide();
}
//关闭所有窗口
function closeall(){
    $('.back1').hide();$('.chooseGoods').hide();
    $('.back2').hide();$('.jiesuan').hide();
    $('.back3').hide();$('.pay_Wait').hide();
    $('.back4').hide();$('.zf_success').hide();
    $('.back5').hide();
    $('.back10').hide();$('.attrbox').hide();
    $('.bg3').hide();$('.sale').hide();    
	$('.bg2').hide();$('.give_up').hide();
    $('.zhezhao').hide();$('.user_card').hide();
	$('.zhezhao1').hide();$('.peisongbox').hide();
	$('.zhezhao2').hide();$('.tuihuo').hide();
    $('body').css('overflow','');
}