UNPKG

tida

Version:

tida

2 lines (1 loc) 6.97 kB
module.exports=webpackJsonp([5],{56:function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=t(1),i=void 0;i=t(o.isWeex?57:59),n.default=i,e.exports=n.default},57:function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=t(58);n.default={getUserInfo:function(e){o.getUserInfo&&o.getUserInfo(function(n){"string"==typeof n&&(n=JSON.parse(n)),e&&e(n)})},login:function(e){o.login&&o.login(function(n){"string"==typeof n&&(n=JSON.parse(n));var t={isLogin:!1};n&&"success"===n.status&&(t.isLogin=!0),n.info&&(t.info=n.info),e&&e(t)})},logout:function(e){o.logout&&o.logout(e)}},e.exports=n.default},58:function(e,n){e.exports=require("@weex-module/user")},59:function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=t(60),i=function(e){return e&&e.__esModule?e:{default:e}}(o);n.default={getUserInfo:function(e){i.default.isLogin(function(n,t){var o=t?t.data||{}:{};e&&e({isLogin:n,info:{userId:o.userNumId,nick:o.nick}})})},login:function(e){i.default.isLogin(function(n,t){var o=t?t.data||{}:{};!0===n?e&&e({isLogin:n,info:{userId:o.userNumId,nick:o.nick}}):i.default.goLogin(void 0,e)})},logout:function(e){i.default.isLogin()?i.default.goLogout():e&&e()}},e.exports=n.default},60:function(e,n,t){"use strict";function o(e){var n=new RegExp("(?:^|;\\s*)"+e+"\\=([^;]+)(?:;\\s*|$)").exec(y.cookie);return n?n[1]:void 0}function i(e){return e.preventDefault(),!1}function r(e,n){var t=this,o=b.dpr||1,r=document.createElement("div"),a=document.documentElement.getBoundingClientRect(),s=Math.max(a.width,window.innerWidth)/o,c=Math.max(a.height,window.innerHeight)/o;r.style.cssText=["-webkit-transform:scale("+o+") translateZ(0)","-ms-transform:scale("+o+") translateZ(0)","transform:scale("+o+") translateZ(0)","-webkit-transform-origin:0 0","-ms-transform-origin:0 0","transform-origin:0 0","width:"+s+"px","height:"+c+"px","z-index:999999","position:absolute","left:0","top:0px","background:#FFF","display:none"].join(";");var u=document.createElement("div");u.style.cssText=["width:100%","height:52px","background:#EEE","line-height:52px","text-align:left","box-sizing:border-box","padding-left:20px","position:absolute","left:0","top:0","font-size:16px","font-weight:bold","color:#333"].join(";"),u.innerText=e;var l=document.createElement("a");l.style.cssText=["display:block","position:absolute","right:0","top:0","height:52px","line-height:52px","padding:0 20px","color:#999"].join(";"),l.innerText="关闭";var d=document.createElement("iframe");d.style.cssText=["width:100%","height:"+window.innerHeight/o+"px","border:0","overflow:hidden"].join(";"),u.appendChild(l),r.appendChild(u),r.appendChild(d),y.body.appendChild(r),d.src=n,l.addEventListener("click",function(){t.hide();var e=y.createEvent("HTMLEvents");e.initEvent("close",!1,!1),r.dispatchEvent(e)},!1),this.addEventListener=function(){r.addEventListener.apply(r,arguments)},this.removeEventListener=function(){r.removeEventListener.apply(r,arguments)},this.show=function(){document.addEventListener("touchmove",i,!1),r.style.display="block",window.scrollTo(0,0)},this.hide=function(){document.removeEventListener("touchmove",i),window.scrollTo(0,-a.top),y.body.removeChild(r)}}function a(e){if(!e||"function"!=typeof e||!L){return!!this.getUserNick()}L.request({api:"mtop.user.getUserSimple",v:"1.0",data:{isSec:0},H5Request:!0},function(n){n.retType===L.RESPONSE_TYPE.SUCCESS?e(!0,n):n.retType===L.RESPONSE_TYPE.SESSION_EXPIRED?e(!1,n):e(void 0,n)})}function s(e){var n;if(C&&(n={},n.promise=new C(function(e,t){n.resolve=e,n.reject=t})),this.isLogin(function(t,o){e&&e(t,o),!0===t?n&&n.resolve(o):n&&n.reject(o)}),n)return n.promise}function c(e){if(!e||"function"!=typeof e){var n="",t=o("_w_tb_nick"),i=o("_nk_")||o("snk"),r=o("sn");return t&&t.length>0&&"null"!=t?n=decodeURIComponent(t):i&&i.length>0&&"null"!=i?n=unescape(unescape(i).replace(/\\u/g,"%u")):r&&r.length>0&&"null"!=r&&(n=decodeURIComponent(r)),n=n.replace(/\</g,"&lt;").replace(/\>/g,"&gt;")}this.isLogin(function(n,t){e(!0===n&&t&&t.data&&t.data.nick?t.data.nick:!1===n?"":void 0)})}function u(e){var n;if(C&&(n={},n.promise=new C(function(e,t){n.resolve=e,n.reject=t})),this.getUserNick(function(t){e&&e(t),t?n&&n.resolve(t):n&&n.reject()}),n)return n.promise}function l(e,n){var t="//"+O+"."+P.subDomain+"."+T+"/"+P[(e||"login")+"Name"];if(n){var o=[];for(var i in n)o.push(i+"="+encodeURIComponent(n[i]));t+="?"+o.join("&")}var r=x.config.loginUrlParams;if(r){var a=[];for(var s in r)a.push(s+"="+encodeURIComponent(r[s]));/\?/.test(t)?t+="&"+a.join("&"):t+="?"+o.join("&")}return t}function d(e,n){n?location.replace(e):location.href=e}function f(e,n,t){function o(e){c.removeEventListener("close",o),b.removeEventListener("message",i),t("CANCEL")}function i(e){var n=e.data||{};n&&"child"===n.type&&n.content.indexOf("SUCCESS")>-1?(c.removeEventListener("close",o),b.removeEventListener("message",i),c.hide(),t("SUCCESS")):t("FAILURE")}var a=location.protocol+"//h5."+P.subDomain+".taobao.com/"+("waptest"===P.subDomain?"src":"other")+"/"+e+"end.html?origin="+encodeURIComponent(location.protocol+"//"+location.hostname),s=l(e,{ttid:"h5@iframe",redirectURL:a}),c=new r(n.title||"您需要登录才能继续访问",s);c.addEventListener("close",o,!1),b.addEventListener("message",i,!1),c.show()}function g(e,n,t){var o=l(e,{wvLoginCallback:"wvLoginCallback"});b.wvLoginCallback=function(e){delete b.wvLoginCallback,t(e.indexOf(":SUCCESS")>-1?"SUCCESS":e.indexOf(":CANCEL")>-1?"CANCEL":"FAILURE")},d(o)}function p(e,n,t){if("function"==typeof n?(t=n,n=null):"string"==typeof n&&(n={redirectUrl:n}),n=n||{},t&&j)g(e,n,t);else if(t&&!_&&"login"===e)f(e,n,t);else{var o=l(e,{redirectURL:n.redirectUrl||location.href});d(o,n.replace)}}function m(e,n,t){var o;if(C&&(o={},o.promise=new C(function(e,n){o.resolve=e,o.reject=n})),p(e,n,function(e){t&&t(e),"SUCCESS"===e?o&&o.resolve(e):o&&o.reject(e)}),o)return o.promise}function v(e,n){p("login",e,n)}function h(e){return m("login",e)}function E(e){p("logout",e)}function w(e){return m("logout",e)}Object.defineProperty(n,"__esModule",{value:!0});var L=lib.mtop,x={},b=window,C=b.Promise,y=b.document,S=b.navigator.userAgent,U=location.hostname,k=(b.location.search,S.match(/WindVane[\/\s]([\d\.\_]+)/)),_=S.match(/AliApp\(([^\/]+)\/([\d\.\_]+)\)/i),j=!!(_&&"TB"===_[1]&&k&&parseFloat(k[1])>5.2),I=["taobao.net","taobao.com"],N=new RegExp("([^.]*?)\\.?((?:"+I.join(")|(?:").replace(/\./g,"\\.")+"))","i"),R=U.match(N)||[],T=function(){return(R[2]||"taobao.com").match(/\.?taobao\.net$/)?"taobao.net":"taobao.com"}(),A=function(){var e=T,n=R[1]||"m";return"taobao.net"===e&&(n="waptest"),"m"!=n&&"wapa"!=n&&"waptest"!=n&&(n="m"),n}(),O="login",P={loginName:"login.htm",logoutName:"logout.htm",subDomain:A};x.config=P,x.isLogin=a,x.isLoginAsync=s,x.getUserNick=c,x.getUserNickAsync=u,x.generateUrl=l,x.goLogin=v,x.goLoginAsync=h,x.goLogout=E,x.goLogoutAsync=w,n.default=x,e.exports=n.default}},[56]);