Pārlūkot izejas kodu

添加今日头条校验

306132416@qq.com 4 gadi atpakaļ
vecāks
revīzija
f3872a2c6a

+ 15 - 2
src/views/account/components/EditModal.vue

@@ -21,8 +21,9 @@
         </div>
         <div class="account">
           <p style="width: 100px">平台账号</p>
-          <input v-model="accountCode"/>
+          <input v-model="accountCode" @blur="checkVal()"/>
         </div>
+        <div v-show="accountIsNumber" style="color: red;font-size: 12px;text-align:center;width: 66%;">平台账号不能为纯数字</div>
         <div class="isAttest">
           <p style="width: 100px">是否认证</p>
           <select v-model="selectValue">
@@ -73,10 +74,18 @@ export default {
     return {
       accountCode: this.modalAccount,
       fansNums: this.modalFanCount,
-      selectValue: this.authorizationName
+      selectValue: this.authorizationName,
+      accountIsNumber:false
     };
   },
   methods: {
+    checkVal(){
+      if(this.dataObj.platformName === '今日头条'){
+        this.accountIsNumber  = /^\d+$/.test(this.accountCode);
+      }else {
+        return true
+      }
+    },
     submit: function () {
       let isAttesta = this.selectValue;
       // let fansNum = this.fansNums;
@@ -86,6 +95,10 @@ export default {
         alert('平台账号不能为空');
         return
       }
+      if (this.accountIsNumber) {
+        alert('平台账号不能为纯数字');
+        return
+      }
       // if (fansNum < 0) {
       //   alert('粉丝数必须大于等于0!');
       //   return

+ 11 - 2
src/views/account/components/Modal2.vue

@@ -18,6 +18,7 @@
           </div>
         </div>
         <div v-show="showCheck" style="color: red;font-size: 12px;text-align:center;">平台账号名称不能包含中文及空格</div>
+        <div v-show="accountIsNumber" style="color: red;font-size: 12px;text-align:center;">平台账号不能为纯数字</div>
         <div class="bodyRow">
           <div class="contentCol1">
             <span>是否认证</span>
@@ -61,7 +62,8 @@ export default {
       accountValue: this.editData["accountCode"],
       fansNum: this.editData["fansCount"],
       flag: this.editData.authorizationName,
-      showCheck:false
+      showCheck:false,
+      accountIsNumber:false
     };
   },
   methods: {
@@ -70,11 +72,14 @@ export default {
     },
     checkVal(){
       //let reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
-
       let reg = new RegExp("[\\u4E00-\\u9FFF\\u0020]+", "g");
       if(this.editData.platformName === '微信订阅号' || this.editData.platformName === '微信服务号'){
         this.showCheck  = reg.test(this.accountValue);
       }
+      if(this.editData.platformName === '今日头条'){
+        console.log(2323)
+        this.accountIsNumber  = /^\d+$/.test(this.accountValue);
+      }
     },
     confirm() {
       /* this.formData.append("dataset_title", this.dataset_title);
@@ -112,6 +117,10 @@ export default {
         alert('平台账号名称不能包含中文及空格');
         return
       }
+      if (this.accountIsNumber) {
+        alert('平台账号不能为纯数字');
+        return
+      }
       if (this.fansNum < 0) {
         alert('粉丝数量填写错误');
         return