单点登陆的javascript类--原创

 

//--------------------------------
//短信系统
//--------------------------------
ShortObj=function()
{
 //this.url="http://192.168.0.118";//短信系统的url
 this.url="http://10.11.117.163";//短信系统的url
}


ShortObj.prototype.loginShort=function(operatorCode,password)
{   
 //alert(this.url);
 var url = this.url+'/operatorlogin';
 var pars = 'operatorCode='+operatorCode+'&password='+password;
 var selfp=this;
 var myAjax = new Ajax.Request(
    url,
    {method: 'post', parameters: pars, onComplete: function(originalRequest){selfp.ongetlogin(originalRequest);}}
    );
 // function(originalRequest){selfp.ongetlogin(originalRequest);}
}
ShortObj.prototype.ongetlogin=function(originalRequest)
{
 
 var strscript = originalRequest.responseText;
 //alert(strscript);
 //this.location="http://192.168.0.118/frame.jsp"
 //alert(this.url);
 window.open(this.url+"/frame.jsp");
}


//-------------------------------------
//修改密码、新增用户
//-------------------------------------
ShortObj.prototype.ModifyShort=function(operatorCode,newpassword)
{   
 var url = this.url+'/operatorlogin';
 var pars = 'operatorCode=0000&password=0';
 var selfp=this;
 var myAjax = new Ajax.Request(
    url,
    {method: 'post', parameters: pars, onComplete: function(transport){selfp.ModifyDeal(operatorCode,newpassword);}}
    );
}
ShortObj.prototype.ModifyDeal=function(id,newpassword)
{
 var url = this.url+'/attemper';
 var pars = 'actionid=ModifyPasswordAction&id='+id+'&newpassword='+newpassword+'&newpassword2='+newpassword;
 var selfp=this;
 var myAjax = new Ajax.Request(
    url,
    {method: 'post', parameters: pars, onComplete: selfp.onCompleteEnd}
    );
}

ShortObj.prototype.AddShort=function(id,code,name,password)
{
 var url = this.url+'/operatorlogin';
 var pars = 'operatorCode=0000&password=0';
 var selfp=this;
 var myAjax = new Ajax.Request(
    url,
    {method: 'post', parameters: pars, onComplete: function(a){selfp.AddDeal(id,code,name,password)}}
    );
}
ShortObj.prototype.AddDeal=function(id,code,name,password)
{
 var url = this.url+'/attemper';
 var pars = 'actionid=OperatorAddAction&operatorType=1&id='+id+'&code='+code+'&name='+name+'&password='+password+'&repassword='+password+'&department=&information=&roleId=1&maxSendSum=0&byDay=0&byMonth=0';
 
 var selfp=this;
 var myAjax = new Ajax.Request(
    url,
    {method: 'post', parameters: pars, onComplete: selfp.onCompleteEnd}
    );
}

ShortObj.prototype.onCompleteEnd=function(originalRequest)
{
 var strscript = originalRequest.responseText;
 if(strscript.indexOf("成功")>0)
 {
  alert('成功!');
 }
 else
 {
  alert('失败!');
 }
}
shortObj=new ShortObj();


---应用举例
shortObj.AddShort(ls_idcard,ls_idcard,ls_name,ls_pwd);

posted @ 2008-07-01 17:08  kuailewangzi1212  阅读(371)  评论(0编辑  收藏  举报