Browse Source

账户配置 校验 添加

jiayufei 4 years ago
parent
commit
b2dc32a08f
1 changed files with 10 additions and 23 deletions
  1. 10 23
      src/views/modules/account-config/components/configuration-modal.vue

+ 10 - 23
src/views/modules/account-config/components/configuration-modal.vue

@@ -480,31 +480,13 @@ export default {
             }
         };
         let handleCharacterLen100 = (rule, value, callback) => {
-            const length = this.handleExportRules(value);
-            if (1 <= length && length <= 100) {
-                callback();
-            }
-            else {
-                callback('只能输入1-100个字符');
-            }
+            this.handleExportRules(value, 1, 100, callback);
         };
         let handleCharacterLen20 = (rule, value, callback) => {
-            const length = this.handleExportRules(value);
-            if (4 <= length && length <= 20) {
-                callback();
-            }
-            else {
-                callback('只能输入4-20个字符');
-            }
+            this.handleExportRules(value, 4, 20, callback);
         };
         let handleCharacterLen7 = (rule, value, callback) => {
-            const length = this.handleExportRules(value);
-            if (1 <= length && length <= 7) {
-                callback();
-            }
-            else {
-                callback('只能输入1-7个字符');
-            }
+            this.handleExportRules(value, 1, 7, callback);
         };
         return {
             adBudgetNum: 0,
@@ -722,7 +704,7 @@ export default {
     methods: {
         ...mapGetters(['nickname', 'avatar', 'userInfo']),
         moment,
-        handleExportRules(value) {
+        handleExportRules(value, min, max, callback) {
             let cnReg = /([\u4e00-\u9fa5]|[\u3000-\u303F]|[\uFF00-\uFF60])/;
             let length = 0;
             let strArr = value.split('');
@@ -734,7 +716,12 @@ export default {
                     length += 1;
                 }
             });
-            return length;
+            if (min <= length && length <= max) {
+                callback();
+            }
+            else {
+                callback(`只能输入${min}-${max}个字符`);
+            }
         },
         handleGetPackage() {
             const params = {