码迷,mamicode.com
首页 > Windows程序 > 详细

登陆判读,并跳转到指定页面(window.location.href='http://localhost/index.html')

时间:2017-01-03 18:34:18      阅读:468      评论:0      收藏:0      [点我收藏+]

标签:不能   赋值   ber   session   info   ssi   手机号   type   nts   

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function confirm(){
  var tel=$tel.val();//获取页面中登录名和密码
  var pwd=$pwd.val();
  if(tel==""|| pwd==""){//判断两个均不为空(其他判断规则在其输入时已经判断)
    alert("手机号密码均不能为空!")
    return false;
  }else{//以上均符合要求,则调用登录esb接口
     $.ajax({
       url:config.baseServerUrl + ‘/account/login‘,//相对应的esb接口地址
       type:‘post‘
       data:{mobile:tel,password:pwd},//向服务器(接口)传递的参数
       success:function(data){//服务器(接口)返回来的数据
         if(data.success){//如果返回来的信息说明提交的信息为正确的
           var customerId = data.attr.customerInfo.id;//将数据中用户信息的ID赋值给变量
           sessionStorage.customerId = customerId;//将变量存储到本地sessionStorage中,并且value为customerID
           window.location.href=http://localhost/index.html;//正确登录后页面跳转至
         }
         else{//如果返回来的信息说明提供的信息为错误的
           if(tel != data.tel){//判断是用户名还是密码错误,提示相应信息
             alert(data.message);
             $tel.val("");
             $pwd.val("");
             return false;
            }
            if(pwd != data.pwd){
             alert(data.message);
             $pwd.val("");
             return false;
            }
         }
       }
    })
  }
}

 

登陆判读,并跳转到指定页面(window.location.href='http://localhost/index.html')

标签:不能   赋值   ber   session   info   ssi   手机号   type   nts   

原文地址:http://www.cnblogs.com/mcpark/p/6245780.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!