Browse Source

登录页提示信息更新

laiguoran 7 years ago
parent
commit
3f795fd4c5
3 changed files with 40 additions and 30 deletions
  1. 4 0
      modules/users/controllers/login_controller.js
  2. 1 0
      web/users/html/login.html
  3. 35 30
      web/users/js/login.js

+ 4 - 0
modules/users/controllers/login_controller.js

@@ -43,6 +43,10 @@ class LoginController {
             // 调用接口验证登录信息
             // 调用接口验证登录信息
             let userModel = new UserModel();
             let userModel = new UserModel();
             let responseData = await userModel.getInfoFromSSO(account, password);
             let responseData = await userModel.getInfoFromSSO(account, password);
+            // 先判断返回值是否为未激活状态
+            if ( responseData === '-3') {
+                throw '因邮箱未完成认证,账号未激活;去<a href="https://sso.smartcost.com.cn" target="_blank">激活</a>。';
+            }
             responseData = JSON.parse(responseData);
             responseData = JSON.parse(responseData);
             if (typeof responseData !== 'object') {
             if (typeof responseData !== 'object') {
                 throw '邮箱/手机 或 密码错误';
                 throw '邮箱/手机 或 密码错误';

+ 1 - 0
web/users/html/login.html

@@ -19,6 +19,7 @@
             <h1 class="d-flex justify-content-center mb-5">纵横建筑云计价</h1>
             <h1 class="d-flex justify-content-center mb-5">纵横建筑云计价</h1>
             <div class="form-group">
             <div class="form-group">
                 <input id="inputEmail" class="form-control " name="inputEmail" placeholder="通行账号 邮箱/手机" autofocus="" />
                 <input id="inputEmail" class="form-control " name="inputEmail" placeholder="通行账号 邮箱/手机" autofocus="" />
+                <small id="emailHelp" class="form-text text-danger"></small>
             </div>
             </div>
             <div class="form-group">
             <div class="form-group">
                 <input id="inputPassword" class="form-control " name="inputPassword" placeholder="输入密码" type="password"/>
                 <input id="inputPassword" class="form-control " name="inputPassword" placeholder="输入密码" type="password"/>

+ 35 - 30
web/users/js/login.js

@@ -15,39 +15,44 @@ $(document).ready(function () {
         let account = $("#inputEmail").val();
         let account = $("#inputEmail").val();
         let pw = $("#inputPassword").val();
         let pw = $("#inputPassword").val();
 
 
-        $.ajax({
-            url: '/login',
-            type: 'post',
-            data: {"account": account, "pw": pw},
-            success: function (response) {
-                if (response.error === 0) {
-                    const url = response.last_page !== null && response.last_page !== undefined && response.last_page !== '' ?
-                        response.last_page : '/pm';
-                    if (response.login_ask === 0) {
-                        location.href = url;
-                    } else {
-                        response.compilation_list = response.compilation_list === undefined || response.compilation_list === '' ?
-                            null : JSON.parse(response.compilation_list);
-                        if (response.compilation_list === null || response.compilation_list.length <= 0) {
+        // 判断输入的邮箱/手机是否格式正确
+        if(/^1[3456789]\d{9}$/.test(account) || /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(account)) {
+            $.ajax({
+                url: '/login',
+                type: 'post',
+                data: {"account": account, "pw": pw},
+                success: function (response) {
+                    if (response.error === 0) {
+                        const url = response.last_page !== null && response.last_page !== undefined && response.last_page !== '' ?
+                            response.last_page : '/pm';
+                        if (response.login_ask === 0) {
                             location.href = url;
                             location.href = url;
-                            return false;
+                        } else {
+                            response.compilation_list = response.compilation_list === undefined || response.compilation_list === '' ?
+                                null : JSON.parse(response.compilation_list);
+                            if (response.compilation_list === null || response.compilation_list.length <= 0) {
+                                location.href = url;
+                                return false;
+                            }
+                            console.log(response.compilation_list);
+                            setVersion(response.compilation_list);
+                            $('#ver').modal('show');
                         }
                         }
-                        console.log(response.compilation_list);
-                        setVersion(response.compilation_list);
-                        $('#ver').modal('show');
+                    } else if(response.error === 2) {
+                        $('#check_ssoId').val(response.ssoId);
+                        $('#phone').modal('show');
+                    } else {
+                        let msg = response.msg !== undefined ? response.msg : '未知错误';
+                        showError(msg, $("input"));
                     }
                     }
-                } else if(response.error === 2) {
-                    $('#check_ssoId').val(response.ssoId);
-                    $('#phone').modal('show');
-                } else {
-                    let msg = response.msg !== undefined ? response.msg : '未知错误';
-                    showError(msg, $("input"));
+                },
+                error: function (result) {
+                    showError('内部程序错误', null);
                 }
                 }
-            },
-            error: function (result) {
-                showError('内部程序错误', null);
-            }
-        });
+            });
+        } else {
+            $('#emailHelp').text('您输入的 邮箱/手机 格式不对');
+        }
     });
     });
 
 
     $("input").blur(function () {
     $("input").blur(function () {
@@ -224,7 +229,7 @@ function showError(msg, element) {
     if (element !== null) {
     if (element !== null) {
         element.parent().addClass('has-danger');
         element.parent().addClass('has-danger');
     }
     }
-    $("#message").text(msg);
+    $("#message").html(msg);
     $("#error-tips").show("fast");
     $("#error-tips").show("fast");
 }
 }