zoukankan      html  css  js  c++  java
  • 登陆判读,并跳转到指定页面(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;
                }
             }
           }
        })
      }
    }
  • 相关阅读:
    SpringMVC-数据处理(三)
    SpringMVC-Controller配置详解(二)
    SpringMVC-简介和执行原理分析(一)
    0913_Python初识及变量
    WebStorm快捷键操作
    纯CSS气泡框实现方法探究
    前端的一些常用DOM和事件归纳
    JS原型与原型链终极详解
    设计趋势:网页设计中的幽灵按钮
    首页焦点图myFocus插件
  • 原文地址:https://www.cnblogs.com/mcpark/p/6245780.html
Copyright © 2011-2022 走看看