<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
    <style type="text/css">
        .login-button { /* 按钮美化 */
            width: 542px; /* 宽度 */
            height: 80px; /* 高度 */
            border-width: 0px; /* 边框宽度 */
            border-radius: 3px; /* 边框半径 */
            background: #1E90FF; /* 背景颜色 */
            cursor: pointer; /* 鼠标移入按钮范围时出现手势 */
            outline: none; /* 不显示轮廓线 */
            font-family: Microsoft YaHei; /* 设置字体 */
            color: white; /* 字体颜色 */
            font-size: 34px; /* 字体大小 */
        }
        .login-button:hover { /* 鼠标移入按钮范围时改变颜色 */
            background: #5599FF;
        }
    </style>
    <meta charset="UTF-8">
    <meta name="x5-orientation" content="portrait">
    <link rel="stylesheet" href="/wxpay/css/weui.min.css">
    <title>微信公众号支付测试</title>
    <script type="text/javascript" src="${ctx}/scripts/jquery/jquery-1.9.1.min.js"></script>
</head>
<body>
<input type="hidden" id="orderNo" value="${orderNo}">
<input type="hidden" id="payURL" value="${payURL}">
<input type="hidden" value="${ctx}" id="contextPath" />
<div class="container" id="container">
    <input id="div1" class="login-button" type="button" value="获取openid" onclick="getAuthUrl('${orderNo}')"/>
    <br/>
    <br/>
    <br/>
    <br/>
    <input id="div2" class="login-button" value="立即支付" onclick="payOrder()"/>

    订单号:<input name="orderNo" value="${orderNo}">
    <form id="unifiedOrderTest" name="form" action="${ctx}/wechat/pay/unifiedOrderTest" method="POST">
        <input type="hidden" name="orderNo" value="${orderNo}">
    </form>
    <br/>
    <br/>
    <br/>
    <br/>
    <form id="refundOrder" name="form" action="${ctx}/wechat/pay/refundOrder" method="POST">
        <input name="orderNo" placeholder="输出退款单号" style="width: 542px;height: 80px;"/>
        <br/>
        <input id="div3" class="login-button" value="退款" onclick="refundOrder()"/>
    </form>
    <%--<a href="${payURL}" class="weui-btn weui-btn_primary" style="font-size:40px; 100px;">
    	立即支付
    </a>--%>
    <%--<a href="http://wxpay.pes-soft.com/wxpay/m/weChat/refund" class="weui-btn weui-btn_primary" style="font-size:40px; 100px;">
    	申请退款
    </a>--%>
</div>

<script>
    function getAuthUrl(orderNo) {
        $.ajax({
            type: "post",
            url: $("#contextPath").val()+ "/wechat/pay/authUrlTest",
            data: {
                orderNo: orderNo
            },
            success: function(data){
                if(data.code== 200){
                    window.location.href = data.data;
                }else{
                    layer.msg(data.msg);
                }
            },
            error: function(){
            }
        });
    }

    function payOrder() {
        $("#unifiedOrderTest").submit();
    }

    function refundOrder() {
        $("#refundOrder").submit();
    }
</script>
</body>
</html>