qq,sina第3方登录js版

发布时间:2017-1-20 9:38:20 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"qq,sina第3方登录js版",主要涉及到qq,sina第3方登录js版方面的内容,对于qq,sina第3方登录js版感兴趣的同学可以参考一下。

                $(".tc").click(function (e) {                 e.preventDefault();                 //alert("QQ="+QC.Login.check());                 if (QC.Login.check() == true) {                     QC.Login.signOut();                 }                 else {                 }                 //alert("sina="+WB2.checkLogin())                 if (WB2.checkLogin() == true) {                     WB2.logout();                     //alert(2);                 }                 else {                 }                 location.href = "/Account/LogOut";                 //alert(1);             }); <script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=YOUR APPKEY" type="text/javascript"         charset="utf-8"></script>     <script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js"         data-appid="appid" data-redirecturi="redirect_url"charset="utf-8"></script>     <%if (!UserContext.Instance.IsLogined)       { %>     <script type="text/javascript">         $(function () {             QC.Login({//按默认样式插入QQ登录按钮                 btnId: "qqLoginBtn", //插入按钮的节点id                 size: "C_S", //按钮尺寸,可用值[A_XL| A_L| A_M| A_S|  B_M| B_S| C_S],可选,默认B_S                 scope: "get_user_info", //展示授权,可选                 display: "pc" //应用场景,可选             }, function (reqData) {//登录成功|                 $("#hidQQName").val(reqData.nickname);                 QC.Login.getMe(function (openId, accessToken, backData) {                     var name = $("#hidQQName").val();                     //登录成功后腾讯会返回一个唯一标识的openid可用于你自己网站绑定的用户存档                     $.post("/Home/CheckLogin?openId=" + openId + "&name=" + name, function (data) {                         //alert(data.Result + "==1");                         if (data.Result == 1 || data.Result == 2) {                             //alert(window.opener + "||" + window.parent)                             if (window.opener != null) {                                 //alert(333);                                 window.opener.location.reload();                                 //window.parent.location.href = window.parent.location.href;                                 window.close();                             }                         }                     })                 });             }, function () {                 //alert('QQ登录注销成功');             });         })     </script>     <%} %>     <%if (!UserContext.Instance.IsLogined)       { %>     <script type="text/javascript">         WB2.anyWhere(function (W) {             W.widget.connectButton({                 id: "wb_connect_btn",                 type: "5,5", //type:连接按钮样式,是登录前的按钮样式[1-7]和登录后的样式[1-5]的组合,可选,默认为a"3,2"                 callback: {                     login: function (o) {//登录后的回调函数                         $("#hidQQName").val(o.screen_name);                         var name = $("#hidQQName").val();                         $.post("/Home/CheckLogin?openId=" + o.id + "&name=" + name, function (data) {                             //if (window.opener != null) {                             alert("sina");                             window.parent.location.href = window.parent.location.href;                             //}                         });                     },                     logout: function () {//退出后的回调函数                         alert('logout');                     }                 }             });         });     </script> 前台:   <a class="tc" href="/Account/Logout">[退出]</a>//退出登录状态 <span id="qqLoginBtn" class="logQQ">qq</span> <span id="wb_connect_btn" class="logSina">sina</span> 后台:         public void Logout()         {             UserContext.Instance.LoginOut();             Session.RemoveAll();             HttpCookie cookie = new HttpCookie("COOKIE_NAME_FOR_USER");             cookie.Expires = DateTime.Now.AddDays(-1);             Response.Cookies.Add(cookie);             Response.Redirect("/Home/Index");         }

上一篇:spring配置datasource三种方式
下一篇:mybatis学习整理(用户手册)(完整的全面学习)

相关文章

相关评论