<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="https://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
</head>
<body>
<input type="hidden" value="${ctx}" id="contextPath"/>
</body>
<script>
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    }

    var code = GetQueryString('code');
    var state = GetQueryString('state');

    alert(code + ',' + state);
    $(document).ready(
        function () {
            $.ajax({
                type: "post",
                url: $("#contextPath").val() + "/super_service/wechat/pay/fetchOpenid1",
                data: {
                    orderNo: state,
                    code: code
                },
                success: function (data) {
                    if (data.code == 200) {
                        alert('success');
                        window.location.href = $("#contextPath").val() + "/super_service/wechat/pay/payIndex?orderNo=" + state;
                    } else {
                        layer.msg(data.msg);
                    }
                },
                error: function () {
                }
            });
        }
    );
</script>
</html>