Browse Source

手机邮箱做输入限制

huangb 7 years ago
parent
commit
8403f90012
1 changed files with 20 additions and 8 deletions
  1. 20 8
      components/mobile/staffManagement/StaffAdd.vue

+ 20 - 8
components/mobile/staffManagement/StaffAdd.vue

@@ -26,6 +26,7 @@
             <li><span>手机号:</span><input type="text"
                                         v-model="newUserPhone"
                                         @change="checkPhone()"
+                                        maxlength="11"
                                         placeholder="请输入手机号"></li>
             <li><span>邮箱:</span><input type="text"
                                        v-model="newUserEmail"
@@ -177,14 +178,25 @@
       },
       // 绑定未注册用户
       addNewUser () {
-        if (this.newEmailCheck && this.newPhoneCheck) {
-          this.$http.post('/basic/user', {userEmail: this.newUserEmail, userName: this.newUserName, userSex: this.sex, userTel: this.newUserPhone})
-            .then(response => {
-              if (response) {
-                this.onRemind('增加用户成功' + this.newUserName)
-                this.$router.push('/mobile/user/staff')
-              }
-            })
+        if (!this.newUserPhone || this.newUserPhone === '') {
+          this.onRemind('请输入手机号码')
+          this.newPhoneCheck = false
+        } else if (!this.newUserEmail || this.newUserEmail === '') {
+          this.onRemind('请输入邮箱')
+          this.newEmailCheck = false
+        } else {
+          if (this.newEmailCheck && this.newPhoneCheck) {
+            this.$http.post('/basic/user', {userEmail: this.newUserEmail, userName: this.newUserName, userSex: this.sex, userTel: this.newUserPhone})
+              .then(response => {
+                if (response) {
+                  this.onRemind('增加用户成功' + this.newUserName)
+                  this.$router.push('/mobile/user/staff')
+                }
+              })
+          } else {
+            this.checkPhone()
+            this.checkEmail()
+          }
         }
       },
       // 取消绑定