登陸判讀,並跳轉到指定頁面(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 ;
             }
          }
        }
     })
   }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM