index.html 1.44 KB
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script type="text/javascript" src="jquery.2.1.3.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        (function(){
            function getQuery(name) {
                var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
                if (result == null || result.length < 1)
                    return undefined;
                return decodeURIComponent(result[1]);
            }

            var code = getQuery('code');
            var ua   = window.navigator.userAgent.toLowerCase();

            if (code && ua.match(/MicroMessenger/i) == 'micromessenger') {
                console.log(code);
                window.location.href = 'http://dev.bigbang.gaoxiaobang.com/dist'+ window.location.search;
            } else {
                $.ajax({
                    type: 'GET',
                    url: 'http://dev.bigbang.gaoxiaobang.com/wx-qa/getRequestCodeUrl.htm?url=http://dev.bigbang.gaoxiaobang.com/dist/',
                    timeout: 15000,
                    success: function(data) {
                        console.log(data);
                        window.location.href = data;
                    },
                    error: function(xhr, type) {
                        alert('Ajax error!')
                    }
                })
            }
        })();
    </script>
</body>
</html>