<?php
require 'config.php';
if (empty($_POST)) $_POST = $_GET;  //如果为GET方式访问
$uid = $_POST['uid'];
$serverid = $_POST['serverid'];
$rechargeid = $_POST['rechargeid'];//礼包ID
//根据礼包计算出金额
$money = $libaoconfig[$rechargeid][0];
//拼接账号，格式为：分区ID-账号
$account = $serverid."-".$uid;
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>游戏赞助页面</title>
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
	<!--引入阿里字体图标-->
	<link rel="stylesheet" type="text/css" href="static/css/iconfont.css" />
	<!--引入jquery-weui框架-->
	<link rel="stylesheet" href="static/weui/css/weui.min.css">
	<link rel="stylesheet" href="static/weui/css/jquery-weui.min.css">
	<link rel="stylesheet" href="static/css/pay.css" type="text/css">
	<style>
	    .weui-cell{border-bottom: 1px solid #e5e5e5!important;}
	    .weui-cell:before{border-top:none!important;}
	</style>
</head>
<body class="center">
    <form action="<?php echo $payurl;?>" method="post">
        <div class="weui-pay" style="background: #fff;">
            <h1 class="weui-payselect-title">礼包金额</h1>
            <p class="weui-pay-num">￥<span id="money"><?php echo $money?></span>.00</p>
            <p class="weui-pay-info"><label class="label f-red b-red f16">充值账号 → 【<?php echo $uid?>】</label></p>
            <!--支付 star-->
			<div class="pay-box" style="margin-bottom:10px;">
				<div class="pay-box-cell">
					<li>
					<label>
					<img src="static/images/pay-zfb.jpg">
					<input name="paytype" value="1" type="radio" checked='true'>
					<span></span>
					</label> 
					</li>
					<li>
					<label>
					<img src="static/images/pay-wx.jpg">
					<input name="paytype" value="2" type="radio">
					<span></span>
					</label> 
					</li>
				</div>
			</div>
			<!--支付 end-->
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">充值礼包：</label></div>
                <div class="weui-cell__bd">
                  <select id="libao" class="weui-select">
                    <?php
                       foreach ($libaoconfig as $key=>$value) {
                           $selected="";
                            if($rechargeid==$key){
                                $selected = "selected";
                            }
                           echo "<option price='".$value[0]."' value='".$key."' ".$selected.">".$value[1]."(需".$value[0]."元)</option>";
                        }
                    ?>
                  </select>
                </div>
            </div>
            <div class="pay-div" style="margin-top:20px;">
				<!-- 使用param参数来存放礼包ID -->
				<input type='hidden' name='param' value ='<?php echo $rechargeid;?>'/>
                <input type='hidden' name='money' value ='<?php echo $money;?>'/>
                <input type='hidden' name='account' value ='<?php echo $account;?>'/>
				<input type='hidden' name='hidetitle' value ='true'/>
                <button type="submit" class="weui-btn weui-btn_primary">立即支付</button>
            </div>
        </div>
    </form>
</body>
</html>
<!--引入jquery-->
<script src="static/js/jquery.min.js" charset="utf-8"></script>
<script language="javascript">
$('#libao').on('change', function () {
    //获取选中的value值
	var value = $(this).val();
	$("input[name='param']").val(value);
	//获取礼包价格
    var price = $(this).find("option:selected").attr("price");
    $("#money").text(price);
    $("input[name='money']").val(price);
});
</script>