sunyadv hace 5 años
padre
commit
6e4ecef85a
Se han modificado 1 ficheros con 25 adiciones y 24 borrados
  1. 25 24
      src/main/resources/templates/index.html

+ 25 - 24
src/main/resources/templates/index.html

@@ -27,35 +27,36 @@
     }
 
     (function() {
-        if (browser.versions.mobile) {//判断是否是移动设备打开。browser代码在下面
-            var ua = navigator.userAgent.toLowerCase();//获取判断用的对象
-            if (ua.match(/MicroMessenger/i) == "micromessenger") {
+        if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) {
+            var ua = navigator.userAgent.toLowerCase() , url = "";
+            // if (ua.match(/MicroMessenger/i) == "micromessenger") {
                 alert("微信浏览器中打开");
-                var loginInfo = {
-                    "appid": 'wx749c84daac654e1e',
-                    "redirect_uri": 'wx.ttkuaiban.com',
-                    "response_type": 'code',
-                    "scope": "snsapi_base"
-                };
-                window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?"+ loginInfo +"&state=STATE#wechat_redirect";
-            }
+                url = "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";
+                //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("在新浪微博客户端打开");
-                $.get("demo_ajax_load.txt", function(result){
-                    $("div").html(result);
-                });
-
+                url = "https://api.weibo.cn/oauth2/authorize?"
+                    +"client_id=2141531565&"
+                    +"display=mobile&"
+                    +"response_type=code&"
+                    +"redirect_uri=code&"
+                    +"scope=snsapi_base";
             }
-            // if (ua.match(/QQ/i) == "qq") {
-            //     alert("在QQ空间打开");
-            // }
-            // if (browser.versions.ios) {
-            //     alert("在IOS中打开");
-            // }
-            // if(browser.versions.android){
-            //     alert("在安卓浏览器打开");
-            // }
+
+            //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>