//添加提现银行
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+"Member/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 gop_withdrawals(){
	var money = $("#money").val();
	var param = money.match("^[0-9]*$");
	if(money<=0 || isNaN(money) || !param){$.showErr('请填写正确的金额',0,'hc');return false;}
	
	var is_code = $('#is_code').val();
	if(is_code == 1){
		var mobilecode = $("#mobilecode").val();
		if(!mobilecode){$.showErr('请填写短信验证码',0,'hc');return false;}
	}
	
	var html = '交易密码：<input type="password" name="paypassword" id="paypassword" class="ui-textbox" style="border: 1px solid #ddd;height: 26px;line-height: 26px;width: 200px;margin-left: 5px;"/>';
        $.weeboxs.open(html, {
            boxid: 'tui_box',
            contentType: 'text',
            showButton: true,
            showCancel: false,
            showOk: true,
            title: '输入交易密码',
            width: 250,
            type: 'hc',
            onopen: function () {
            }, onok: function () {
                var query = new Object;
                query.money=money;
                query.mobilecode=mobilecode;
                query.mobile=$("#mobile").val();
                query.paypassword=$("#paypassword").val();
				//alert(JSON.stringify(query));return false;
				$.ajax({
					type:"POST",
					url:APP+"Member/Withdrawals/go_withdrawals",
					data:query,
					success:function(data){
						if(data.status==1){
							$.showSuccess(data.info,1,'hc');
							$('#is_no').attr("disabled", "true");
							window.location.href=data.url;
						}else if(data.status==2){
							$.showErr(data.info,1,'hc');
							window.location.href=data.url;
						}else{
							$.showErr(data.info,1,'hc');
						}
					}
				});
            }
        });
}
//无密码提现
function go_withdrawals(){
	var money = $("#money").val();
	var param = money.match("^[0-9]*$");
	if(money<=0 || isNaN(money) || !param){$.showErr('请填写正确的金额',0,'hc');return false;}
	
	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();
	$.ajax({
		type:"POST",
		url:APP+"Member/Withdrawals/go_withdrawals",
		data:query,
		success:function(data){
			if(data.status==1){
				$.showSuccess(data.info,1,'hc');
				$('#is_no').attr("disabled", "true");
				window.location.href=data.url;
			}else if(data.status==2){
				$.showErr(data.info,1,'hc');
				window.location.href=data.url;
			}else{
				$.showErr(data.info,1,'hc');
			}
		}
	});
}
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 + "秒内输入验证码");
    }
}