define("editor/assert/js/plugins/table/dialogs/userlogin/userlogindlg",["../../../../../../../share/assert/js/usersvc","../../../../../../../share/assert/js/restclient"],function(require,exports){function a(){this.showDialog=function(a){var _self=this;$("#modal-content")&&$("#modal-content").remove();var c=$('<div id="modal-content" class="modal fade" tabindex="-1" role="dialog"><div class="modal-dialog test_temp_login" style="width: 350px"><div class="modal-content"><div class="pop_tit"><span class="fl">用户登录</span><div class="w_func fr"><a href="javascript:;" title="关闭" class="w_func_close" data-dismiss="modal"></a></div></div><div style="text-align: center"><iframe id="loginFrame" src="./editor/assert/js/plugins/table/dialogs/userlogin/userlogin.html" frameborder="0" scrolling="no" width="330" height="200"></iframe></div><div style="text-align: center"><a href="javascript:void(0)" class="submit_btn" style="width: 248px; font-size: 16px; margin-bottom: 40px">登录</a></div></div></div></div>');$("body").append(c);var d=document.body.clientHeight;c.find(".modal-content").css("margin-top",(d-280)/2);var e=document.getElementById("loginFrame");c.find(".submit_btn").bind("click",function(){var d=e.contentWindow.userLogin.getUserName(),f=e.contentWindow.userLogin.getPassword();return""==d?void e.contentWindow.userLogin.setErrorMsg("请输入用户名"):""==f?void e.contentWindow.userLogin.setErrorMsg("请输入密码"):void b.login(d,f,function(b){1==b?(c.modal("hide"),setTimeout(function(){c.remove(),$("body").find(".modal-backdrop.fade.in").remove()},500),e.contentWindow.userLogin.setUserInfo(),a()):e.contentWindow.userLogin.setErrorMsg(0==b?"用户名或密码错误":401==b?"请联网后重试":"服务器错误")})}),c.find(".w_func_close").bind("click",function(){c.modal("hide"),setTimeout(function(){c.remove(),$("body").find(".modal-backdrop.fade.in").remove()},500)}),_self.dlg=c,c.modal({show:!0,keyboard:!1,backdrop:"static"})}}var b=require("../../../../../../../share/assert/js/usersvc").userSvc;exports.userLoginDlg=a}),define("share/assert/js/usersvc",["share/assert/js/restclient"],function(require,exports){function a(){function a(a){var b="";for(var c in a)b+=c+"="+a[c]+"&";return encodeURI(b.substr(0,b.length-1))}this.userName="",this.uuid="",this.passwd="";var _self=this;this.login=function(b,c,d){_self.userName=b,_self.passwd=c,_self.getToken(function(e){if(!e)return void d(401);var f={method:"core.user.login",version:"version",format:"json",key:"loginName",value:b,password:c,appkey:"Hb0YhmOo",access_token:e},g=a(f);$.post(AppRemoteSvcCfg.UserSvcUrl,g,function(a){a?(1==a.statusCode&&(_self.uuid=a.userInfo.id),d(new Number(a.statusCode))):d(-1)}).error(function(){d(-1)})})},this.getToken=function(a){b.reqAccessToken(_self.userName,_self.passwd,a)}}var b=require("share/assert/js/restclient").RestClient;exports.userSvc=new a}),define("share/assert/js/restclient",[],function(require,exports){function a(){function b(b,d){var f={locale:e.locale,format:e.format,appkey:e.appkey,access_token:c};for(var g in d)f[g]=d[g];var h;return $.ajax({type:b,async:!1,url:e.restUrl,data:f,dataType:f.format,success:function(a){h=a},error:function(e){log(e.responseJSON),"401"==e.status&&"106"==e.responseJSON.code&&(c="",h=a._request(b,d))}}),h}var _self=this,c="",d=!1,e={appkey:"Hb0YhmOo",appsecret:"R7odNVS0KPtgXJ1TKQbHAxFP6EHdSW5d",username:"",password:"",grantType:"client_credentials",locale:"zh_CN",format:"json",tokenUrl:AppRemoteSvcCfg.UserSvcToken,restUrl:AppRemoteSvcCfg.ResSvcUrl};this.reqAccessToken=function(a,b,d){$.ajax({type:"POST",async:!1,cache:!1,url:e.tokenUrl,data:{client_id:e.appkey,client_secret:e.appsecret,grant_type:e.grantType,username:a,password:b},dataType:"json",success:function(a){c=a.access_token,d(a.access_token)},error:function(){d("")}})},this.userLogin=function(a,b){$.ajax({type:"POST",async:!1,cache:!1,url:e.restUrl,data:{method:"core.user.login",version:"version",format:"json",key:"loginName",value:a,password:b,appkey:"Hb0YhmOo",access_token:c},dataType:"json",success:function(){},error:function(){}})},this.init=function(a){if(!d){for(var b in a)void 0!=e[b]&&(e[b]=a[b]);d=!0}},this.post=function(a){return _self._request("POST",a)},this.get=function(a){return _self._request("GET",a)},this._request=function(a,d){return""==c&&_self.reqAccessToken(),b(a,d)}}exports.RestClient=new a});