<?php
include_once "./config.php";
$order_id=time().rand(1,9999);
$serverid = @$_GET['sid'];
$rolename = @$_GET['rnm'];
$roleid = @$_GET['rid'];
if(@$_POST['oper']=='clearBb'){
	$qu=$quarr[$_POST["qu"]];
	clearBag($qu['url'],array(
                            "roleId"=>@$_POST['roleid']
                        ));
}
?>



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>赞助</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<link rel="stylesheet" href="style/weui.css">
<link rel="stylesheet" href="style/weuix.css">
<script src='./static/js/jquery-2.1.4.min.js' type='text/javascript'></script>
<style>
.page-bg {
	max-width: 750px;
	margin: 0 auto;
}
.weui-cells {
	margin-top:0;
	border: 1px solid #eee;
	border-radius: 1em;
}
.bgc-b{
	background-color:#fff;
}

</style>
</head>
<body  class="page-bg">
<form id="pay_form" action="./submit.php" method='post'>
   <input  name="sign" value="1" id="sign" type="text" style="display:none">
   <input  name="version" value="1.0"  type="text" style="display:none">
   <input  name="customerid" value="<?php echo $uid; ?>" id="uid" type="text" style="display:none">
   <input  name="notifyurl" value="<?php echo $callback_url; ?>" id="callback_url" type="text" style="display:none">
   <input  name="returnurl" value="<?php echo $return_url; ?>" id="success_url" type="text" style="display:none">
   <input  name="sdorderno" id="sdorderno" value="<?php echo $order_id?>" type="text" style="display:none">
   <input  name="total_fee" id="amount1" type="text" style="display:none">
   <input  name="remark" value="" type="text" id="pay_note" style="display:none">
   <input  name="paytype" value="" type="text" id="pay_type"  style="display:none">
   <input  name="recommend"  value="" type="text" id="recommend"  style="display:none">
</form>
 
    <div class="weui-pay weui-cells_form">
		<div class="weui-cell none1  bgc-b">
            <div class="weui-cell__hd"><label class="weui-label">订单编号 :</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="order_id" value="<?php echo $order_id?>" type="text">
            </div>
        </div>
		<div class="weui-cell none1 bgc-b tc-div">
            <div class="weui-cell__hd"><label class="weui-label">选择区服:</label></div>
            <div class="weui-cell__bd">
                 <select id="qu" style="color: #777373;border: 1px solid #252925;width: 40%;border-radius: 6px;padding: 5px;"
                  <?php if($roleid){ echo "disabled='disabled'"; }?> >
					<?php 
					foreach ($quarr  as $key => $value) {
					    if($serverid == $value['serverID']){
					        echo "<option value='".$key."' selected='selected'>".$value["name"]." </option>";
					    }else{
					        echo "<option value='".$key."'>".$value["name"]." </option>";
					    }
                          
					}
	                ?>
				</select>
            </div>
        </div>
        <div class="weui-cell none1  bgc-b" style="display:<?php if(!$roleid){ echo "none"; }?>">
            <div class="weui-cell__hd"><label class="weui-label">角色ID :</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" name="$roleid" value="<?php echo $roleid?>" readonly="readonly" type="text">
            </div>
        </div>
		 <div class="weui-cell none1 bgc-b" style="display:<?php if($roleid){ echo "none"; }?>">
            <div class="weui-cell__hd"><label class="weui-label">角色名称 :</label></div>
            <div class="weui-cell__bd" >
                <input class="weui-input" style="height:120px" value="<?php echo $rolename; ?>" name="user_name" id="user_name" type="text" placeholder="请确保输入正确">
            </div>
        </div>
        <div class="weui-cell none1 bgc-b tc-div">
            <div class="weui-cell__hd"><label class="weui-label">选择档位:</label></div>
            <div class="weui-cell__bd">
                 <select id="tc" style="color: #777373;border: 1px solid #252925;width: 40%;border-radius: 6px;padding: 5px;">
					<?php 
					foreach ($goods as $w) {
                          echo "<option value='".$w["amount"]."'>".$w["name"]."</option>";
					}
	                ?>
				</select>
            </div>
        </div>
          <div class="weui-cells weui-cells_checkbox">
				<label class="weui-cell weui-check__label" for="x3">
                    <div class="weui-cell__hd">
                        <img src="/pay/logo_2.png">
                    </div>
                    <div class="weui-cell__bd">
                        <p>微信</p>
                    </div>
                    <div class="weui-cell__ft">
                        <input class="weui-check" name="pay_type" checked="checked"  value="wxpay" id="x3" type="radio">
                        <span class="weui-icon-checked"></span>
                    </div>
                </label>
                            <label class="weui-cell weui-check__label" for="x2">
                    <div class="weui-cell__hd">
                        <img src="/pay/logo_1.png">
                    </div>
                    <div class="weui-cell__bd">
                        <p>支付宝</p>
                    </div>
                    <div class="weui-cell__ft"> 
                        <input class="weui-check" name="pay_type" value="alipay"   id="x2" type="radio">
                        <span class="weui-icon-checked"></span>
                    </div>
                     </label>
                    </div>
        <div class="weui-pay-btn">
            <button type="submit" class="weui-btn weui-btn_primary" onclick="pay()" style="color: #18b4ed;
    border: 1px solid #18b4ed;background-color:initial;">立即支付</button>
        </div>
        <div class="weui-pay-btn">
            <a href="./reset.php"><button type="button" class="weui-btn weui-btn_primary" style="color: #18b4ed;
    border: 1px solid #18b4ed;background-color:initial;">修改密码</button></a>
        </div>
        <?php
        if($roleid){
            echo '
        <div class="weui-pay-btn">
            <button type="button" class="weui-btn weui-btn_primary" onclick="clearBb()" style="color: #fff;" >清理背包</button>
        </div>';
        }
        
        ?>
		 <div class="weui-pay-btn">
            <button style="color: #fff;
    border: 1px solid #dbd1d1;"  class="weui-btn weui-btn_primary" onclick="custom_close()" >关闭页面</button>
        </div>
    </div>
</div>
<div class="weui-footer weui-footer_fixed-bottom">
</div>
    <script type="text/javascript">
	

// 这个脚本是 ie6和ie7 通用的脚本
function custom_close() {
	if(confirm("您确定要关闭本页吗？")) {
		window.opener=null;
		window.open('','_self');
		window.close();
	} 
}
function welfare(){
	var name=$("input[name=user_name]").val();
	var recommend=$("#recommend1").val();
	if(!name) {
		alert("请输入角色UID！");
		return;
	}else{
		$.ajax({
			url:'./welfare.php?uid='+name+'&recommend='+recommend,
			type:'get',
			success:function(res){
				alert(res);
			}
		})
	}
}

$("#golb").click(function(){
    var name=$("input[name=user_name]").val();
	var qu=$("#qu").val();
    if(!qu) {
		alert("请选择区服！");
		return;
	}
	
	if(!name) {
		alert("请输入角色名称！");
		return;
	}
	var a=''+'<?php if($roleid){ echo $rolename; }?>';
	if(a){
        location.href="./lc.php?qu="+qu+"&rnm="+name+"&rid"+a
	}else{
        location.href="./lc.php?qu="+qu+"&rnm="+name
	}
	
})


function pay() {
	var name=$("input[name=user_name]").val();
	var money=$("#tc").val();
	var paytype=$("input[type='radio']:checked").val();
	var qu=$("#qu").val();
	
	if(!qu) {
		alert("请选择区服！");
		return;
	}
	
	if(!name) {
		alert("请输入角色名称！");
		return;
	}
	
	
	if(!money) {
		alert("请选择套餐！");
		return;
	}
	
	if(paytype == "") {
		alert("请选择支付方式！");
		return;
	}
	var recommend=$("#recommend1").val();
	if(!recommend){
		recommend='';
	}
	var a=''+'<?php if($roleid){ echo $rolename; }?>';
	if(a){
	$("#recommend").val(recommend);
	$("#pay_note").val(qu+"-sp-<?php echo $roleid?>-sp-"+a);
	$("#pay_type").val($("input[type='radio']:checked").val());
	$("#amount1").val(money);
	$("#pay_form").submit();
	}else{
	$("#recommend").val(recommend);
	$("#pay_note").val(qu+"-sp-"+name);
	$("#pay_type").val($("input[type='radio']:checked").val());
	$("#amount1").val(money);
	$("#pay_form").submit();
	}
}
function clearBb(){
    var qu=$("#qu").val();
	
	if(!qu) {
		alert("请选择区服！");
		return;
	}
    if(window.confirm("清理前请确认背包无贵重物品!清理后无法找回")){
    $.ajax({
	    type:'post',
	    url:'./index.php',
	    data:{
	        oper:'clearBb',roleid:'<?php echo $roleid?>',rolename:'<?php echo $rolename?>',serverid:'<?php echo $serverid?>',qu:qu
	    },
	    success:function(res){
	        alert(res)
	    }
	})
    }
}
</script>
</body>
</html>