<?php
require_once("../check.php");
require_once("../../config.php");
$usersql = "select * from dunling_user where username='$username'";
$userery = mysql_query($usersql,$config);
$user = mysql_fetch_array($userery);

$minpaysql = "select * from dunling_config where id='1'";
$minpayery = mysql_query($minpaysql,$config);
$pay = mysql_fetch_array($minpayery);
$conminpay = $pay['minpay'];


?>
<!DOCTYPE HTML>
<html>
<head>
<title>我要提现</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="../js/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="../style/template.css" />
<style>
input.text{
    width: 300px;height:30px;
    border:1px solid #D5D5D5;
}
.form{
    width:300px;
    height:35px;
    
}

</style>
</head>
<body>
<script>
$(function(){

    
    
$("#money").keyup(function(){
    var money = $(this).val();
    var is = isNaN(money);
    if(is){
        $("#money").val('');
    }



});

    $("#form").click(function(){
    var pay1 = $("#pay1").text();  
    var pay2 = $("#pay2").text();  
    var pay3 = $("#pay3").text();    
    
    if(pay1=="" || pay2=="" || pay3==""){
    $(".ts").html('<span style="color:red">您未完整设置收款资料,请到"<a href="ziliao.php">我的资料</a>"中进行设置！</span>');
    return false;
    }
    
    var money = $("#money").val();
    
    if(money=="" || money<="0"){
    $(".ts").html('<span style="color:red">请输入您的提现的金额</span>');
    return false; 
    }
    var yy = $("#yy").val();
    if(money*1000000>yy*1000000){
        $(".ts").html('<span style="color:red">亲,您的余额没这么多吧？</span>');
        setTimeout(function(){
        $(".ts").text(''); 
            
        },3000);
        return false;
    }
    $.post("php/pay.php",{
        money:money
    },function(a,b){
      if(a=="ok"){
        setTimeout(function(){
         location.href='pay.php';
        },1200);
        $(".ts").html('<span style="color:red">已提现,请等待支付!</span>');
        $("#form").attr("disabled",true);
      }
      if(a=="minpay"){
        $(".ts").html('<span style="color:red">你的提现金额不足系统最小提现额度!</span>');
        return false;
      }
        
    });
    
        
    });

   
});
</script>


<div id="table">
<div class="W100">我的余额:</div><div class="W350 yyxx"><?php echo $user['money'];?><input id="yy" type="hidden" value="<?php echo $user['money'];?>"/></div>
</div>

<div id="table">
<div class="W100">最小提现:</div><div class="W350 yyxx"><?php echo $conminpay;?></div>
</div>

<div id="table">
<div class="W100">收款方式:</div><div class="W350" id="pay1"><?php echo $user['pay1'];?></div>
</div>

<div id="table">
<div class="W100">收款姓名:</div><div class="W350" id="pay3"><?php echo $user['pay3'];?></div>
</div>

<div id="table">
<div class="W100">收款账号:</div><div class="W350" id="pay2"><?php echo $user['pay2'];?></div>
</div>

<div id="table">
<div class="W100">提现金额:</div><div class="W350"><input class="text" type="text" id="money"  /></div>
</div>


<div id="table">
<div class="W100"> </div><div class="W350"><input class="form" type="button" id="form" value="提现" /></div>
</div>
<div id="table">
<div class="W100"> </div><div class="W350 ts"></div>
</div>




</body>
</html>