search.vue
4.52 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!--
* @Date: 2024-01-26 13:08:09
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-26 14:32:16
* @FilePath: /xysBooking/src/views/search.vue
* @Description: 文件描述
-->
<template>
<div class="search-page">
<div>
<div v-if="!is_search">
<div class="input-item">
<div>证件号码</div>
<div>
<input type="text" v-model="idCode" placeholder="请输入证件号码" @blur="checkIdCode" maxlength="18" style="width: 100%;">
</div>
</div>
<div style="color:#A67939; font-size: 0.85rem; text-align: center;">
<van-icon name="warning-o" /> 获取参观码,扫码或识别身份证成功进闸机
</div>
</div>
<div v-else>
<qrCodeSearch :id="id_number" />
</div>
<div v-if="!is_search" class="save-wrapper">
<div class="save-btn" @click="searchBtn">查询</div>
</div>
<div v-else class="success-btn">
<div @click="goToHome" class="btn-item btn-left">首页</div>
<div @click="goBack" class="btn-item btn-right">返回查询</div>
</div>
</div>
<div class="logo"></div>
<van-toast v-model:show="show_error" style="">
<template #message>
{{ error_message }}
</template>
</van-toast>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { validateCIN } from '@code-ts/cin'
import qrCodeSearch from '@/components/qrCodeSearch';
import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js'
//import { } from '@/utils/generateModules.js'
//import { } from '@/utils/generateIcons.js'
//import { } from '@/composables'
import { showSuccessToast, showFailToast } from 'vant';
import { useGo } from '@/hooks/useGo'
import { queryQrCodeAPI } from '@/api/index'
const $route = useRoute();
const $router = useRouter();
useTitle($route.meta.title);
const go = useGo();
const is_search = ref(false);
const idCode = ref('');
const id_number = ref('');
const show_error = ref(false);
const error_message = ref('');
const checkIdCode = () => { // 检查身份证号是否为空
let flag = true;
if (idCode.value.length === 15) { // 15位身份证号码不校验
flag = true;
} else {
if (!validateCIN(idCode.value)) {
show_error.value = true;
error_message.value = '请检查身份证号码';
flag = false;
}
}
return flag;
}
const searchBtn = async () => {
// 查询用户信息
if (checkIdCode()) {
is_search.value = true;
id_number.value = idCode.value;
idCode.value = ''
}
}
const goBack = () => {
is_search.value = false;
}
const goToHome = () => {
go('/')
}
</script>
<style lang="less" scoped>
.search-page {
padding: 1rem;
position: relative;
height: calc(100vh - 2rem);
background-image: url('https://cdn.ipadbiz.cn/xys/booking/bg.jpg');
background-repeat: no-repeat;
background-position: center;
.logo {
position: absolute;
right: 0;
bottom: calc(15vh);
height: 30vh;
width: 20vw;
background-image: url('https://cdn.ipadbiz.cn/xys/booking/logo.png');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
.input-item {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #fff;
padding: 1rem;
border-radius: 8px;
margin-bottom: 1rem;
border: 1px solid #A67939;
input {
border: 0;
text-align: right;
}
}
.save-wrapper {
background-color: #FFF;
position: fixed;
width: 100vw;
bottom: 0;
left: 0;
height: 5rem;
display: flex;
align-items: center;
justify-content: center;
.save-btn {
text-align: center;
flex-grow: 1;
background-color: #A67939;
padding: 0.8rem 0;
margin: 1rem;
color: #FFF;
border-radius: 5px;
font-size: 1.1rem;
}
}
.success-btn {
background-color: #FFF;
position: fixed;
width: 100vw;
bottom: 0;
left: 0;
height: 5rem;
display: flex;
align-items: center;
justify-content: space-around;
.btn-item {
flex: 1;
padding: 0.7rem 0;
border-radius: 5px;
font-size: 1.05rem;
text-align: center;
margin: 0 0.25rem;
}
.btn-left{
background-color: #A67939;
color: #FFF;
margin-left: 0.7rem;
}
.btn-right{
border: 1px solid #A67939;
color: #A67939;
font-size: 1.05rem;
margin-right: 0.7rem;
}
}
}
</style>