|
@@ -0,0 +1,1109 @@
|
|
|
+/**
|
|
|
+ * 修改于2019.10.31
|
|
|
+ * 1、针对多玩游戏大厅的修改:多玩游戏大厅YY游戏未绑定微信或者qq账号时,允许弹出绑定弹窗
|
|
|
+ **/
|
|
|
+
|
|
|
+(function (window, $) {
|
|
|
+
|
|
|
+ //小程序不执行
|
|
|
+ if(/(\?|\&)platform=wxminiprogram(&*|$)/.test(location.href)) return
|
|
|
+
|
|
|
+ if (window.dwUDBProxy) return
|
|
|
+
|
|
|
+ __inline('/src/modules/cookie/cookie.js')
|
|
|
+
|
|
|
+ var plainFunction = function () { }
|
|
|
+
|
|
|
+ //多玩客户端不支持window.open,在这里做统一兼容处理
|
|
|
+ var dwClientIncompatible = {
|
|
|
+ isClient: function() {
|
|
|
+ return !!(window.external && window.external.OpenThirdLogin)
|
|
|
+ },
|
|
|
+ open: function(url,target) {
|
|
|
+ if(dwClientIncompatible.isClient()){
|
|
|
+ window.external.OpenThirdLogin(url)
|
|
|
+ } else {
|
|
|
+ return window.open(url,target)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ focus: function(context) {
|
|
|
+ if(!dwClientIncompatible.isClient()){
|
|
|
+ context && context.focus()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: function(context) {
|
|
|
+ if(dwClientIncompatible.isClient()){
|
|
|
+ window.external.CloseThirdLogin()
|
|
|
+ } else {
|
|
|
+ context && context.close()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var Config = {
|
|
|
+ multilogin: {
|
|
|
+ domainMap: [
|
|
|
+ 'video.duowan.com',
|
|
|
+ 'duowan.com',
|
|
|
+ 'duowan.cn'
|
|
|
+ ],
|
|
|
+ domainExcludeMap: [
|
|
|
+ // 'udbproxy.duowan.com',
|
|
|
+ 'ka.duowan.com',
|
|
|
+ 'kaplus.duowan.com',
|
|
|
+ // 'bbs.duowan.com'
|
|
|
+ ],
|
|
|
+ urlMap: [
|
|
|
+ 'http://www.duowan.com/s/test_login.html'
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ showTips:{
|
|
|
+ domainExcludeMap: [
|
|
|
+ 'wan.duowan.com'
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var Util = {
|
|
|
+ loginCallbacks: $.Callbacks('memory'),
|
|
|
+ loginSuccCallbacks: $.Callbacks('memory'),//登录成功后的回调队列
|
|
|
+ bindCallbacks: $.Callbacks('memory'),
|
|
|
+ bindSuccCallbacks: $.Callbacks('memory'),//绑定成功后的回调队列
|
|
|
+ logoutCallbacks: $.Callbacks('memory'),
|
|
|
+ logoutSuccCallbacks: $.Callbacks('memory'),//注销成功后的回调队列
|
|
|
+ intervalHandle: 0,
|
|
|
+
|
|
|
+ getCookie: Cookie.get,
|
|
|
+
|
|
|
+ setCookie: Cookie.set,
|
|
|
+
|
|
|
+ removeCookie: Cookie.remove,
|
|
|
+ //新增默认登录成功事件
|
|
|
+ setDefaultSuccCb: function () {
|
|
|
+ //1.登录成功后,校验论坛信息
|
|
|
+ this.loginSuccCallbacks.add(function (user) {
|
|
|
+ if(Util.allowShowTips() === false) return
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: Util.toDecorateURL('//bbs.duowan.com/api/uinfo4dw.php?op=isregister'),
|
|
|
+ dataType: 'jsonp',
|
|
|
+ success: function (ret) {
|
|
|
+ if (ret.code == 1) {
|
|
|
+ if (__ThirdLogin.loginMaskObj) {
|
|
|
+ __ThirdLogin.loginMaskObj.show()
|
|
|
+ __ThirdLogin.setNickName.show()
|
|
|
+ } else {
|
|
|
+ __ThirdLogin.initLoginTip()
|
|
|
+ if (Util.isWap) {
|
|
|
+ __ThirdLogin.setNickName.css({
|
|
|
+ position: 'absolute',
|
|
|
+ top: $(window).scrollTop() + $(window).height() / 2
|
|
|
+ })
|
|
|
+ }
|
|
|
+ __ThirdLogin.loginMaskObj.show()
|
|
|
+ __ThirdLogin.setNickName.show()
|
|
|
+ }
|
|
|
+ __ThirdLogin.setNickName.data('sign', ret.data)
|
|
|
+ setTimeout(function () {
|
|
|
+ __ThirdLogin.setNickName.find('input').eq(0).val(ret.msg)
|
|
|
+ }, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ return this
|
|
|
+ },
|
|
|
+
|
|
|
+ isLogin: function () {
|
|
|
+ return Util.getCookie('lg_uid') || Util.getCookie('yyuid') || Util.getCookie('ouid')
|
|
|
+ },
|
|
|
+ isBind: function () {
|
|
|
+ return Util.getCookie('lg_bind') == 1
|
|
|
+ },
|
|
|
+ isKaLogin: function (callback) {
|
|
|
+ if (Util.getCookie('user_id')) {
|
|
|
+ callback && callback(true)
|
|
|
+ } else {
|
|
|
+ $.ajax({
|
|
|
+ url: Util.toDecorateURL('//ka.duowan.com/user/checkLogin?createIfNx=0'),
|
|
|
+ dataType: 'jsonp',
|
|
|
+ success: function (ret) {
|
|
|
+ if (ret.code == 0 && ret.data) {
|
|
|
+ callback && callback(true)
|
|
|
+ } else {
|
|
|
+ callback && callback(false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ getUsername: function () {
|
|
|
+ var username = Util.getCookie('username');
|
|
|
+ if (!username) return "";
|
|
|
+
|
|
|
+ var arr = username.split('_', 2);
|
|
|
+ if (!arr || !arr[0]) return username;
|
|
|
+
|
|
|
+ var nickname = Util.getCookie(arr[0] + '_nickname');
|
|
|
+ if (!nickname || 'null' == nickname) return username;
|
|
|
+
|
|
|
+ var prefix = "";
|
|
|
+ if ('newqq' == arr[0]) {
|
|
|
+ prefix = "[QQ网友]";
|
|
|
+ } else if ('qq' == arr[0]) {
|
|
|
+ prefix = "[微信网友]";
|
|
|
+ } else if ('sina' == arr[0]) {
|
|
|
+ prefix = "[微博网友]";
|
|
|
+ } else {
|
|
|
+ prefix = "[多玩网友]";
|
|
|
+ }
|
|
|
+ return prefix + nickname;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ getUid: function () {
|
|
|
+ return Util.getCookie('lg_uid') || Util.getCookie('yyuid') || Util.getCookie('ouid');
|
|
|
+ },
|
|
|
+ decorateURL: function (url) {
|
|
|
+ if (url) {
|
|
|
+ if (/^http/.test(url)) {
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+ var protocol = "http://";
|
|
|
+ if (/^https/.test(window.location.href)) {
|
|
|
+ protocol = "https://"
|
|
|
+ }
|
|
|
+ return protocol + window.location.host + url
|
|
|
+ } else {
|
|
|
+ url = window.location.href;
|
|
|
+ var pos = url.indexOf("#");
|
|
|
+ if (pos != -1) {
|
|
|
+ url = url.substring(0, pos)
|
|
|
+ }
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toDecorateURL: function (url) {
|
|
|
+ if (/^http/.test(url)) {
|
|
|
+ return url;
|
|
|
+ } else {
|
|
|
+ var protocol = "http:";
|
|
|
+ if (/^https/.test(window.location.href)) {
|
|
|
+ protocol = "https:"
|
|
|
+ }
|
|
|
+ return protocol + url
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**默认是登录检测 */
|
|
|
+ intervalCheckLogin: function (intervalTime, tryNum, isbind) {
|
|
|
+ this.intervalHandle && clearInterval(this.intervalHandle)
|
|
|
+
|
|
|
+ if (!intervalTime) intervalTime = 100;
|
|
|
+ if (!tryNum) tryNum = 3000;
|
|
|
+
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ var checkFn = function () {
|
|
|
+ return isbind ? that.isBind() : that.isLogin()
|
|
|
+ }
|
|
|
+
|
|
|
+ var SuccFn = (function () {
|
|
|
+ var fn
|
|
|
+ if (isbind) {
|
|
|
+ fn = function () {
|
|
|
+ that.bindCallbacks.fire()
|
|
|
+ that.bindSuccCallbacks.fire()
|
|
|
+ that.bindCallbacks = $.Callbacks('memory')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ fn = function () {
|
|
|
+ that.loginCallbacks.fire()
|
|
|
+ that.loginSuccCallbacks.fire(Util.getUserInfo())
|
|
|
+ that.loginCallbacks = $.Callbacks('memory')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return fn
|
|
|
+ })()
|
|
|
+
|
|
|
+
|
|
|
+ if (checkFn()) {
|
|
|
+ SuccFn()
|
|
|
+ } else {
|
|
|
+ var i = 0;
|
|
|
+ that.intervalHandle = setInterval(function () {
|
|
|
+ i++;
|
|
|
+ if (checkFn()) {
|
|
|
+ SuccFn()
|
|
|
+ clearInterval(that.intervalHandle);
|
|
|
+ }
|
|
|
+ if (i > tryNum) {
|
|
|
+ clearInterval(that.intervalHandle);
|
|
|
+ }
|
|
|
+ }, intervalTime);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ handleSuccessURL: function (successURL, closeLoginFunc, reloadPage) {
|
|
|
+ var successFunc = function () { };
|
|
|
+ var reloadPageFunc = function () { };
|
|
|
+ var checkLogin = false;
|
|
|
+
|
|
|
+ if ('function' == typeof successURL) {
|
|
|
+ successFunc = successURL;
|
|
|
+ successURL = Util.handleUrl();
|
|
|
+ checkLogin = true;
|
|
|
+ }
|
|
|
+ successURL = this.decorateURL(successURL);
|
|
|
+
|
|
|
+ if ('function' == typeof reloadPage) {
|
|
|
+ reloadPageFunc = function () {
|
|
|
+ reloadPage(successURL);
|
|
|
+ __ThirdLogin.showTip()
|
|
|
+ };
|
|
|
+ checkLogin = true;
|
|
|
+ } else {
|
|
|
+ reloadPageFunc = function () {
|
|
|
+ __ThirdLogin.showTip()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (checkLogin) {
|
|
|
+ this.loginCallbacks.empty();
|
|
|
+ this.loginCallbacks.add(closeLoginFunc);
|
|
|
+ this.loginCallbacks.add(reloadPageFunc);
|
|
|
+ this.loginCallbacks.add(successFunc);
|
|
|
+ this.intervalCheckLogin();
|
|
|
+ }
|
|
|
+ return successURL;
|
|
|
+ },
|
|
|
+ /**绑定处理 */
|
|
|
+ handle2SuccessURL: function (successURL, reloadPage) {
|
|
|
+ var successFunc = function () { };
|
|
|
+ var reloadPageFunc = function () { };
|
|
|
+ var checkBind = false;
|
|
|
+
|
|
|
+ if ('function' == typeof successURL) {
|
|
|
+ successFunc = successURL;
|
|
|
+ successURL = Util.handleUrl();
|
|
|
+ checkBind = true;
|
|
|
+ }
|
|
|
+ successURL = this.decorateURL(successURL);
|
|
|
+
|
|
|
+ if ('function' == typeof reloadPage) {
|
|
|
+ reloadPageFunc = function () {
|
|
|
+ reloadPage(successURL);
|
|
|
+ };
|
|
|
+ checkBind = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (checkBind) {
|
|
|
+ /**清除cookie*/
|
|
|
+ Util.removeCookie('lg_bind', {
|
|
|
+ domain: '.duowan.com',
|
|
|
+ path: '/'
|
|
|
+ })
|
|
|
+ this.bindCallbacks = $.Callbacks('memory')
|
|
|
+ this.bindCallbacks.add(successFunc);
|
|
|
+ this.bindCallbacks.add(reloadPageFunc);
|
|
|
+ this.intervalCheckLogin(null, null, 'bind');
|
|
|
+ }
|
|
|
+ return successURL;
|
|
|
+ },
|
|
|
+
|
|
|
+ handleUrl: function (param) {
|
|
|
+ var href = window.location.href
|
|
|
+
|
|
|
+ param = param || 'udbSuccessCallback'
|
|
|
+
|
|
|
+ if (/\?/.test(href)) {
|
|
|
+ href += ('&' + param)
|
|
|
+ } else {
|
|
|
+ href += ('?' + param)
|
|
|
+ }
|
|
|
+
|
|
|
+ return href
|
|
|
+ },
|
|
|
+
|
|
|
+ isMobile: function () {
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+
|
|
|
+ useMultiLogin: function () {
|
|
|
+ //排除的域名
|
|
|
+ for (var i = 0, len = Config.multilogin.domainExcludeMap.length; i < len; i++) {
|
|
|
+ var domain = Config.multilogin.domainExcludeMap[i]
|
|
|
+ if (location.href.indexOf('ka.duowan.com/hd/') != -1) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((-1 != location.hostname.indexOf(domain))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //域名白名单
|
|
|
+ for (var i in Config.multilogin.domainMap) {
|
|
|
+ if (-1 != location.hostname.indexOf(Config.multilogin.domainMap[i])) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var i in Config.multilogin.urlMap) {
|
|
|
+ if (location.href == Config.multilogin.urlMap[i]) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+
|
|
|
+ allowShowTips:function(){
|
|
|
+ var domainExcludeMap = Config.showTips.domainExcludeMap
|
|
|
+
|
|
|
+ for(var i = 0; i < domainExcludeMap.length; i++){
|
|
|
+ var domainExclude = domainExcludeMap[i];
|
|
|
+ if(location.hostname.indexOf(domainExclude) >= 0 ) return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
+ },
|
|
|
+
|
|
|
+ checkLogin: function () {
|
|
|
+ if (this.isLogin()) {
|
|
|
+ this.loginSuccCallbacks.fire(this.getUserInfo())
|
|
|
+ }
|
|
|
+ return this
|
|
|
+ },
|
|
|
+ getUserInfo: function () {
|
|
|
+ var user = {}
|
|
|
+
|
|
|
+ user.username = this.getUsername()
|
|
|
+ user.yyuid = Util.getUid()
|
|
|
+
|
|
|
+ return user
|
|
|
+ },
|
|
|
+ isWap: /Android|webOS|iPhone|Windows Phone|iPod|BlackBerry|SymbianOS/i.test(window.navigator.userAgent),
|
|
|
+ isBBS: /bbs./.test(location.host),
|
|
|
+ isWx: window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger"
|
|
|
+ }
|
|
|
+
|
|
|
+ function UDBLogin(appid, baseURL) {
|
|
|
+ this.baseURL = baseURL || Util.toDecorateURL('//udbproxy.duowan.com/');
|
|
|
+ this.UDBCallbacks = $.Callbacks('memory');
|
|
|
+ this.setAppid(appid);
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+
|
|
|
+ UDBLogin.prototype = {
|
|
|
+ init: function () {
|
|
|
+ if (Util.isMobile()) {
|
|
|
+ this.loadUDBSdk('MWeb');
|
|
|
+ } else {
|
|
|
+ this.loadUDBSdk('PCWeb');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setAppid: function (appid) {
|
|
|
+ this.appid = appid || 1000;
|
|
|
+ this.getAuthorizeURL = this.baseURL + 'getAuthorizeURL?appid=' + this.appid;
|
|
|
+ this.callbackURL = this.baseURL + 'callback?appid=' + this.appid + '&successURL=';
|
|
|
+ this.denyCallbackURL = this.baseURL + 'denyCallback?appid=' + this.appid;
|
|
|
+ this.getDelCookieURL = this.baseURL + 'getDelCookieURL?appid=' + this.appid;
|
|
|
+ },
|
|
|
+ loadUDBSdk: function (type) {
|
|
|
+ var jsMap = {
|
|
|
+ 'PCWeb': '/lgn/js/oauth/udbsdk/pcweb/udb.sdk.pcweb.popup.min.js',
|
|
|
+ 'MWeb': '/lgn/js/oauth/udbsdk/mweb/udb.sdk.mweb.embed.min.js'
|
|
|
+ }
|
|
|
+ if (!jsMap[type]) {
|
|
|
+ type = 'PCWeb';
|
|
|
+ }
|
|
|
+
|
|
|
+ var that = this;
|
|
|
+ var isLoadUDB = function () {
|
|
|
+ if (window.UDB && window.UDB.sdk && window.UDB.sdk[type]) {
|
|
|
+ that.UDBCallbacks.fire(window.UDB.sdk[type]);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!isLoadUDB()) {
|
|
|
+ $.ajax({
|
|
|
+ type: "GET",
|
|
|
+ url: Util.toDecorateURL("//res.udb.duowan.com/" + jsMap[type]),
|
|
|
+ success: function () {
|
|
|
+ return isLoadUDB();
|
|
|
+ },
|
|
|
+ dataType: "script",
|
|
|
+ cache: true
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ login: function (successURL) {
|
|
|
+ var that = this;
|
|
|
+ successURL = Util.handleSuccessURL(successURL, function () {
|
|
|
+ that.UDBCallbacks.add(function (UDBSdk) {
|
|
|
+ UDBSdk.popupCloseLgn && UDBSdk.popupCloseLgn();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ that.UDBCallbacks.add(function (UDBSdk) {
|
|
|
+ UDBSdk.jsonpOpenLgn(that.getAuthorizeURL, that.callbackURL + encodeURIComponent(successURL), encodeURI(that.denyCallbackURL));
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ embedLogin: function (sel, successURL, UIStyle, closeLoginFunc) {
|
|
|
+ var that = this;
|
|
|
+ var eq = $(sel);
|
|
|
+ if (eq.length == 0) return;
|
|
|
+ eq.each(function () {
|
|
|
+ var thisObj = $(this);
|
|
|
+ if (("function" != typeof successURL) && !successURL) {
|
|
|
+ successURL = thisObj.data("callback-url");
|
|
|
+ }
|
|
|
+ successURL = Util.handleSuccessURL(successURL, closeLoginFunc);
|
|
|
+ $.getJSON(that.getAuthorizeURL + '&jsonpcallback=?', {
|
|
|
+ callbackURL: that.callbackURL + encodeURIComponent(successURL),
|
|
|
+ denyCallbackURL: that.denyCallbackURL
|
|
|
+ },
|
|
|
+ function (data) {
|
|
|
+ if ("1" != data.success) {
|
|
|
+ alert(data.errMsg);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ thisObj.append($('<iframe frameborder="0" scrolling="no" allowtransparency="true"></iframe>').attr("src", data.url + "&rdm=" + Math.random() + "&UIStyle=" + UIStyle));
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ logout: function (successURL) {
|
|
|
+ var that = this;
|
|
|
+ Util.logoutCallbacks.empty()
|
|
|
+
|
|
|
+ if ('function' == typeof successURL) {
|
|
|
+ Util.logoutCallbacks.add(successURL)
|
|
|
+ } else {
|
|
|
+ Util.logoutCallbacks.add(function(){
|
|
|
+ window.location.href = successURL;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ $.getJSON(that.getDelCookieURL + '&jsonpcallback=?', function (data) {
|
|
|
+ if ("1" != data.success) {
|
|
|
+ alert(data.errMsg);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(dwClientIncompatible.isClient()){
|
|
|
+ //多玩游戏大厅
|
|
|
+ Util.removeCookie('dw_client_rewriteDomainCookie',{domain: '.duowan.com',path: '/'})
|
|
|
+ Util.removeCookie('lg_uid', {domain: '.duowan.com',path: '/'})
|
|
|
+ Util.removeCookie('yyuid', {domain: '.duowan.com',path: '/'})
|
|
|
+ Util.removeCookie('ouid', {domain: '.duowan.com',path: '/'})
|
|
|
+
|
|
|
+ window.external && window.external.Logout && window.external.Logout()
|
|
|
+ Util.logoutCallbacks.fire()
|
|
|
+ Util.logoutSuccCallbacks.fire()
|
|
|
+ Util.logoutCallbacks = $.Callbacks('memory')
|
|
|
+ }else{
|
|
|
+ that.UDBCallbacks.add(function (UDBSdk) {
|
|
|
+ UDBSdk.deleteCrossmainCookieWithCallBack(
|
|
|
+ data.delCookieURL,
|
|
|
+ function () {
|
|
|
+ Util.logoutCallbacks.fire()
|
|
|
+ Util.logoutSuccCallbacks.fire()
|
|
|
+ Util.logoutCallbacks = $.Callbacks('memory')
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $.getJSON('//udbproxy.duowan.cn/deleteDuowanCookie?callback=?');
|
|
|
+ },
|
|
|
+ kaLogout: function (successURL) {
|
|
|
+ $.ajax({
|
|
|
+ url: Util.toDecorateURL('//ka.duowan.com/user/logout'),
|
|
|
+ dataType: 'jsonp',
|
|
|
+ success: function (ret) {
|
|
|
+ if (ret.code == 0) {
|
|
|
+ location.reload()
|
|
|
+ } else {
|
|
|
+ alert(ret.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function ThirdLogin(appid, baseURL, loginStyle) {
|
|
|
+ this.baseURL = baseURL || Util.toDecorateURL('//udbproxy.duowan.com/thirdlogin');
|
|
|
+ this.loginStyle = loginStyle || 'duowan';
|
|
|
+ this.callbackURL = '';
|
|
|
+ this.denyCallbackURL = '';
|
|
|
+ this.minWindow = null;
|
|
|
+ this.loginPopupObj = null;
|
|
|
+ this.loginMaskObj = null;
|
|
|
+ this.yyLoginTip = null;
|
|
|
+ this.type = 'login' //login or register
|
|
|
+ this.setAppid(appid)
|
|
|
+ this.init();
|
|
|
+ }
|
|
|
+
|
|
|
+ ThirdLogin.prototype = {
|
|
|
+ init: function () {
|
|
|
+ },
|
|
|
+ setAppid: function (appid) {
|
|
|
+ this.appid = appid || 1000;
|
|
|
+ },
|
|
|
+ multiLogin: function (successURL) {
|
|
|
+ this.initMutilLoginPopup(successURL)
|
|
|
+ this.multiLoginPopupObj.show()
|
|
|
+ this.loginMaskObj.show();
|
|
|
+ },
|
|
|
+ login: function (successURL) {
|
|
|
+ this.initDuowanLoginPopup(successURL)
|
|
|
+ this.loginPopupObj.show()
|
|
|
+ this.loginMaskObj.show()
|
|
|
+ },
|
|
|
+ register: function (successURL) {
|
|
|
+ this.initMutilLoginPopup(successURL, 'register')
|
|
|
+ this.multiLoginPopupObj.show()
|
|
|
+ this.loginMaskObj.show()
|
|
|
+ },
|
|
|
+ kaLogin: function (successURL) {
|
|
|
+ this.initKaLoginPopup(successURL);
|
|
|
+ this.loginPopupObj.show();
|
|
|
+ this.loginMaskObj.show();
|
|
|
+ },
|
|
|
+
|
|
|
+ bind: function (bindType, successURL) {
|
|
|
+ this.bindOauth(bindType, successURL)
|
|
|
+ },
|
|
|
+
|
|
|
+ unBind: function (options, callback) {
|
|
|
+ if (options.loginType && options.openid) {
|
|
|
+ $.ajax({
|
|
|
+ url: this.baseURL + '/?do=unbind',
|
|
|
+ data: options,
|
|
|
+ dataType: 'jsonp'
|
|
|
+ }).done(function (ret) {
|
|
|
+ callback && callback(ret)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ return this
|
|
|
+ },
|
|
|
+
|
|
|
+ getUser: function (callback) {
|
|
|
+ $.ajax({
|
|
|
+ url: Util.toDecorateURL('//udbproxy.duowan.com/getInfo'),
|
|
|
+ dataType: 'jsonp'
|
|
|
+ }).done(function (ret) {
|
|
|
+ callback && callback(ret)
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ mobileLogin: function (successURL) {
|
|
|
+ this.loginOauth('yy', successURL);
|
|
|
+ },
|
|
|
+
|
|
|
+ loginOauth: function (loginType, successURL, multi) {
|
|
|
+ var that = this;
|
|
|
+ var authorize = multi ? 'dwAuthorizeURL' : 'dummy3AuthorizeURL'
|
|
|
+ successURL = Util.handleSuccessURL(successURL, function () {
|
|
|
+ that.closeLoginPopup();
|
|
|
+ }, function (successURL) {
|
|
|
+ that.reloadPage(successURL);
|
|
|
+ });
|
|
|
+
|
|
|
+ if ('yy' == loginType) {
|
|
|
+ var url = '//www.duowan.com/mlogin/?calbackUrl=' + encodeURIComponent(successURL);
|
|
|
+ } else {
|
|
|
+ var url = this.baseURL + "?do=" + authorize + '&appid=' + this.appid + "&loginType=" + loginType + "&callbackUrl=" + encodeURIComponent(successURL);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.minWindow = dwClientIncompatible.open(url, "_loginWin");
|
|
|
+ dwClientIncompatible.focus(this.minWindow);
|
|
|
+
|
|
|
+ // this.minWindow = window.open(url, "_loginWin");
|
|
|
+ // this.minWindow.focus();
|
|
|
+ },
|
|
|
+
|
|
|
+ bindOauth: function (bindType, successURL) {
|
|
|
+ var that = this;
|
|
|
+ var bindUrl = 'bindAuthorizeURL'
|
|
|
+ successURL = Util.handle2SuccessURL(successURL, function (successURL) {
|
|
|
+ that.reloadPage(successURL);
|
|
|
+ });
|
|
|
+
|
|
|
+ var url = this.baseURL + "?do=" + bindUrl + '&appid=' + this.appid + "&loginType=" + bindType + "&callbackUrl=" + encodeURIComponent(successURL);
|
|
|
+
|
|
|
+ this.minWindow = dwClientIncompatible.open(url, "_loginWin");
|
|
|
+ dwClientIncompatible.focus(this.minWindow);
|
|
|
+
|
|
|
+ // this.minWindow = window.open(url, "_loginWin");
|
|
|
+ // this.minWindow.focus();
|
|
|
+ },
|
|
|
+
|
|
|
+ reloadPage: function (successURL) {
|
|
|
+ var that = this;
|
|
|
+ if (this.minWindow) {
|
|
|
+ dwClientIncompatible.close(this.minWindow)
|
|
|
+ }
|
|
|
+ // if (this.minWindow) {
|
|
|
+ // this.minWindow.close()
|
|
|
+ // }
|
|
|
+ this.writeOtherDomainCookie(function () {
|
|
|
+ if (!successURL) {
|
|
|
+ window.location.reload();
|
|
|
+ }
|
|
|
+ if (/udbSuccessCallback/.test(successURL)) {
|
|
|
+ that.closeLoginPopup();
|
|
|
+ } else {
|
|
|
+ window.location.href = successURL;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ writeOtherDomainCookie: function (callback) {
|
|
|
+ var fields = ['udb_n', 'udb_l', 'udb_oar', 'yyuid', 'username', 'password', 'osinfo', 'oauthCookie',
|
|
|
+ 'newqq_nickname', 'qq_nickname', 'sina_nickname', 'lg_uid', 'lg_openid', 'lg_type', 'lg_token'
|
|
|
+ ];
|
|
|
+ var params = {}, field = '', value = '';
|
|
|
+ for (var i = 0; i < fields.length; i++) {
|
|
|
+ field = fields[i];
|
|
|
+ value = Util.getCookie(field);
|
|
|
+ if (value != null) {
|
|
|
+ params[field] = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (-1 != location.hostname.indexOf('duowan')) {
|
|
|
+ $.ajax({
|
|
|
+ url: Util.toDecorateURL('//udbproxy.duowan.cn/writeDuowanCookie'),
|
|
|
+ data: params,
|
|
|
+ dataType: 'jsonp',
|
|
|
+ complete: function () {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initLoginTip: function () {
|
|
|
+ if ($(".account-login-mask").length) return this;
|
|
|
+
|
|
|
+ var cssStyle = __inline("../dwUDBProxy/css/login.css");
|
|
|
+
|
|
|
+ var loginTipTpl = __inline("../dwUDBProxy/tpl/wan_tip.tmpl");
|
|
|
+
|
|
|
+ $("body").append('<style>' + cssStyle + '</style>')
|
|
|
+ $("body").append(loginTipTpl({
|
|
|
+ isWap: Util.isWap,
|
|
|
+ isBBS: Util.isBBS
|
|
|
+ }))
|
|
|
+ var that = this
|
|
|
+ this.loginMaskObj = $(".account-login-mask")
|
|
|
+ this.yyLoginTip = $('#yyLoginTip')
|
|
|
+ this.setNickName = $('#setNickNameTip')
|
|
|
+ this.setNickNameTip = $('.dw-account-input-tip')
|
|
|
+
|
|
|
+ this.loginMaskObj.on('click', function () {
|
|
|
+ that.closeLoginPopup()
|
|
|
+ })
|
|
|
+
|
|
|
+ this.yyLoginTip.on("click", ".close", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.yyLoginTip.hide()
|
|
|
+ that.loginMaskObj.hide()
|
|
|
+ }).on("click", ".dw-account-tip-cancel", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.yyLoginTip.hide()
|
|
|
+ that.loginMaskObj.hide()
|
|
|
+ }).on('click','.dw-account-tip-confirm',function(e){
|
|
|
+ that.yyLoginTip.hide()
|
|
|
+ that.loginMaskObj.hide()
|
|
|
+ })
|
|
|
+
|
|
|
+ var nicking = false
|
|
|
+
|
|
|
+ this.setNickName.on('click', '.close', function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.setNickName.hide()
|
|
|
+ that.loginMaskObj.hide()
|
|
|
+ }).on('click', '.nickname-submit', function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+
|
|
|
+ var sign = that.setNickName.data('sign')
|
|
|
+ if (nicking || !sign) return
|
|
|
+
|
|
|
+ var username = that.setNickName.find('input').eq(0).val()
|
|
|
+
|
|
|
+ if (!username) {
|
|
|
+ that.showNickNameTip(0, '昵称不能为空')
|
|
|
+ } else {
|
|
|
+ nicking = true
|
|
|
+ $.ajax({
|
|
|
+ url: Util.toDecorateURL('//bbs.duowan.com/api/uinfo4dw.php?op=register'),
|
|
|
+ data: { username: username, sign: sign },
|
|
|
+ dataType: 'jsonp',
|
|
|
+ success: function (ret) {
|
|
|
+ if (ret.code == 1) {
|
|
|
+ that.showNickNameTip(1, '注册成功')
|
|
|
+
|
|
|
+ setTimeout(function () {
|
|
|
+ that.closeLoginPopup()
|
|
|
+ if (/bbs./.test(location.href)) {
|
|
|
+ window.location.reload()
|
|
|
+ }
|
|
|
+ }, 2000);
|
|
|
+ } else {
|
|
|
+ that.showNickNameTip(0, ret.msg)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function (err) {
|
|
|
+ that.showNickNameTip(0, err.msg)
|
|
|
+ },
|
|
|
+ complete: function () {
|
|
|
+ nicking = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).on('click', '.nickname-logout', function () {
|
|
|
+ __UDBLogin.logout('')
|
|
|
+ })
|
|
|
+
|
|
|
+ return this
|
|
|
+ },
|
|
|
+ initMutilLoginPopup: function (successURL, type) {
|
|
|
+ type = type || 'login'
|
|
|
+
|
|
|
+ this.initLoginTip()
|
|
|
+
|
|
|
+ if (this.type == type && this.multiLoginPopupObj) return this;
|
|
|
+
|
|
|
+ this.type = type;
|
|
|
+
|
|
|
+ //弹窗定制化 主要针对pc.duowan.cn
|
|
|
+ var wxCustomization = typeof successURL == 'object'
|
|
|
+
|
|
|
+ var loginConfig = {
|
|
|
+ wap: Util.isWap,
|
|
|
+ type: type,
|
|
|
+ dropYYLogin: false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wxCustomization && Util.isWap) {
|
|
|
+ loginConfig.dropYYLogin = true
|
|
|
+ }
|
|
|
+
|
|
|
+ var loginPopupTpl = __inline("../dwUDBProxy/tpl/wan_login.tmpl")(loginConfig);
|
|
|
+
|
|
|
+ if (this.multiLoginPopupObj) {
|
|
|
+ this.multiLoginPopupObj.html($(loginPopupTpl).html())
|
|
|
+
|
|
|
+ return this;
|
|
|
+ } else {
|
|
|
+ $("body").append(loginPopupTpl)
|
|
|
+ }
|
|
|
+
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ this.multiLoginPopupObj = $(".dw-account-login-pop")
|
|
|
+
|
|
|
+ //微信登录定制
|
|
|
+ if (wxCustomization) {
|
|
|
+ var wechatClickCallback = successURL.wechatClickCallback
|
|
|
+ successURL = successURL.defaultCallbck
|
|
|
+ if (Util.isWx) {
|
|
|
+ that.multiLoginPopupObj.on("click", ".login-btn-wechat", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.loginOauth('mp', successURL, 1)
|
|
|
+ that.loginExtention('wechat')
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.multiLoginPopupObj.on("click", ".login-btn-wechat", function () {
|
|
|
+ wechatClickCallback(that)
|
|
|
+ that.loginExtention('wechat')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that.multiLoginPopupObj.on("click", ".login-btn-wechat", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.loginOauth(Util.isWx ? 'mp' : "weixin", successURL, 1)
|
|
|
+ that.loginExtention('wechat')
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ this.multiLoginPopupObj.on('click', '.login-btn-yy', function (e) {
|
|
|
+ if (that.type == 'login') {
|
|
|
+ if (Util.isWap) {
|
|
|
+ __ThirdLogin.mobileLogin(successURL)
|
|
|
+ } else {
|
|
|
+ e.preventDefault()
|
|
|
+ that.closeLoginPopup()
|
|
|
+ __UDBLogin.login(successURL)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.open(Util.toDecorateURL('//aq.yy.com/p/reg/mobile.do?fromadv=navigator'));
|
|
|
+ }
|
|
|
+ that.loginExtention('yy')
|
|
|
+ }).on("click", ".login-btn-qq", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.loginOauth("qq", successURL, 1)
|
|
|
+ that.loginExtention('qq')
|
|
|
+ }).on("click", ".login-btn-weibo", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.loginOauth("weibo", successURL, 1)
|
|
|
+ that.loginExtention('weibo')
|
|
|
+ }).on("click", ".login-btn-old", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.closeLoginPopup()
|
|
|
+ that.login(successURL)
|
|
|
+ }).on("click", ".close", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.closeLoginPopup()
|
|
|
+ })
|
|
|
+
|
|
|
+ return this
|
|
|
+ },
|
|
|
+ initDuowanLoginPopup: function (successURL) {
|
|
|
+ this.initLoginTip()
|
|
|
+
|
|
|
+ if ($(".account-login-pop").length != 0) return;
|
|
|
+ var cssStyle = __inline("../dwUDBProxy/css/duowan.css");
|
|
|
+ var loginPopupTpl = __inline("../dwUDBProxy/tpl/duowan.tmpl")();
|
|
|
+
|
|
|
+ $("body").append('<style>' + cssStyle + '</style>');
|
|
|
+ $("body").append(loginPopupTpl);
|
|
|
+
|
|
|
+ var that = this;
|
|
|
+ that.loginPopupObj = $(".account-login-pop");
|
|
|
+
|
|
|
+ __UDBLogin.embedLogin("#udbsdk_login_content .udbsdk_login", successURL, 'xelogin', function () {
|
|
|
+ that.closeLoginPopup();
|
|
|
+ });
|
|
|
+ that.loginPopupObj.on("click", ".login-btn-wechat", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.loginOauth("weixin", successURL)
|
|
|
+ }).on("click", ".login-btn-qq", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.loginOauth("qq", successURL)
|
|
|
+ }).on("click", ".login-btn-weibo", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.loginOauth("weibo", successURL)
|
|
|
+ }).on("click", ".close", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.closeLoginPopup()
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+ initKaLoginPopup: function (successURL) {
|
|
|
+ if ($(".account-login-pop").length != 0) return;
|
|
|
+ var cssStyle = __inline("../dwUDBProxy/css/duowan.css");
|
|
|
+ var loginPopupTpl = __inline("../dwUDBProxy/tpl/duowan.tmpl")();
|
|
|
+
|
|
|
+ var $loginPopupTpl = $(loginPopupTpl)
|
|
|
+ $loginPopupTpl.find('.login-btn-weibo').remove();
|
|
|
+
|
|
|
+ $("body").append('<style>' + cssStyle + '</style>');
|
|
|
+ $("body").append($loginPopupTpl);
|
|
|
+
|
|
|
+ var that = this;
|
|
|
+ that.loginPopupObj = $(".account-login-pop");
|
|
|
+ that.loginMaskObj = $(".account-login-mask");
|
|
|
+
|
|
|
+ __UDBLogin.embedLogin("#udbsdk_login_content .udbsdk_login", successURL, 'xelogin', function () {
|
|
|
+ that.closeLoginPopup();
|
|
|
+ });
|
|
|
+ that.loginMaskObj.on('click', function () {
|
|
|
+ that.closeLoginPopup()
|
|
|
+ })
|
|
|
+ that.loginPopupObj.on("click", ".login-btn-wechat", function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ var url = '//ka.duowan.com/login/weixin/?type=1&url=' + encodeURIComponent(location.href);
|
|
|
+ $.get(url, function (objResult) {
|
|
|
+ if (objResult.result) {
|
|
|
+ alert('登录成功');
|
|
|
+ } else if (objResult.code === -7 || objResult.code === -5) {
|
|
|
+ location.href = objResult.data;
|
|
|
+ } else {
|
|
|
+ alert(objResult.msg);
|
|
|
+ }
|
|
|
+ }, 'jsonp');
|
|
|
+ }).on("click", ".login-btn-qq", function (e) {
|
|
|
+ e.preventDefault();
|
|
|
+ var url = '//ka.duowan.com/qq/getUserInfo/?url=' + encodeURIComponent(location.href);
|
|
|
+ $.get(url, function (objResult) {
|
|
|
+ if (objResult.result) {
|
|
|
+ alert('登录成功');
|
|
|
+ } else if (objResult.code === -7 || objResult.code === -5) {
|
|
|
+ location.href = objResult.data;
|
|
|
+ } else {
|
|
|
+ alert(objResult.msg);
|
|
|
+ }
|
|
|
+ }, 'jsonp');
|
|
|
+ }).on("click", ".close", function (e) {
|
|
|
+ e.preventDefault()
|
|
|
+ that.closeLoginPopup()
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**提示弹窗 */
|
|
|
+ showTip: function () {
|
|
|
+ if (Util.isWap) return
|
|
|
+ // if( Util.allowShowTips() === false) return //多玩大厅是否允许弹出绑定框
|
|
|
+ var self = this
|
|
|
+ this.getUser(function (ret) {
|
|
|
+ if (ret.bindList.length == 0) {
|
|
|
+ self.yyLoginTip.show()
|
|
|
+ self.loginMaskObj.show()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ showNickNameTip: function (type, msg) {
|
|
|
+ var $icon = this.setNickNameTip.children('.input-tip-icon'),
|
|
|
+ $msg = this.setNickNameTip.children('em')
|
|
|
+
|
|
|
+ if (type) {
|
|
|
+ $icon.addClass('succ')
|
|
|
+ } else {
|
|
|
+ $icon.removeClass('succ')
|
|
|
+ }
|
|
|
+
|
|
|
+ $msg.text(msg)
|
|
|
+ this.setNickNameTip.show()
|
|
|
+ },
|
|
|
+
|
|
|
+ closeLoginPopup: function () {
|
|
|
+ if (this.multiLoginPopupObj) this.multiLoginPopupObj.hide()
|
|
|
+ if (this.loginPopupObj) this.loginPopupObj.hide()
|
|
|
+ if (this.loginMaskObj) this.loginMaskObj.hide()
|
|
|
+ if (this.setNickName) this.setNickName.hide()
|
|
|
+ if (this.yyLoginTip) this.yyLoginTip.hide()
|
|
|
+ },
|
|
|
+ /** 登录以外操作 */
|
|
|
+ loginExtention:function(loginType){
|
|
|
+ //多玩游戏大厅-登录类型上报
|
|
|
+ if(/wan.duowan.com/.test(location.host)){
|
|
|
+ var event = /^\/propCenter/.test(location.pathname) ? "dwgameprop_login_" : "dwgame_login_"
|
|
|
+ var src="http://clickstats.duowan.com/index.php?r=stats/index&event="+event+loginType
|
|
|
+ var img = new Image()
|
|
|
+ img.src = src
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ var _appid = '', _baseURL = '', _thirdLoginStyle = 'duowan';
|
|
|
+
|
|
|
+ var __UDBLogin = new UDBLogin(_appid, _baseURL);
|
|
|
+ var __ThirdLogin = new ThirdLogin(_appid, _baseURL, _thirdLoginStyle);
|
|
|
+
|
|
|
+ Util.setDefaultSuccCb().checkLogin()//如果已经登录 直接执行回调
|
|
|
+
|
|
|
+ window.dwUDBProxy = {
|
|
|
+ login: function (successURL, appid) {
|
|
|
+ try {
|
|
|
+ if (appid) {
|
|
|
+ __UDBLogin.setAppid(appid)
|
|
|
+ __ThirdLogin.setAppid(appid)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Util.useMultiLogin()) {
|
|
|
+ return this.multiLogin(successURL);
|
|
|
+ } else {
|
|
|
+ return __UDBLogin.login(successURL);
|
|
|
+ }
|
|
|
+ } catch (e) { }
|
|
|
+ },
|
|
|
+ register: function (successURL) {
|
|
|
+ return __ThirdLogin.register(successURL)
|
|
|
+ },
|
|
|
+ kaLogin: function (successURL) {
|
|
|
+ return __ThirdLogin.kaLogin(successURL);
|
|
|
+ },
|
|
|
+ multiLogin: function (successURL) {
|
|
|
+ try {
|
|
|
+ return __ThirdLogin.multiLogin(successURL);
|
|
|
+ } catch (e) { }
|
|
|
+ },
|
|
|
+ mobileLogin: function (successURL) {
|
|
|
+ return __ThirdLogin.mobileLogin(successURL);
|
|
|
+ },
|
|
|
+ logout: function (successURL) {
|
|
|
+ try {
|
|
|
+ return __UDBLogin.logout(successURL);
|
|
|
+ } catch (e) { }
|
|
|
+ },
|
|
|
+ kaLogout: function () {
|
|
|
+ try {
|
|
|
+ return __UDBLogin.kaLogout();
|
|
|
+ } catch (e) { }
|
|
|
+ },
|
|
|
+ isLogin: function () {
|
|
|
+ try {
|
|
|
+ return Util.isLogin();
|
|
|
+ } catch (e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isKaLogin: Util.isKaLogin,
|
|
|
+ getCookie: function (name) {
|
|
|
+ try {
|
|
|
+ if ('username' == name) {
|
|
|
+ return Util.getUsername();
|
|
|
+ } else {
|
|
|
+ return Util.getCookie(name);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getUsername: function () {
|
|
|
+ return Util.getUsername();
|
|
|
+ },
|
|
|
+
|
|
|
+ getUid: Util.getUid,
|
|
|
+
|
|
|
+ /**callback(user)*/
|
|
|
+ add: function (callback) {
|
|
|
+ Util.loginSuccCallbacks.add(callback)
|
|
|
+ },
|
|
|
+ /**callback(type) */
|
|
|
+ addBind: function (callback) {
|
|
|
+ Util.bindSuccCallbacks.add(callback)
|
|
|
+ },
|
|
|
+
|
|
|
+ addLogout:function(callback){
|
|
|
+ Util.logoutSuccCallbacks.add(callback)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**绑定相关的操作 */
|
|
|
+ bind: function (type, callback) {
|
|
|
+ return __ThirdLogin.bind(type, callback);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * options [object] {type,openid}
|
|
|
+ */
|
|
|
+ unBind: function (options, callback) {
|
|
|
+ return __ThirdLogin.unBind(options, callback);
|
|
|
+ },
|
|
|
+
|
|
|
+ //是否是wap端 一般用于适配
|
|
|
+ isWap: Util.isWap,
|
|
|
+
|
|
|
+ /**第三方获取用户信息接口 */
|
|
|
+ getUser: function (callback) {
|
|
|
+ return __ThirdLogin.getUser(callback)
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $(function () {
|
|
|
+ __UDBLogin.embedLogin("#login-embed", '', 'xelogin');
|
|
|
+ __UDBLogin.embedLogin("#mlogin-embed", '', 'xemlogin');
|
|
|
+ })
|
|
|
+})(window, jQuery);
|