|
@@ -2,43 +2,32 @@
|
|
|
<html>
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
+ <meta http-equiv="Access-Control-Allow-Origin" content="*" />
|
|
|
<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() {
|
|
|
- }
|
|
|
-
|
|
|
+ <script>
|
|
|
(function() {
|
|
|
+ //初始化用户信息数据
|
|
|
+ window.user_info = {
|
|
|
+ logo:'http://img5q.duitang.com/uploads/item/201502/25/20150225060808_wuANL.jpeg',//用户头像
|
|
|
+ nickname:'不羡鸳鸯',//用户昵称,
|
|
|
+ textmsg:'GOOD GOOD STUDY,DAY DAY UP'//寄语
|
|
|
+ };
|
|
|
+
|
|
|
+ var ua = navigator.userAgent.toLowerCase() , url = "" , type = 0;
|
|
|
if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) {
|
|
|
- var ua = navigator.userAgent.toLowerCase() , url = "" , type = 0;
|
|
|
if (ua.match(/MicroMessenger/i) == "micromessenger") {
|
|
|
+ console.log(123)
|
|
|
+ alert('123')
|
|
|
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&"
|
|
|
+ +"scope=snsapi_userinfo&"
|
|
|
+"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") {
|
|
@@ -48,35 +37,65 @@
|
|
|
+"client_id=2141531565&"
|
|
|
+"display=mobile&"
|
|
|
+"response_type=code&"
|
|
|
- +"redirect_uri=code&"
|
|
|
+ +"redirect_uri=http://wx.ttkuaiban.com/minigame&"
|
|
|
+"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);
|
|
|
- });
|
|
|
- }); */
|
|
|
- }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ var ua = navigator.userAgent.toLowerCase();
|
|
|
+ if (ua.match(/MicroMessenger/i) == "micromessenger") {
|
|
|
+ console.log(245)
|
|
|
+ alert('234')
|
|
|
+ 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_userinfo&"
|
|
|
+ +"state=STATE#wechat_redirect";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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'];
|
|
|
+ <!-- $.get("http://118.190.47.230/minigame/user/weiXinLogin",{ -->
|
|
|
+ <!-- code:code, -->
|
|
|
+ <!-- type:type -->
|
|
|
+ <!-- },function(result){ -->
|
|
|
+ <!-- console.log(result) -->
|
|
|
+ <!-- }); -->
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url:"http://118.190.47.230/minigame/user/weiXinLogin",
|
|
|
+ type:"POST",//请求方式
|
|
|
+ data:{"code":code,"type":type},
|
|
|
+ dataType:"json", //数据格式设置为jsonp
|
|
|
+ success:function (data) {//请求成功后调用的函数
|
|
|
+ alert("succ:"+data);
|
|
|
+ if(URLParams['act']=='hbshare'){
|
|
|
+ document.write('<h1>这里是海报页</h1>');
|
|
|
+ document.write('头像<img src="'+window.user_info.logo+'" width=40 height=40 /><br>');
|
|
|
+ document.write('昵称:'+window.user_info.nickname+'<br>');
|
|
|
+ document.write('寄语:'+window.user_info.textmsg);
|
|
|
+ }else{
|
|
|
+ document.write('<h1>这是首页哦</h1>');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function (textStatus) {//请求失败后调用的函数
|
|
|
+ alert("fail");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ window.location.href = url;
|
|
|
+ }
|
|
|
})()
|
|
|
</script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
</body>
|
|
|
</html>
|