//添加提现银行
function add_banks(){
	var bankcode = $("#bankcode").val();
	if(isNaN(bankcode)){$.showErr('请填写正确的银行账号',1,'hc');return false;}
	var query = new Object;
	query = $("form[name='add_bank']").serialize();
	$.ajax({
		type:"POST",
		url:APP+"Mobile/Withdrawals/add_bank",
		data:query,
		success:function(data){
			if(data.status==1){
				$.showSuccess(data.info,0,'hc');
				window.location.href=data.url;
			}else{
				$.showErr(data.info,0,'hc');
			}
		}
	});
}
//无密码提现
function go_withdrawals(){
	//jxr 18.09.06 start
	var tx_type=$("#myselect").val();
	if(isNaN(tx_type) || !tx_type){$.showErr('请选择提现方式',0,'hc');return false;}
	//jxr 18.09.06 end
	var comm_money = $("#comm_money").val();
	var param = comm_money.match("^[0-9]*$");
	if(comm_money<=0 || isNaN(comm_money) || !param){$.showErr('请填写正确的金额',0,'hc');return false;}
	//jxr 18.09.06 start
	var min_money=$("#min_money").val();
	if(comm_money<min_money){$.showErr('提现金额应不小于最低提现金额',0,'hc');return false;}
	if(tx_type && tx_type >= 1 && tx_type != 2){
		var tx_code = $("#tx_code").val();
		if(isNaN(tx_code) || !tx_code){$.showErr('请填写提现账号',0,'hc');return false;}
		if(tx_type=="4"){	//银行卡
			var bankname = $("#bankname").val();
			if(isNaN(bankname) || !bankname){$.showErr('请填写提现银行',0,'hc');return false;}
			var bankkai = $("#bankkai").val();
			if(isNaN(bankkai) || !bankkai){$.showErr('请填写开户行',0,'hc');return false;}
		}
	}
	//jxr 18.09.06 end
	var is_code = $('#is_code').val();
	if(is_code == 1){
		var mobilecode = $("#mobilecode").val();
		if(!mobilecode){$.showErr('请填写短信验证码',0,'hc');return false;}
	}
	var query = new Object;
	query = $("form[name='withdrawals']").serialize();
	// console.log(query);return;
	$.ajax({
		type:"POST",
		url:APP+"Mobile/Withdrawals/go_withdrawals",
		data:query,
		success:function(data){
			if(data.status==1){
				$.showSuccess(data.info,0,'hc');
				window.location.href=data.url;
			}else{
				$.showErr(data.info,0,'hc');
			}
		}
	});
}
//密码提现
function gop_withdrawals(){
	var real_name=$("#real_name").html();
	if(!real_name){$.showErr('请设置真实姓名',0,'hc');window.location.href=window.location.href=APP + "Mobile/UserInfo/head_portrait";return false;}
	//jxr 18.09.06 start
	var tx_type=$("#myselect").val();
	if(isNaN(tx_type) || !tx_type){$.showErr('请选择提现方式',0,'hc');return false;}
	//jxr 18.09.06 end
	var comm_money = $("#comm_money").val();
	var param = comm_money.match("^[0-9]*$");
	if(comm_money<=0 || isNaN(comm_money) || !param){$.showErr('请填写正确的金额',0,'hc');return false;}
	//jxr 18.09.06 start
	var min_money=$("#min_money").val();
	if(parseFloat(comm_money) < parseFloat(min_money)){$.showErr('1提现金额应不小于最低提现金额',0,'hc');return false;}
	if(tx_type && tx_type >= 1 && tx_type != 2){
		var tx_code = $("#tx_code").val();
		if(isNaN(tx_code) || !tx_code){$.showErr('请填写提现账号',0,'hc');return false;}
		if(tx_type=="4"){	//银行卡
			var bankname = $("#bankname").val();
			if(isNaN(bankname) || !bankname){$.showErr('请填写提现银行',0,'hc');return false;}
			var bankkai = $("#bankkai").val();
			if(isNaN(bankkai) || !bankkai){$.showErr('请填写开户行',0,'hc');return false;}
		}
	}
	//jxr 18.09.06 end
	var is_code = $('#is_code').val();
	if(is_code == 1){
		var mobilecode = $("#mobilecode").val();
		if(!mobilecode){$.showErr('请填写短信验证码',0,'hc');return false;}
	}
	var query = new Object;
	var paypassword=$("#paypassword").val();
	if(paypassword != ''){
		query = $("form[name='withdrawals']").serialize();
		// console.log(query);return;
		$.ajax({
			type:"POST",
			url:APP+"Mobile/Withdrawals/go_withdrawals",
			data:query,
			success:function(data){
				if(data.status==1){//申请成功
					$.showSuccess(data.info,0,'hc');
					window.location.href=data.url;
				}else if(data.status==2){//设置密码
					$.showErr(data.info,0,'hc');
					window.location.href=data.url;
				}else if(data.status==3){//密码错误
					$.showErr(data.info,1,'hc');
					$("#paypassword").val('');
					gop_withdrawals();
				}else{//其他错误
					$.showErr(data.info,0,'hc');
					$("#paypassword").val('');
				}
			}
		});
    }else{
		$("#sub_order").next().next().fadeIn();
		$("#sub_order").next().animate({"bottom": 0});
        
    }
}
var InterValObj; //timer变量，控制时间
var curCount;//当前剩余秒数
function sendMessage() {
	var ktx_money = parseFloat($("#ktx_money").html());
	if(ktx_money <= 0){
		showtoast("抱歉，您还没有金额可提现");
		var body = $('body').css("position");
		if(body=='relative'){
			$('body').css("position","");
		}
		return false;
	}
	var comm_money = $("#comm_money").val();
	var param = comm_money.match("^[0-9]*$");
	if(comm_money == ''){showtoast("请填写金额");
		var body = $('body').css("position");
		if(body=='relative'){
			$('body').css("position","");
		}
		return false;
	}
	if(comm_money<=0 || isNaN(comm_money) || !param){showtoast("请填写正确的金额");
		var body = $('body').css("position");
		if(body=='relative'){
			$('body').css("position","");
		}
		return false;
	}
	var min_money = $("#min_money").val();
	if(parseFloat(min_money)>0 && parseFloat(min_money)>parseFloat(comm_money)){
		showtoast("不能低于最低提现金额"+min_money);
		var body = $('body').css("position");
		if(body=='relative'){
			$('body').css("position","");
		}
		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%"});
}