var qeedooLogin=function(a){this.obj=a;this.init()};qeedooLogin.prototype={init:function(){this.SetOptions(this.opt);this.getUrl();this.addCheck();if(this.opt.ucLogin){$(this.opt.loginOutBtn).hitch("click",this.loginOutUc,this)}else{$(this.opt.loginOutBtn).hitch("click",this.loginOut,this)}},SetOptions:function(a){this.opt={formItem:"#idDialLoginForm",loginInItem:"#idDialUserLogin",loginOutItem:"#idDialUserLogined",loginInUrl:"",loginOutUrl:"",loginUrlType:"",loginOutBtn:"#idUserLoginout",username:"#idDialUname",vipItem:"#idVipInfo",safeItem:"#idSafeInfo",integrityItem:"#idIntegrityInfo",ifLoginOutLink:false,act_type:"",ucLogin:false,ifAjax:false};jQuery.extend(this.opt,this.obj)},loginErrors:{"111":"\u901a\u884c\u8bc1\u4e0d\u80fd\u4e3a\u7a7a","112":"\u901a\u884c\u8bc1\u8f93\u5165\u9519\u8bef","113":"\u901a\u884c\u8bc1\u5df2\u88ab\u51bb\u7ed3","114":"\u901a\u884c\u8bc1\u4e0d\u5b58\u5728","115":"\u901a\u884c\u8bc1\u957f\u5ea6\u9519\u8bef","121":"\u901a\u884c\u8bc1\u5bc6\u7801\u9519\u8bef","122":"\u901a\u884c\u8bc1\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a","123":"\u901a\u884c\u8bc1\u5bc6\u7801\u957f\u5ea6\u9519\u8bef","131":"\u9a8c\u8bc1\u7801\u9519\u8bef","134":"\u60a8\u5df2\u591a\u6b21\u8f93\u5165\u9519\u8bef\u5bc6\u7801\uff0c\u8bf7\u7528\u4e50\u5b50\u7f51\u7684\u5b89\u5168\u767b\u5f55","141":"\u53c2\u6570\u9519\u8bef\u6216\u8f93\u5165\u4e0d\u5b8c\u6574"},integMsg:{safeMsg:{"0":"\u5371\u9669","1":"\u4e2d\u7b49","2":"\u5b89\u5168"},strongMsg:function(a){return String(Number(a)*25)+"%"}},addCheck:function(){$(this.opt.formItem).check({userid:{name:"\u7528\u6237\u540d",type:"text",min:4,max:20,empty:true},pwd:{name:"\u5bc6\u7801",type:"text",min:4,max:24,empty:true}},null,this.loginIn,this)},resetUserForm:function(){$(this.opt.formItem).find(":input").not(":hidden").val("")},setInfo:function(e,d,a){var c=$(e);if(c[0]){var b=d?a+d:a+"0";c[0].className="";c.addClass(b)}},setUserInfo:function(a,b){$(this.opt.loginInItem).toggle();$(this.opt.loginOutItem).toggle();$(this.opt.username).html(a?a.uname:"");if(a){this.setInfo(this.opt.vipItem,a.level,"vip");this.setInfo(this.opt.safeItem,a.security,"safe");this.setInfo(this.opt.integrityItem,a.integrity,"strong")}else{this.resetUserForm()}},getUrl:function(){this.opt.act_type=$(this.opt.formItem).find("[name='act_type']").val();this.opt.loginInUrl=this.opt.loginInUrl?this.opt.loginInUrl:$(this.opt.formItem).attr("action");switch(this.opt.act_type){case"serialize":this.opt.ifAjax=this.opt.loginInUrl?true:false;break;case"redirect":break;case"bbs":break;default:break}if(!this.opt.loginUrlType){this.opt.loginOutUrl=this.opt.loginOutUrl?this.opt.loginOutUrl:this.opt.loginInUrl+"out"}else{if(this.opt.loginUrlType="php"){this.opt.loginOutUrl=this.opt.loginOutUrl?this.opt.loginOutUrl:this.opt.loginInUrl.slice(0,-4)+"out.php"}}},loginIn:function(){if(this.opt.ifAjax){$.ajax({type:"POST",dataType:"json",url:this.opt.loginInUrl,data:$(this.opt.formItem).formToArray(),getThis:this,success:function(a){if(typeof(a.type)!="undefined"){if(a.type=="loginok"){if(a.datas){this.getThis.setUserInfo(a.datas,a.uc_data)}}else{if(typeof(this.getThis.loginErrors[a.code])!="undefined"){alert(this.getThis.loginErrors[a.code]);if(a.code==134){window.location="http://www.lezi.com/index.php/login/index/?forward="+window.location.href+"&errno=134&userid="+$($(this.getThis.opt.formItem)[0].userid).val()}}else{alert("\u767b\u9646\u5931\u8d25!")}switch(a.type){case"userid":$(this.getThis.opt.formItem)[0].userid.focus();break;case"pwd":$(this.getThis.opt.formItem)[0].pwd.focus();break;case"error":break;default:break}}}},error:function(){alert("\u8fde\u63a5\u670d\u52a1\u5668\u9519\u8bef\uff0c\u767b\u5f55\u5931\u8d25\uff01")}});return false}else{return true}},loginOut:function(){$.ajax({type:"POST",url:this.opt.loginOutUrl,getThis:this,success:function(a){if(a==0){this.getThis.setUserInfo("");if(!this.getThis.opt.ifAjax&&this.getThis.opt.ifLoginOutLink){window.location=$(this.getThis.opt.formItem).find("[name='forward']").val()}}else{alert("\u9000\u51fa\u5931\u8d25\uff01")}},error:function(){alert("\u8fde\u63a5\u670d\u52a1\u5668\u9519\u8bef\uff0c\u9000\u51fa\u5931\u8d25\uff01")}});return false},loginOutUc:function(){$.ajax({type:"POST",url:this.opt.loginOutUrl,getThis:this,dataType:"json",success:function(a){if(a.error==0){$("body").append(a.uc_data);this.getThis.setUserInfo("");if(!this.getThis.opt.ifAjax&&this.getThis.opt.ifLoginOutLink){window.location=$(this.getThis.opt.formItem).find("[name='forward']").val()}}else{alert("\u9000\u51fa\u5931\u8d25\uff01")}},error:function(){alert("\u8fde\u63a5\u670d\u52a1\u5668\u9519\u8bef\uff0c\u9000\u51fa\u5931\u8d25\uff01")}});return false}};

