index.vue 5.34 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
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
<template>
<view class="cardscanning">
<!-- 摄像机 -->
<view class="cardscanning-head">
<view class="title item">请扫描你的有效身份证</view>
<!-- 扫描身份证 -->
<ocr-navigator @onSuccess="scanIdcardFront" certificateType="idCard" :opposite="false">
<view class="title-box" >
<img style="width: 100%; height: 100%;" :src="src" alt="" v-if="src" />
<img src="/static/zhengmian.png" alt="" v-else />
<view class="box" >
扫描身份证正面
</view>
</view>
</ocr-navigator>
</view>
<!-- 身份信息 -->
<view class="cardscanning-box">
<view class="box-item item">请确认你的身份信息</view>
<view class="box-item">
<view>姓名</view>
<view class="box-item-info">{{userInfo.name}}</view>
</view>
<view class="box-item">
<view>性别</view>
<view class="box-item-info">{{userInfo.gender}}</view>
</view>
<view class="box-item">
<view>民族</view>
<view class="box-item-info">{{userInfo.nationality}}</view>
</view>
</view>
<view class="cardscanning-box" style="height: 250rpx;">
<view class="box-item">
<view>出生日期</view>
<view class="box-item-info">{{userInfo.mount}}</view>
</view>
<view class="box-item">
<view>家庭住址</view>
<view class="box-item-info">{{userInfo.address}}</view>
</view>
<view class="box-item">
<view>身份证号</view>
<view class="box-item-info">{{userInfo.id}}</view>
</view>
</view>
<!-- 最后的提取信息 -->
<view class="bottom">
<button type="default" :disabled="!userInfo.id" class="button" @click="extractBtn">提取信息</button>
</view>
</view>
</template>



<script>
import {request} from '../../request/request.js'
// 在 Vue 文件中调用原生插件
// import { NativeModules } from '@dcloudio/uni-app';
export default {
data(){
return{
id:'',
patientForm:{
},
userInfo:{
} ,//个人信息
src:''
}
},
mounted() {
this.getPatient()
},
methods:{
// 出生年月
extractBirthDate(idNumber){
const birthDate = new Date(idNumber);
// 当前日期
const currentDate = new Date();
// 计算年龄
let age = currentDate.getFullYear() - birthDate.getFullYear();
// 如果当前月份小于出生月份,或者当前月份等于出生月份但是当前日期小于出生日期,则年龄减一
if (currentDate.getMonth() < birthDate.getMonth() ||
(currentDate.getMonth() === birthDate.getMonth() && currentDate.getDate() < birthDate.getDate())) {
age--;
}
// 打印年龄
return age
},
// 获取患者信息
async getPatient (){
const res = await request({url:'/patient'})
console.log(res,'res');
this.patientForm = res
},
// 扫描身份证
scanIdcardFront(e){
const data = e.detail;
const birthDate = this.extractBirthDate(data.birth.text);
this.userInfo = {
name:data.name.text,
id:data.id.text,
address:data.address.text,
gender:data.gender.text,
nationality:data.nationality.text,
mount:data.birth.text,
age:birthDate,
id1:this.id,
img:this.patientForm.img,
id1:this.patientForm.id,
caseHistory:this.patientForm.caseHistory
}
this.src = data.image_path
},
// 提取信息
async extractBtn(){
uni.navigateTo({
url: `/pages/gentfiling/index?userInfo=${JSON.stringify(this.userInfo)}`
});
}
}
}
</script>

<style scoped lang="scss">
.cardscanning{
width: 100vw;
height: 100vh;
// padding: 23rpx;
background-color: #eee;
box-sizing: border-box;
.item{
font-family: SourceHanSansCN, SourceHanSansCN;
font-weight: 400;
font-size: 30rpx;
color: #999999;
line-height: 32rpx;
text-align: left;
font-style: normal;
text-transform: none;
}
.cardscanning-head{
width: 750rpx;
height: 400rpx;
background: #FFFFFF;
padding: 30rpx;
.title-box{
margin-top: 32rpx;
width: 685rpx;
height: 279rpx;
background: #F3F7FD;
border-radius: 10rpx 10rpx 10rpx 10rpx;
text-align: center;
img{
width: 220rpx;
height: 180rpx;
}
.box{
margin-top: 20rpx;
width: 692rpx;
height: 80rpx;
background: #5581FF;
border-radius: 0rpx 10rpx 10rpx 0rpx;
line-height: 80rpx;
font-family: SourceHanSansCN, SourceHanSansCN;
font-weight: 400;
font-size: 28rpx;
color: #FFFFFF;
font-style: normal;
text-transform: none;
}
}
}
.cardscanning-box{
margin-top: 30rpx;
width: 750rpx;
height: 362rpx;
background-color: #FFFFFF;
box-sizing: border-box;
.box-item{
// width: 750rpx;
height: 88rpx;
line-height: 88rpx;
border-bottom: 2rpx solid #eee;
background: #FFFFFF;
padding:0 40rpx ;
display: flex;
justify-content: space-between;
font-family: SourceHanSansCN, SourceHanSansCN;
font-weight: 400;
font-size: 30rpx;
color: #1B1B20;
.box-item-info{
color: #656565;
}
}
}
.bottom{
margin-top: 50rpx;
height: 200rpx;
background-color: #FFFFFF;
display: flex;
align-items: center;
.button{
width: 721rpx;
height: 100rpx;
background: #5581FF;
box-shadow: 8rpx 0rpx 16rpx 0rpx #2385FF;
border-radius: 44rpx 44rpx 44rpx 44rpx;
color: #FFFFFF;
}
}
}
</style>