12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>测试用页面</title>
- <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
- <script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
- <style>
- div, a {
- font-size: 60px;
- }
- </style>
- </head>
- <body>
- <div>
- <a onclick="getMsgByWX()">获取微信数据</a>
- </div>
- <br>
- <div>
- <a onclick="getMsgByWB()">获取微博数据</a>
- </div>
- <script>
- function getMsgByWX() {
- }
- function getMsgByWB() {
- }
- (function() {
- if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) {
- var ua = navigator.userAgent.toLowerCase() , url = "" , type = 0;
- if (ua.match(/MicroMessenger/i) == "micromessenger") {
- alert("微信浏览器中打开");
- type = 0;
- url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
- +"appid=wx749c84daac654e1e&"
- +"redirect_uri=http://wx.ttkuaiban.com/minigame&"
- +"response_type=code&"
- +"scope=snsapi_base&"
- +"state=STATE#wechat_redirect";
- //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx749c84daac654e1e&redirect_uri=wx.ttkuaiban.com&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect
- }
- if (ua.match(/WeiBo/i) == "weibo") {
- alert("在新浪微博客户端打开");
- type = 1;
- url = "https://api.weibo.cn/oauth2/authorize?"
- +"client_id=2141531565&"
- +"display=mobile&"
- +"response_type=code&"
- +"redirect_uri=code&"
- +"scope=snsapi_base";
- }
- var URLParams = new Array();
- var params = document.location.search.substr(1).split('&');
- for (i=0; i < params.length ; i++){
- var aParam = params[i].split('=');
- URLParams[aParam[0]] = aParam[1];
- }
- if(URLParams['code']){
- var code = URLParams['code'];
- $.post("https://http://118.190.47.230/minigame/user/weiXinLogin.do",{
- code:code,
- type:type
- },function(result){
- console.log(result)
- });
- }else{
- window.location.href = url;
- }
-
- /* $.get(url ,function(data,status){
- console.log("Data: " + data + "nStatus: " + status);
- $.post("demo_ajax_gethint.html",{suggest:txt},function(result){
- $("span").html(result);
- });
- }); */
- }
- })()
- </script>
- </body>
- </html>
|