<?php
require_once("../check.php");
require_once("../../config.php");
$systemsql = "select * from dunling_config where id='1'";
$sysery = mysql_query($systemsql,$config);
$con = mysql_fetch_array($sysery);
?>
<!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>
<script>
$(function(){
    $.get("../core/fangshi.php",function(rand,su){
     if(rand=="1"){
        $("#zhongjiangfangshi").find("option[value='1']").attr("selected",true);
        $(".h1").show();
        return false;
     }
     if(rand=="0")
        $("#zhongjiangfangshi").find("option[value='0']").attr("selected",true);
        $(".h0").show();
        return false;
    });
    
    $("#zhongjiangfangshi").change(function(){
        
        var zhi = $(this).val();
        if(zhi=="0"){
        $(".h0").show();
        $(".h1").hide();
        }
        if(zhi=="1"){
        $(".h1").show();
        $(".h0").hide();
        }
        
        
    });
    
    
    
    $("#form").click(function(){
        var m = $("#m").val();
        var j = $("#j").val();
        var zhongjiangfangshi = $("#zhongjiangfangshi").val();
        var minmoney = $("#minmoney").val();
        var maxmoney = $("#maxmoney").val();
        var gudingmoney = $("#gudingmoney").val();
        
       
        if(zhongjiangfangshi=="0"){
        if(gudingmoney==""){
        alert('请输入中奖的固定金额!');
        return false;
        }
        if(gudingmoney<="0"){
        alert('请输入大于0的数值!');
        return false;
        }
        }
        
        if(zhongjiangfangshi=="1"){
        if(minmoney=="" || maxmoney==""){
        alert('请输入随机值中的最小值与最大值!');
        return false;
        }
        if(minmoney*1000000 > maxmoney*1000000){
        alert('最小数值不能大于最大数值!');
        return false;
        }
        if(minmoney <= "0" || maxmoney <= "0"){
        alert('数值不能小于0!');
        return false;
        }
        }
        
        
        if(m==""){
        alert('请输入每次开启宝箱消耗的积分!');
        return false;
        }
        
        if(j==""){
        alert('请输入宝箱的中奖机率!');
        return false;
        }

        $.post("../core/baohe.php",{
        m:m,
        j:j,
        zhongjiangfangshi:zhongjiangfangshi,
        minmoney:minmoney,
        maxmoney:maxmoney,
        gudingmoney:gudingmoney
        },function(ook,bad){
        if(ook=="ok"){
            alert('保存成功!');
            return false;
        }else{
            alert(ook);
            alert('保存出错!');
            return false;
        }
        });
        
        
        
    });
    
    
});

</script>
<body>
<style>
#forms input{
    margin-top:5px;
    width:1000px;
    min-height:40px;
    max-height:120px;
    height:150px;
    display: table;
    line-height:40px;
    text-align:right;
}

input.form{
    margin-top:5px;
    height:30px;
    line-height:30px;
    width:100px;
    float:left;
    color: #FFFFFF;
    font-size:16px; 
    background-color:#08246B;
    border:1px solid #08246B;
    border-radius:5px;
    box-shadow:0px 0px 5px 5px #C2C2C2;   
}
#table{
    width:auto;
    width:100%;
    height:auto;
    min-height: 45px;
    display: table;
    text-align:center;
    color: #505050;
    font-size:14px;
}
#table:hover{
    background-color: #DDEEFF;

}
#table .W100{
    width:100px;
    height:40px;
    line-height:40px;
    text-align:center;
    float:left;
}

#table .W150{
    width:150px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}

#table .W200{
    width:200px;
    height:40px;
    line-height:40px;
    text-align:center;
    float:left;
}

#table .W250{
    width:250px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}
#table .W300{
    width:300px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}
#table .W350{
    width:350px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}

#table .W400{
    width:400px;
    height:40px;
    line-height:40px;
    text-align:left;
    float:left;
}

input.text{
    width:380px;
    height:30px;
    line-height:30px;
}
input.min{
    width:125px;
    height:30px;
    line-height:30px;
    text-align:center;
}
input.max{
    width:125px;
    height:30px;
    line-height:30px;
    text-align:center;
}
select{
    width:385px;
    height:30px;
    line-height:30px;
    font-size:16px;
}
.h0,.h1{
    display:none;
}

</style>
<div id="table">
<div class="W100">每次消耗积分:</div>
<div class="W400"><input type="text" id="m" value="<?php echo $con['m'];?>" class="text" /></div><div class="W200" style="text-align: left;">每次开启宝箱扣除的积分</div>
</div>

<div id="table">
<div class="W100">宝箱中奖机率:</div>
<div class="W400"><input type="text" id="j" value="<?php echo $con['j'];?>" class="text" /></div><div class="W200" style="text-align: left;">例:中奖机率50%则写50</div>
</div>

<div id="table">
<div class="W100">中奖方式:</div><div class="W400"><select id="zhongjiangfangshi"><option value="0">固定金额</option><option value="1">随机金额</option></select></div>
</div>

<div class="h0">
<div id="table" >
<div class="W100">固定金额:</div><div class="W150"><input type="text" id="gudingmoney" value="<?php echo $con['gudingmoney']*100;?>" class="max" /></div><div class="W200" style="text-align: left;">单位:分&nbsp;(如1元则填写100)</div>
</div></div>

<div class="h1">
<div id="table" class="h1">
<div class="W100">随机金额:</div><div class="W300"><input type="text" id="minmoney" value="<?php echo $con['minmoney']*100;?>" class="min" />&nbsp;-&nbsp;<input type="text" id="maxmoney" value="<?php echo $con['maxmoney']*100;?>" class="min" /></div><div class="W400" style="text-align: left;">最小数和最大数之间的随机数,单位(分),如1元则填写100</div>
</div></div>


<div id="table">
<div class="W100"> </div><div class="W400"><input class="form" id="form" type="button" value="保存设置" /></div>
</div>


</body>