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


    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;
                }
             }
           }
        })
      }
    }
  • 相关阅读:
    Luogu_P3435 [POI2006]OKR-Periods of Words KMP
    NOIP2019游记
    []記錄容易出錯的地方和一些知識
    [题解]luogu_P3939_数颜色(vector二分
    [题解]luogu_P4819_杀人游戏(缩点
    [题解]NOIP2018_赛道修建(二分/树形dp/set/贪心
    [题解]luogu_P4161_(排列/lcm
    [题解]luogu_P4886_快递员(点分治
    [题解]luogu_P3523(树上覆盖
    [题解]luogu_P2466(区间dp
  • 原文地址:https://www.cnblogs.com/mcpark/p/6245780.html
Copyright © 2020-2023  润新知