Explorar o código

pref: 处理邮箱交互问题

wangcz %!s(int64=7) %!d(string=hai) anos
pai
achega
d643938c8c

+ 32 - 25
src/main/webapp/resources/js/sso/controllers/staffManagementCtrl.js

@@ -13,6 +13,7 @@ define(['app/app'], function (app) {
             $scope.addingUser = status;
             $scope.addingUser = status;
             $scope.adding = false;
             $scope.adding = false;
             $scope.newUser = {};
             $scope.newUser = {};
+            $scope.newUser.userName = '';
             $scope.newUser.userTel = '';
             $scope.newUser.userTel = '';
             $scope.newUser.userEmail = '';
             $scope.newUser.userEmail = '';
         };
         };
@@ -247,7 +248,7 @@ define(['app/app'], function (app) {
                 toaster.pop('error', '请输入用户名信息');
                 toaster.pop('error', '请输入用户名信息');
                 return;
                 return;
             }
             }
-            if (!$scope.userTelSuccess) {
+            if (!$scope.userTelSuccess && !$scope.userEmailSuccess) {
                 toaster.pop('error', '请输入正确的信息后提交');
                 toaster.pop('error', '请输入正确的信息后提交');
                 return;
                 return;
             }
             }
@@ -367,33 +368,39 @@ define(['app/app'], function (app) {
          * 验证邮箱是否可用
          * 验证邮箱是否可用
          */
          */
         $scope.emailValid = function (email) {
         $scope.emailValid = function (email) {
+            var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
             if (email) {
             if (email) {
-                $http.get('basic/user/emailEnable', {
-                    params: {
-                        email: email
-                    }
-                }).success(function (data) {
-                    data = eval(data);
-                    if (data == true) {
-                        // $scope.newUserForm.newUserEmail.$setValidity('available',
-                        //     true);
-                        $scope.userEmailSuccess = true;
-                        $scope.userEmailError = false;
-                    } else {
-                        // $scope.newUserForm.newUserEmail.$setValidity('available',
-                        //     false);
-                        $scope.userEmailError = true;
-                        $scope.userEmailSuccess = false;
-                        toaster.pop('error', '错误', '邮箱 ' + email + ' 已被注册');
-                    }
-                }).error(function () {
-                    $scope.userEmailError = true;
-                    $scope.userEmailSuccess = false;
-                });
+                reg.test(email) ? $scope.userEmailSuccess = true : $scope.userEmailSuccess = false;
             } else {
             } else {
-                $scope.userEmailError = false;
-                $scope.userEmailSuccess = false;
+                $scope.userEmailSuccess = true;
             }
             }
+            // if (email) {
+            //     $http.get('basic/user/emailEnable', {
+            //         params: {
+            //             email: email
+            //         }
+            //     }).success(function (data) {
+            //         data = eval(data);
+            //         if (data == true) {
+            //             // $scope.newUserForm.newUserEmail.$setValidity('available',
+            //             //     true);
+            //             $scope.userEmailSuccess = true;
+            //             $scope.userEmailError = false;
+            //         } else {
+            //             // $scope.newUserForm.newUserEmail.$setValidity('available',
+            //             //     false);
+            //             $scope.userEmailError = true;
+            //             $scope.userEmailSuccess = false;
+            //             toaster.pop('error', '错误', '邮箱 ' + email + ' 已被注册');
+            //         }
+            //     }).error(function () {
+            //         $scope.userEmailError = true;
+            //         $scope.userEmailSuccess = false;
+            //     });
+            // } else {
+            //     $scope.userEmailError = false;
+            //     $scope.userEmailSuccess = false;
+            // }
         };
         };
 
 
         /**
         /**

+ 1 - 0
src/main/webapp/resources/view/sso/staffManagement.html

@@ -973,6 +973,7 @@
                         </td>
                         </td>
                         <td ng-class="{'has-error': userEmailError, 'has-success': userEmailSuccess}">
                         <td ng-class="{'has-error': userEmailError, 'has-success': userEmailSuccess}">
                             <input ng-model="newUser.userEmail" ng-pattern="/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/"
                             <input ng-model="newUser.userEmail" ng-pattern="/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/"
+                                   ng-blur="emailValid(newUser.userEmail)"
                                    name="newUserEmail" type="text"
                                    name="newUserEmail" type="text"
                                    placeholder="邮箱">
                                    placeholder="邮箱">
                         </td>
                         </td>