Explorar o código

手机字段的11位检验

duanshenglang hai 8 meses
pai
achega
91165a7407
Modificáronse 3 ficheiros con 39 adicións e 3 borrados
  1. 0 2
      lottery/h5Type-20.html
  2. 19 0
      lottery/registrationActivity.html
  3. 20 1
      lottery/signUp.html

+ 0 - 2
lottery/h5Type-20.html

@@ -343,8 +343,6 @@
 		object-fit: cover;
 	}
 
-	.show_box .show_item .info_box .info_text {}
-
 	.show_box .show_item .info_box .info_text .info_name {
 		font-weight: 500;
 		font-size: 14rem;

+ 19 - 0
lottery/registrationActivity.html

@@ -599,6 +599,13 @@
               })
               return true
             }
+            if (this.containsAllChineseCharacters(item.name, '手机') && item.value.length !== 11) {
+              this.$message({
+                message: '请输入正确的手机号',
+                type: 'warning'
+              })
+              return true
+            }
             return false
           })
           if (isValid) return
@@ -648,6 +655,18 @@
           })
         }
       },
+      // 检查字符串中是否包含所有指定的中文字符
+      containsAllChineseCharacters (str, chineseChars) {
+        // 将要检查的字符拆分为数组
+        const charsArray = chineseChars.split('')
+        // 遍历每个字符并检查是否存在
+        for (const char of charsArray) {
+          if (!str.includes(char)) {
+            return false
+          }
+        }
+        return true
+      },
       // 检测是否iOS端
       iosAgent () {
         return navigator.userAgent.match(/(iPhone|iPod|iPad);?/i);

+ 20 - 1
lottery/signUp.html

@@ -194,7 +194,7 @@
           <el-form-item label="核销码" required>
             <el-input v-model="verificationCode" placeholder="请输入"></el-input>
           </el-form-item>
-          <el-form-item v-for="(item, index) in toshopData.formProList" :key="index" :label="item.name "
+          <el-form-item v-for="(item, index) in toshopData.formProList" :key="index" :label="item.name"
             :required="Boolean(item.isNeed)">
             <el-cascader v-if="item.type === 10" v-model="item.value" :options="transformedData"
               @change="handleInfoCity">
@@ -454,6 +454,13 @@
             })
             return true
           }
+          if (this.containsAllChineseCharacters(item.name, '手机') && item.value.length !== 11) {
+            this.$message({
+              message: '请输入正确的手机号',
+              type: 'warning'
+            })
+            return true
+          }
           return false
         })
         if (isValid) return
@@ -509,6 +516,18 @@
           this.loading = false
         })
       },
+      // 检查字符串中是否包含所有指定的中文字符
+      containsAllChineseCharacters (str, chineseChars) {
+        // 将要检查的字符拆分为数组
+        const charsArray = chineseChars.split('')
+        // 遍历每个字符并检查是否存在
+        for (const char of charsArray) {
+          if (!str.includes(char)) {
+            return false
+          }
+        }
+        return true
+      },
       // 截取url中的数据
       getQueryParam (paramName) {
         // 获取当前URL的查询字符串部分