function service_hx(){
	var service_no = $("#service_no").val();
	if(isNaN(service_no)){$.showErr('请填写正确的消费券验证码',1,'hc');return false;}
	var query = new Object;
	query.service_no = service_no;
	$.ajax({
		type:"POST",
		url:APP+"Mobile/ShopInfo/service_hx",
		data:query,
		success:function(data){
			if(data.status==1){
				$.showSuccess(data.info,3,'hc');
				$("#service_no").val('');
				// window.location.href=data.url;
			}else{
				$.showErr(data.info,3,'hc');
			}
		}
	});
	$('.snma').slideUp();
	$('.popmask').hide();
	$("body").css('overflow','');
}
function select_hx(){
	var service_no = $("#service_no").val();
	if(isNaN(service_no)){$.showErr('请填写正确的消费券验证码',3,'hc');return false;}
	var query = new Object;
	query.service_no = service_no;
	$.ajax({
		type:"POST",
		url:APP+"Mobile/ShopInfo/select_hx",
		data:query,
		success:function(data){
			// console.log(data.data);
			if(data.status==1){
				$("#user_name").html('订单号：'+data.data.order_sn);
				$("#name").html(data.data.name);
				$("#goods_sn").html(data.data.goods_sn);
				$("#num").html(data.data.num);
				$('.snma').slideDown();
				$('.popmask').show();
				$("body").css('overflow','hidden');
			}else{
				$.showErr(data.info,3,'hc');
			}
		}
	});
}
function popmask(){
	$('.snma').slideUp();
	$('.popmask').hide();
	$("body").css('overflow','');
}
	


var InterValObj; //timer变量，控制时间
var curCount;//当前剩余秒数
function sendMessage() {
	var money = $("#money").val();
	var param = money.match("^[0-9]*$");
	if(money == ''){$.showErr('请填写金额',0,'hc');return false;}
	if(money<=0 || isNaN(money) || !param){$.showErr('请填写正确的金额',0,'hc');return false;}
	var min_money = $("#min_money").val();
	if(parseFloat(min_money)>0 && parseFloat(min_money)>parseFloat(money)){
		$.showErr('不能低于最低提现金额'+min_money,0,'hc');return false;
	}
	
	var time = $("#true_time").val();
	var count = parseInt(time); //间隔函数，1秒执行
    curCount = count;
    var mobile=$('#mobile').val();
    var param="mobile=" + mobile + "&unique=" + 2+ "&type=" + 3;
    $.ajax({
        type: "POST",
        dataType: "JSON",
        url: APP+"Home/Ajax/sendsms",
        data:param,
        success:function (data){
			if(data.status==0){
				$.showErr(data.msg,0,'hc');
				return false;
			}else{
				$("#btnSendCode").attr("disabled", "true");
				$("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
				InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
			}
		}
	});
}
//timer处理函数
function SetRemainTime() {
    if (curCount == 0) {
        window.clearInterval(InterValObj);//停止计时器
        $("#btnSendCode").removeAttr("disabled");//启用按钮
        $("#btnSendCode").val("重新发送验证码");
    }else {
        curCount--;
        $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
    }
}
//关闭遮罩
$(function() {
	$("#areaMasks, #closeAreas").click(function() {
		var clos=$(this);
		clockAreas(clos);
	});
});
function clockAreas(obj) {
	$(obj).fadeOut();
	$(obj).prev().animate({"bottom": "-100%"});
}
function chaxun(){
	
	var card_sn = $('#card_sn').val();
	$.post(APP + "Mobile/ShopInfo/selectpack.html", {
	  card_sn: card_sn
	  //ser_id:ser_id
	}, function(data) {
			if(data.status == 1){
				$(".cxinfor").show();
				$("#tianjia").html(data.info);
			}else{
				$.showErr(data.info,0,'hc');return false;
			} 
		   
	});
	return false;
}
function chaxun_tc(){
	var card_sn = $('#card_sn').val();
	$.post(APP + "Mobile/ShopInfo/selectpack.html", {
	  card_sn: card_sn
	  //ser_id:ser_id
	}, function(data) {
		
			if(data.status == 1){
				$("#tc_select").show();
				$("#tc_select").html(data.data);
			}else{
				$.showErr(data.info,0,'hc');return false;
			} 
		   
	});
	return false;
}
function change_tc(value){
	$(".cxinfor").hide();
	if(value == 0){return false;}
	var card_sn = $('#card_sn').val();
	$.post(APP + "Mobile/ShopInfo/selectpack.html", {
	  card_sn:card_sn,
	  order_id: value
	  //ser_id:ser_id
	}, function(data) {
			if(data.status == 1){
				$(".cxinfor").show();
				$("#tianjia").html(data.info);
			}else{
				$.showErr(data.info,3,'hc');return false;
			} 
		   
	});
	return false;
}
function hx_submit(){
	var query= new Object();
	query = $("form[name='formadd']").serialize();
	paypassword = $("input[name='paypassword']").val();
	mobile = $("input[name='mobile']").val();
	if(!mobile){
		$.showErr('请填写卡号或手机号',3,'hc');return false;
	}
	if(!paypassword){
		$.showErr('请填写支付密码',3,'hc');return false;
	}
	$.ajax({
			type:"POST",
			url:APP+"Mobile/ShopInfo/sub_package",
			data:query,
			success:function(data){
				if(data.status==1){//申请成功
					$.showSuccess(data.info,3,'hc');
					window.location.reload();
				}else{//其他错误
					$.showErr(data.info,3,'hc');
					$("#paypassword").val('');
				}
			}
		});
}
function add(id){
      var wei_num = $('#wei_num'+id).val();
      var num = $('#num'+id).html();
      if(parseInt(num) >= parseInt(wei_num)){
			$.showErr('消费次数不能大于为消费次数',0,'hc');return false;
      }else{
		   var txt2 = parseInt(num) + 1;
			$('#num'+id).html(txt2);
			$('#sub_package_'+id).val(txt2);
	  }
    }
function jian(id){
	var wei_num = $('#wei_num'+id).val();
    var num = $('#num'+id).html();
	if(num != '0'){
		var txt2 = parseInt(num) - 1;
		$('#num'+id).html(txt2);
		$('#sub_package_'+id).val(txt2);
    }
}