hookehuyr

feat(搜索页): 添加证件类型选择功能并调整证件号码输入限制

增加证件类型选择器组件,支持身份证和其他证件类型选择
根据选择的证件类型动态调整证件号码输入框的最大长度限制
1 <!-- 1 <!--
2 * @Date: 2024-01-26 13:08:09 2 * @Date: 2024-01-26 13:08:09
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-08 10:33:16 4 + * @LastEditTime: 2026-01-08 16:57:38
5 * @FilePath: /xyxBooking-weapp/src/pages/search/index.vue 5 * @FilePath: /xyxBooking-weapp/src/pages/search/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -9,6 +9,13 @@ ...@@ -9,6 +9,13 @@
9 <view class="search-page"> 9 <view class="search-page">
10 <view> 10 <view>
11 <view v-if="!is_search"> 11 <view v-if="!is_search">
12 + <view class="input-card" @tap="open_id_type_picker">
13 + <view class="input-label">证件类型</view>
14 + <view class="picker-value">
15 + <text>{{ id_type_label }}</text>
16 + <text class="picker-arrow">›</text>
17 + </view>
18 + </view>
12 <view class="input-card"> 19 <view class="input-card">
13 <view class="input-label">证件号码</view> 20 <view class="input-label">证件号码</view>
14 <input 21 <input
...@@ -17,7 +24,7 @@ ...@@ -17,7 +24,7 @@
17 v-model="idCode" 24 v-model="idCode"
18 placeholder="请输入证件号码" 25 placeholder="请输入证件号码"
19 @blur="checkIdCode" 26 @blur="checkIdCode"
20 - maxlength="18" 27 + :maxlength="id_type === 1 ? 18 : 30"
21 > 28 >
22 </view> 29 </view>
23 <view class="tip-block"> 30 <view class="tip-block">
...@@ -42,10 +49,20 @@ ...@@ -42,10 +49,20 @@
42 <view @tap="goBack" class="btn-item btn-right">返回查询</view> 49 <view @tap="goBack" class="btn-item btn-right">返回查询</view>
43 </view> 50 </view>
44 </view> 51 </view>
52 +
53 + <nut-popup v-model:visible="show_id_type_picker" position="bottom" safe-area-inset-bottom>
54 + <nut-picker
55 + v-model="id_type_picker_value"
56 + :columns="id_type_columns"
57 + title="选择证件类型"
58 + @confirm="on_id_type_confirm"
59 + @cancel="show_id_type_picker = false"
60 + ></nut-picker>
61 + </nut-popup>
45 </template> 62 </template>
46 63
47 <script setup> 64 <script setup>
48 -import { ref } from 'vue' 65 +import { ref, computed } from 'vue'
49 import Taro from '@tarojs/taro' 66 import Taro from '@tarojs/taro'
50 import { IconFont } from '@nutui/icons-vue-taro' 67 import { IconFont } from '@nutui/icons-vue-taro'
51 import qrCodeSearch from '@/components/qrCodeSearch'; 68 import qrCodeSearch from '@/components/qrCodeSearch';
...@@ -55,6 +72,34 @@ const go = useGo(); ...@@ -55,6 +72,34 @@ const go = useGo();
55 const is_search = ref(false); 72 const is_search = ref(false);
56 const idCode = ref(''); 73 const idCode = ref('');
57 const id_number = ref(''); 74 const id_number = ref('');
75 +const show_id_type_picker = ref(false);
76 +const id_type_options = [
77 + { label: '身份证', value: 1 },
78 + { label: '其他', value: 3 }
79 +];
80 +const id_type = ref(id_type_options[0].value);
81 +const id_type_picker_value = ref([String(id_type.value)]);
82 +
83 +const id_type_columns = computed(() => {
84 + return id_type_options.map(item => ({
85 + text: item.label,
86 + value: String(item.value)
87 + }));
88 +});
89 +const id_type_label = computed(() => {
90 + return id_type_options.find(item => item.value === id_type.value)?.label || id_type_options[0].label;
91 +});
92 +
93 +const open_id_type_picker = () => {
94 + id_type_picker_value.value = [String(id_type.value)];
95 + show_id_type_picker.value = true;
96 +}
97 +
98 +const on_id_type_confirm = ({ selectedValue }) => {
99 + const value = selectedValue?.[0];
100 + id_type.value = Number(value) || 1;
101 + show_id_type_picker.value = false;
102 +}
58 103
59 // 简单的身份证校验 104 // 简单的身份证校验
60 const validateCIN = (id) => { 105 const validateCIN = (id) => {
...@@ -62,6 +107,8 @@ const validateCIN = (id) => { ...@@ -62,6 +107,8 @@ const validateCIN = (id) => {
62 } 107 }
63 108
64 const checkIdCode = () => { // 检查身份证号是否为空 109 const checkIdCode = () => { // 检查身份证号是否为空
110 + if (id_type.value !== 1) return true;
111 +
65 let flag = true; 112 let flag = true;
66 if (idCode.value.length === 15) { // 15位身份证号码不校验 113 if (idCode.value.length === 15) { // 15位身份证号码不校验
67 flag = true; 114 flag = true;
...@@ -125,6 +172,22 @@ const goToHome = () => { ...@@ -125,6 +172,22 @@ const goToHome = () => {
125 font-size: 30rpx; 172 font-size: 30rpx;
126 color: #333; 173 color: #333;
127 } 174 }
175 +
176 + .picker-value {
177 + flex: 1;
178 + display: flex;
179 + align-items: center;
180 + justify-content: flex-end;
181 + text-align: right;
182 + font-size: 30rpx;
183 + color: #333;
184 + }
185 +
186 + .picker-arrow {
187 + margin-left: 10rpx;
188 + color: #BBB;
189 + font-size: 28rpx;
190 + }
128 } 191 }
129 192
130 .tip-block { 193 .tip-block {
......