index.vue
4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!--
* @Date: 2024-01-26 13:08:09
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-06 23:23:30
* @FilePath: /xyxBooking-weapp/src/pages/search/index.vue
* @Description: 文件描述
-->
<template>
<view class="search-page">
<view>
<view v-if="!is_search">
<view class="input-item">
<view>证件号码</view>
<view>
<input type="text" v-model="idCode" placeholder="请输入证件号码" @blur="checkIdCode" maxlength="18" style="width: 100%;">
</view>
</view>
<view style="color:#A67939; font-size: 30rpx; text-align: center;">
<view style="display: flex; align-items: center; justify-content: center;">
<IconFont name="tips" /> 温馨提示
</view>
<view style="margin-top: 16rpx;">获取参观码,扫码或识别身份证成功进闸机</view>
</view>
</view>
<view v-else>
<qrCodeSearch :id="id_number" />
</view>
<view v-if="!is_search" class="save-wrapper">
<view class="save-btn" @tap="searchBtn">查询</view>
</view>
<view v-else class="success-btn">
<view @tap="goToHome" class="btn-item btn-left">首页</view>
<view @tap="goBack" class="btn-item btn-right">返回查询</view>
</view>
</view>
<view class="logo"></view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import Taro from '@tarojs/taro'
import { IconFont } from '@nutui/icons-vue-taro'
import qrCodeSearch from '@/components/qrCodeSearch';
import { useGo } from '@/hooks/useGo'
const go = useGo();
const is_search = ref(false);
const idCode = ref('');
const id_number = ref('');
// 简单的身份证校验
const validateCIN = (id) => {
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(id);
}
const checkIdCode = () => { // 检查身份证号是否为空
let flag = true;
if (idCode.value.length === 15) { // 15位身份证号码不校验
flag = true;
} else {
if (!validateCIN(idCode.value)) {
Taro.showToast({ title: '请检查身份证号码', icon: 'none' });
flag = false;
}
}
return flag;
}
const searchBtn = async () => {
// 查询用户信息
if (checkIdCode() && idCode.value) {
is_search.value = true;
id_number.value = idCode.value;
idCode.value = ''
}
}
const goBack = () => {
is_search.value = false;
}
const goToHome = () => {
go('/index')
}
</script>
<style lang="less">
.search-page {
padding: 32rpx;
min-height: 100vh;
background-color: #F6F6F6;
.input-item {
background-color: #FFF;
padding: 32rpx;
border-radius: 16rpx;
margin-bottom: 32rpx;
view:first-child {
margin-bottom: 16rpx;
font-weight: bold;
}
input {
border-bottom: 2rpx solid #EEE;
padding: 16rpx 0;
}
}
.save-wrapper {
margin-top: 64rpx;
.save-btn {
background-color: #A67939;
color: #FFF;
text-align: center;
padding: 26rpx 0;
border-radius: 16rpx;
font-size: 35rpx;
}
}
.success-btn {
position: fixed;
bottom: 64rpx;
width: 750rpx;
left: 0;
display: flex;
justify-content: space-around;
.btn-item {
width: 40%;
text-align: center;
padding: 26rpx 0;
border-radius: 16rpx;
font-size: 35rpx;
}
.btn-left {
border: 2rpx solid #A67939;
color: #A67939;
background-color: #FFF;
}
.btn-right {
background-color: #A67939;
color: #FFF;
}
}
.logo {
position: absolute;
right: 0;
bottom: 200rpx;
height: 400rpx;
width: 150rpx;
background-image: url('https://cdn.ipadbiz.cn/xys/booking/logo.png');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
opacity: 0.5;
pointer-events: none;
}
}
</style>