Browse Source

update(活动注册): 输入框掩码

曾志翔 2 years ago
parent
commit
55bd72002e
2 changed files with 21 additions and 1 deletions
  1. 1 1
      pages/activity/invite-user/register.vue
  2. 20 0
      plugins/v-mask.js

+ 1 - 1
pages/activity/invite-user/register.vue

@@ -19,11 +19,11 @@
                 name="phone"
                 required
                 :error-messages="errors"
-                maxlength="11"
                 placeholder="请输入11位手机号"
                 solo
                 type="tel"
                 flat
+                maxlength="11"
               />
             </validation-provider>
             <validation-provider

+ 20 - 0
plugins/v-mask.js

@@ -7,6 +7,24 @@ const idCard = [...Array.from({ length: 17 }).fill(/\d/), /(\d|X|x)/];
 
 const phone = [/1/, ...Array.from({ length: 10 }).fill(/\d/)];
 
+const phoneKebab = [
+  /1/,
+  ...Array.from({ length: 2 }).fill(/\d/),
+  '-',
+  ...Array.from({ length: 4 }).fill(/\d/),
+  '-',
+  ...Array.from({ length: 4 }).fill(/\d/),
+];
+
+const phoneNo = [
+  /1/,
+  ...Array.from({ length: 2 }).fill(/\d/),
+  ' ',
+  ...Array.from({ length: 4 }).fill(/\d/),
+  ' ',
+  ...Array.from({ length: 4 }).fill(/\d/),
+];
+
 const bankCard = Array.from({ length: 20 }).fill(/\d/);
 
 export default function (c, i) {
@@ -14,5 +32,7 @@ export default function (c, i) {
     idCard,
     phone,
     bankCard,
+    phoneKebab,
+    phoneNo,
   });
 }