178 lines
3.4 KiB
Vue
Raw Normal View History

2024-04-27 21:59:29 +08:00
<template>
<div class="login">
<div class="content">
<div class="title">
<p>准入二维码</p>
</div>
<div class="input">
<input
type="text"
placeholder="请输入身份证号码"
v-model="value"
maxlength="18"
>
</div>
<div
class="anniu"
@click="toQR"
>
查看二维码
</div>
<div class="p">
<p v-if="!isValidIdCard">请输入有效的身份证号码!</p>
</div>
<div class="p">
<p v-if="!iscunzai">身份证号码不能为空!</p>
</div>
</div>
</div>
</template>
<script>
2024-04-27 21:59:52 +08:00
import { entryCodeApi } from '@/assets/js/api/safeManage.js'
2024-04-27 21:59:29 +08:00
export default {
name: 'myLogin',
data () {
return {
value: "",
isValidIdCard: true,
iscunzai: true,
projectSn: "",
userId: "",
id: "",
}
},
mounted () {
this.getQuery();
},
methods: {
getQuery () {
this.projectSn = this.$route.query.projectSn;
this.userId = this.$route.query.userId;
},
async selectWorkerInfo () {
const params = {
// projectSn: this.projectSn,
idCard: this.value
};
// const idCard = this.value;
2024-04-28 21:13:33 +08:00
const res = await entryCodeApi(params);
2024-04-27 21:59:29 +08:00
console.log(res);
if (res.success == true) {
this.id = res.result.id;
console.log("this.id:" + this.id);
2024-04-28 21:13:33 +08:00
this.$router.push({ name: '准入二维码_详情', params: { WorkerInfo: res.result, projectSn: this.projectSn } })
// this.$router.push({path: '/entryCodeDetail'});
2024-04-27 21:59:29 +08:00
} else {
console.log("没有查到信息");
}
},
validateIdCard () {
// 身份证号码正则表达式,简单示例
const idCardRegex = /^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])([0-2][1-9]|10|20|30)\d{3}[\dX]$/;
// 验证身份证号码格式
this.isValidIdCard = idCardRegex.test(this.value);
},
toQR () {
if (this.value != null && this.value != "") {
this.iscunzai = true
this.validateIdCard();
if (this.isValidIdCard) {
console.log("身份证号:" + this.value);
this.selectWorkerInfo();
}
} else {
this.isValidIdCard = true
this.iscunzai = false
}
},
}
}
</script>
<style scoped>
.p {
color: red;
font-size: 1rem;
2024-04-28 21:13:33 +08:00
text-align: center;
margin-top: 2%;
2024-04-27 21:59:29 +08:00
}
.anniu {
color: white;
2024-04-28 21:13:33 +08:00
width: 90%;
margin: 0 auto;
margin-top: 10%;
height: 2.5rem;
line-height: 2.5rem;
2024-04-27 21:59:29 +08:00
font-size: 1.2rem;
background-color: rgb(74, 137, 238);
border-radius: 2.5rem;
2024-04-28 21:13:33 +08:00
text-align: center;
2024-04-27 21:59:29 +08:00
}
.input {
2024-04-28 21:13:33 +08:00
width: 90%;
margin: 0 auto;
margin-top: 40%;
2024-04-27 21:59:29 +08:00
}
input {
font-size: 1.3rem;
text-align: center;
2024-04-28 21:13:33 +08:00
height: 2.5rem;
2024-04-27 21:59:29 +08:00
width: 100%;
border: rgb(165, 165, 165) solid 0.08rem;
border-radius: 0.41rem;
}
input::placeholder {
font-weight: bold;
font-size: 1.2rem;
color: rgb(123, 123, 123);
}
input::-ms-input-placeholder {
text-align: center;
}
input::-webkit-input-placeholder {
text-align: center;
}
.title {
2024-04-28 21:13:33 +08:00
font-size: 1.6rem;
2024-04-27 21:59:29 +08:00
font-weight: bold;
2024-04-28 21:13:33 +08:00
margin-top: 30%;
p{
text-align: center;
}
2024-04-27 21:59:29 +08:00
}
.login {
width: 100%;
height: 100%;
display: flex;
2024-04-28 21:13:33 +08:00
flex-direction: column;
2024-04-27 21:59:29 +08:00
}
.content {
width: 100%;
2024-04-28 21:13:33 +08:00
height: 100vh;
2024-04-27 21:59:29 +08:00
background-size: cover;
background-position: right;
2024-04-28 21:13:33 +08:00
background-image: url("~@/assets/images/entryCodeImg/工地背景.jpg");
2024-04-27 21:59:29 +08:00
}
h1 {
font-size: 1.5rem;
}
</style>