sign-stream/src/views/upload-id-card/content/one.vue

279 lines
6.5 KiB
Vue
Raw Normal View History

2024-02-05 05:10:46 +00:00
<script setup>
2024-02-19 09:00:40 +00:00
import {scan_id_card, upload_img} from "@/apis/index.js";
import {useUserStore} from '@/stores/userStore.js'
import defaultImage1 from '@/assets/images/zu1172@2x.png';
import storage from "@/utils/storage.js";
import {storeToRefs} from "pinia";
import {ref} from "vue";
import dayjs from "dayjs";
2024-02-05 05:10:46 +00:00
2024-02-19 09:00:40 +00:00
const userStore = useUserStore()
const {idCardInfo,iDCardImage} = storeToRefs(userStore);
2024-07-23 11:10:26 +00:00
const Num=ref(0)
2024-02-19 09:00:40 +00:00
const afterRead = async (file, num) => {
2024-07-23 11:10:26 +00:00
Num.value=num
2024-02-19 09:00:40 +00:00
const res = await upload_img({
2024-02-19 02:38:17 +00:00
file: file.file,
source: "artwork",
type: 'image'
})
2024-02-19 09:00:40 +00:00
if (res.status === 0) {
if (num === 0) {
iDCardImage.value.front = res.data.ori_url
} else if (num === 1) {
iDCardImage.value.back = res.data.ori_url
}
await cardFace(res.data.ori_url, num)
}
}
2024-02-21 03:30:59 +00:00
const compareDate=(givenDate)=> {
const inputDate = dayjs(givenDate);
2024-02-19 09:00:40 +00:00
const now = dayjs();
2024-02-21 03:30:59 +00:00
if (inputDate.isBefore(now)) {
return '证件已到期,请尽快更新,否则将影响部分功能使用!';
} else if (inputDate.isBefore(now.add(3, 'month'))) {
return '证件即将到期,请尽快更新,否则将影响部分功能使用!';
} else {
return ''
}
2024-02-19 09:00:40 +00:00
}
const cardFace = async (img, num) => {
const res = await scan_id_card({
idCardUrl: img,
Side: num + 1
})
if (res.status === 0) {
if (res.data.iDNum) {
idCardInfo.value=res.data
}else if (res.data.expirationDate || res.data.issueDate) {
idCardInfo.value.expirationDate=res.data.expirationDate
idCardInfo.value.issueDate=res.data.issueDate
}
2024-07-23 11:10:26 +00:00
}else if (res.status === 1) {
2024-07-29 06:25:36 +00:00
iDCardImage.value.front=''
iDCardImage.value.back=''
2024-02-19 09:00:40 +00:00
}
2024-02-19 02:38:17 +00:00
}
2024-02-05 05:10:46 +00:00
</script>
<template>
2024-02-19 09:00:40 +00:00
<div class="one-content">
<div class="content2">
<van-uploader :after-read="(e)=>{afterRead(e,0)}">
<div class="wrap1">
<div class="wrap1_1">
<div class="wrap1_1_1">
<img :src="iDCardImage.front || defaultImage1" alt="">
</div>
2024-02-21 03:30:59 +00:00
<div class="wrap1_1_2" v-if="iDCardImage.front">更换</div>
2024-02-18 08:50:06 +00:00
</div>
2024-02-19 09:00:40 +00:00
<div class="wrap1_2">上传身份证人像面</div>
2024-02-05 05:10:46 +00:00
</div>
2024-02-19 09:00:40 +00:00
</van-uploader>
</div>
<div class="content3">
<van-uploader :after-read="(e)=>{afterRead(e,1)}">
<div class="wrap1">
<div class="wrap1_1">
<div class="wrap1_1_1">
<img :src="iDCardImage.back || defaultImage1" alt="">
</div>
2024-02-21 03:30:59 +00:00
<div class="wrap1_1_2" v-if="iDCardImage.back">更换</div>
2024-02-18 08:50:06 +00:00
</div>
2024-02-19 09:00:40 +00:00
<div class="wrap1_2">上传身份证国徽面</div>
2024-02-05 05:10:46 +00:00
</div>
2024-02-19 09:00:40 +00:00
</van-uploader>
</div>
2024-02-21 03:30:59 +00:00
<div class="content4" v-if="iDCardImage.front&&iDCardImage.back">
2024-02-18 08:50:06 +00:00
<div class="wrap1">
<div class="wrap1_1">
<div class="wrap1_1_1">姓名</div>
2024-02-19 09:00:40 +00:00
<div class="wrap1_1_2">{{ idCardInfo.realName }}</div>
2024-02-18 08:50:06 +00:00
</div>
</div>
<div class="wrap1">
<div class="wrap1_1">
2024-02-19 09:00:40 +00:00
<div class="wrap1_1_1">性别</div>
<div class="wrap1_1_2">{{idCardInfo.sex}}</div>
</div>
</div>
<div class="wrap1">
<div class="wrap1_1">
<div class="wrap1_1_1">身份证号码</div>
<div class="wrap1_1_2">{{idCardInfo.iDNum}}</div>
</div>
</div>
<div class="wrap1">
<div class="wrap1_1">
<div class="wrap1_1_1">有效日期</div>
2024-02-21 03:30:59 +00:00
<div class="wrap1_1_2">{{idCardInfo.issueDate?dayjs(idCardInfo.issueDate).format('YYYY年MM月DD日'):''}}-{{idCardInfo.expirationDate?dayjs(idCardInfo.expirationDate).format('YYYY年MM月DD日'):''}}</div>
2024-02-18 08:50:06 +00:00
</div>
</div>
</div>
<div class="content5">*自动识别内容请仔细核对</div>
2024-02-21 03:30:59 +00:00
<div class="content6" v-if="iDCardImage.front&&iDCardImage.back&&compareDate(idCardInfo.expirationDate)">{{compareDate(idCardInfo.expirationDate)}}</div>
2024-02-20 09:00:39 +00:00
2024-02-18 08:58:36 +00:00
2024-02-19 09:00:40 +00:00
</div>
2024-02-05 05:10:46 +00:00
</template>
<style scoped lang="scss">
2024-02-19 09:00:40 +00:00
.content6 {
2024-02-18 08:50:06 +00:00
margin-top: 5px;
width: 100%;
height: 46px;
background-color: #E74747;
color: #fff;
font-size: 12px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 10px;
}
2024-02-19 09:00:40 +00:00
.content5 {
2024-02-18 08:50:06 +00:00
text-align: right;
font-size: 10px;
color: #FFFFFF;
margin-top: 8px;
}
2024-02-19 09:00:40 +00:00
.content4 {
2024-02-18 08:50:06 +00:00
margin-top: 20px;
background-color: #fff;
overflow: hidden;
border-radius: 12px;
2024-02-19 09:00:40 +00:00
.wrap1 {
2024-02-18 08:50:06 +00:00
padding-left: 14px;
padding-right: 14px;
2024-02-19 09:00:40 +00:00
&:last-child .wrap1_1 {
border-bottom: none;
2024-02-18 08:50:06 +00:00
}
2024-02-19 09:00:40 +00:00
.wrap1_1 {
2024-02-18 08:50:06 +00:00
padding-top: 14px;
padding-bottom: 14px;
border-bottom: #BBC5E0 solid 1px;
display: flex;
2024-02-19 09:00:40 +00:00
.wrap1_1_2 {
2024-02-18 08:50:06 +00:00
padding-left: 10px;
color: #24437E;
font-size: 12px;
}
2024-02-19 09:00:40 +00:00
.wrap1_1_1 {
flex-shrink: 0;
display: flex;
align-items: center;
2024-02-18 08:50:06 +00:00
border-right: #BBC5E0 solid 1px;
width: 92px;
font-size: 12px;
color: #000;
padding-left: 10px;
}
}
}
}
2024-02-19 09:00:40 +00:00
2024-02-05 05:10:46 +00:00
.content3 {
.wrap1 {
width: 332px;
height: 220px;
background-color: #fff;
border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
2024-02-19 09:00:40 +00:00
.wrap1_2 {
2024-02-05 05:10:46 +00:00
margin-top: 3px;
color: #2159C4;
font-size: 12px;
}
2024-02-19 09:00:40 +00:00
2024-02-05 05:10:46 +00:00
.wrap1_1 {
width: 293px;
height: 170px;
2024-02-18 08:50:06 +00:00
position: relative;
2024-02-19 09:00:40 +00:00
.wrap1_1_2 {
2024-02-18 08:50:06 +00:00
font-size: 14px;
display: flex;
justify-content: center;
align-items: center;
color: white;
background-color: #2159C4;
width: 48px;
height: 32px;
border-radius: 20px;
position: absolute;
bottom: 12px;
right: 12px;
2024-02-05 05:10:46 +00:00
}
2024-02-19 09:00:40 +00:00
.wrap1_1_1 {
2024-02-18 08:50:06 +00:00
img {
2024-02-19 09:00:40 +00:00
width: 293px;
height: 170px;
2024-02-18 08:50:06 +00:00
}
}
2024-02-05 05:10:46 +00:00
}
}
}
2024-02-19 09:00:40 +00:00
2024-02-05 05:10:46 +00:00
.content2 {
2024-02-05 08:27:29 +00:00
margin-bottom: 20px;
2024-02-19 09:00:40 +00:00
2024-02-05 05:10:46 +00:00
.wrap1 {
width: 332px;
height: 220px;
background-color: #fff;
border-radius: 10px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
2024-02-19 09:00:40 +00:00
.wrap1_2 {
2024-02-05 05:10:46 +00:00
margin-top: 3px;
color: #2159C4;
font-size: 12px;
}
2024-02-19 09:00:40 +00:00
2024-02-05 05:10:46 +00:00
.wrap1_1 {
width: 293px;
height: 170px;
2024-02-18 08:50:06 +00:00
position: relative;
2024-02-19 09:00:40 +00:00
.wrap1_1_2 {
2024-02-18 08:50:06 +00:00
font-size: 14px;
display: flex;
justify-content: center;
align-items: center;
color: white;
background-color: #2159C4;
width: 48px;
height: 32px;
border-radius: 20px;
position: absolute;
bottom: 12px;
right: 12px;
2024-02-05 05:10:46 +00:00
}
2024-02-19 09:00:40 +00:00
.wrap1_1_1 {
2024-02-18 08:50:06 +00:00
img {
2024-02-19 09:00:40 +00:00
width: 293px;
height: 170px;
2024-02-18 08:50:06 +00:00
}
}
2024-02-05 05:10:46 +00:00
}
}
}
</style>