wangfumin преди 3 месеца
родител
ревизия
a5c7da1b21
променени са 2 файла, в които са добавени 13 реда и са изтрити 6 реда
  1. 12 5
      pages/user/userList/index.js
  2. 1 1
      pages/user/userList/index.wxml

+ 12 - 5
pages/user/userList/index.js

@@ -12,7 +12,7 @@ Page({
       phoneError: '',
       idNumberError: ''
     },
-    idTypes: ['身份证']
+    idTypes: ['身份证', '护照']
   },
 
   onLoad() {
@@ -116,9 +116,16 @@ Page({
       this.setData({ 'newVisitor.idNumberError': '请输入证件号码' });
       return false;
     }
-    if (!/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(idCard)) {
-      this.setData({ 'newVisitor.idNumberError': '请输入正确的18位身份证号码' });
-      return false;
+    if (this.data.newVisitor.idType === '护照') {
+      // if (!/^[A-Za-z0-9]+$/.test(idCard)) {
+      //   this.setData({ 'newVisitor.idNumberError': '请输入正确的护照号码' });
+      //   return false;
+      // }
+    } else {
+      if (!/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(idCard)) {
+        this.setData({ 'newVisitor.idNumberError': '请输入正确的18位身份证号码' });
+        return false;
+      }
     }
     this.setData({ 'newVisitor.idNumberError': '' });
     return true;
@@ -209,7 +216,7 @@ Page({
     
     // 构造API参数
     const params = {
-      cardType: contact.idType === '身份证' ? '1' : '1', // 暂时都设为身份证类型
+      cardType: contact.idType === '身份证' ? '1' : '2', // 暂时都设为身份证类型
       id: 0, // 新增时为0
       idCard: contact.idCard,
       name: contact.name,

+ 1 - 1
pages/user/userList/index.wxml

@@ -96,7 +96,7 @@
             <view class="form-input">
               <input 
                 class="bottom-line-input {{newVisitor.idNumberError ? 'error-line' : ''}}"
-                placeholder="请输入18位证件编码"
+                placeholder="{{newVisitor.idType == '身份证' ? '请输入18位证件编码' : '请输入护照号码'}}"
                 value="{{newVisitor.idCard}}"
                 bindinput="onIdNumberInput"
                 bindblur="validateIdNumber"