define(["ember","app","appuser"],function(a,b,c){return b.LoginController=a.ObjectController.extend({needs:["application"],queryParams:["action","dest"],appVersion:b.version,model:{username:"",password:"",errormsg:null,isPersist:!1},didModelChanged:function(){}.observes("model"),tabs:[a.Object.create({key:"online",name:"在线登录",classH:"",display:!0}),a.Object.create({key:"local",name:"离线登录",classH:"",display:!0})],isLoading:!1,activeTab:null,onlineTab:!0,didActiveTabChanged:function(){var a=this.get("activeTab");a&&(this.get("tabs").forEach(function(b){b.set("classH",b==a?"qh1":"")}),this.set("onlineTab","online"==a.get("key")))}.observes("activeTab"),_redirect:function(){var a=this.get("controllers.application"),b=a.get("previousTransition");b?(a.set("previousTransition",null),b.retry()):this.transitionToRoute("growth")},_login:function(){var a=this;a.set("isLoading",!0);var b=a.get("username");a.store.find("account",{username:b,password:a.get("password")}).then(function(d){var e=d.get("firstObject").get("id");e&&(c.empty(),c.set("Token",e),a.store.find("user",e).then(function(d){return"parents"!=d.get("Role")?void a.get("dialogManager").notice("请使用学生帐号登录！"):(c.setProperties({Role:d.get("Role"),PersonID:d.get("id"),Logo:d.get("Logo"),Name:b,ChineseName:d.get("ChineseName"),EnglishName:d.get("EnglishName"),ClassName:d.get("ClassName"),GardenName:d.get("GardenName"),ClassID:d.get("ClassID"),GardenID:d.get("GardenID")}),a.set("session.appUser",c),a.set("session.online",!0),a.get("isPersist")&&a.set("confirmUser",!0),void a._redirect())},function(){a.set("errormsg","获取个人信息失败")}))},function(b){a.set("errormsg","登录失败："+b.message)})["finally"](function(){a.set("isLoading",!1)})},actions:{toggleTab:function(a){this.set("activeTab",a)},login:function(){return this.get("isLoading")?void 0:(this.set("username",a.$.trim(this.get("username"))),this.get("username")?this.get("password")?void this._login():void this.set("errormsg","请输入密码"):void this.set("errormsg","请输入用户名"))},togglePersist:function(){this.set("isPersist",!this.get("isPersist"))},loadLocal:function(a){c.setProperties(a.getProperties(["Role","Name","ChineseName","EnglishName","ClassName","GardenName","PersonID","ClassID","GardenID"])),this.set("session.appUser",c),this.set("session.online",!1),this._redirect()}}})});