|
@@ -0,0 +1,213 @@
|
|
|
+<template>
|
|
|
+ <window-size>
|
|
|
+ <div style="height: 5px"></div>
|
|
|
+ <van-tag>请拍摄身份证的人像面照片</van-tag>
|
|
|
+ <div :style="uploadHeight" id="capBox">
|
|
|
+ <div :style="uploadWidth">
|
|
|
+ <van-uploader style="width: 100%; height: 100%" v-model="fileList" :max-count="1">
|
|
|
+ <img style="width: 100%; height: 100%" :src="capImg" />
|
|
|
+ </van-uploader>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="height: 10px"></div>
|
|
|
+ <div class="cap-tip">
|
|
|
+ <van-tag type="danger">拍摄要求</van-tag>
|
|
|
+ <p>* 身份证置于纯色背景上</p>
|
|
|
+ <p>* 拍摄身份证时请靠近证件并垂直拍摄</p>
|
|
|
+ <div style="margin: 20px">
|
|
|
+ <van-button type="primary" block :disabled="disableUpload" @click="uploadIdCard">确定上传</van-button>
|
|
|
+ <div style="height: 10px"></div>
|
|
|
+ <van-button block @click="showInputDialog = true">没带身份证,填写信息</van-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <van-dialog
|
|
|
+ v-model:show="showInputDialog"
|
|
|
+ width="90%"
|
|
|
+ title="请补充以下信息"
|
|
|
+ show-cancel-button
|
|
|
+ confirm-button-text="新建卡"
|
|
|
+ :before-close="beforeClose"
|
|
|
+ >
|
|
|
+ <div style="padding: 20px">
|
|
|
+ <van-field v-model="inputInfo.name" label="姓名" placeholder="请输入姓名"></van-field>
|
|
|
+ <van-field v-model="inputInfo.socialNo" label="身份证号" placeholder="请输入身份证号"></van-field>
|
|
|
+ <van-field v-model="inputInfo.phone" type="tel" label="手机号" placeholder="请输入手机号"></van-field>
|
|
|
+ <van-field
|
|
|
+ readonly
|
|
|
+ clickable
|
|
|
+ name="area"
|
|
|
+ v-model="inputInfo.address"
|
|
|
+ label="住址地区"
|
|
|
+ placeholder="点击选择省市区"
|
|
|
+ @click="showArea = true"
|
|
|
+ />
|
|
|
+ <van-popup v-model:show="showArea" position="bottom">
|
|
|
+ <van-area :area-list="allArea" :value="defaultDistrict" @confirm="onConfirmArea" @cancel="showArea = false" />
|
|
|
+ </van-popup>
|
|
|
+ <van-field v-model="inputInfo.street" label="街道、小区" type="text" placeholder="请输入住址所在街道、小区" />
|
|
|
+ </div>
|
|
|
+ </van-dialog>
|
|
|
+ </window-size>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { computed, reactive, ref } from 'vue'
|
|
|
+import store from '../../../store'
|
|
|
+import capImg from '../../../assets/capture-img.png'
|
|
|
+import allArea from '../../../utils/area'
|
|
|
+import { getPatientIdByOpenId, readImage, readInput } from '../../../api/patient-id-cards'
|
|
|
+import { isValidIdcard, isValidPhone } from '../../../utils/validate'
|
|
|
+import { Toast } from 'vant'
|
|
|
+import router from '../../../router'
|
|
|
+import { getLocalOpenId } from '../../../utils/check-patient-id'
|
|
|
+export default {
|
|
|
+ setup() {
|
|
|
+ const windowSize = store.state.windowSize
|
|
|
+ const uploadWidth = {
|
|
|
+ margin: '10px 60px',
|
|
|
+ width: windowSize.w - 120 + 'px',
|
|
|
+ }
|
|
|
+ const uploadHeight = {
|
|
|
+ height: ((windowSize.w - 120) / 3) * 2 + 'px',
|
|
|
+ }
|
|
|
+ const fileList = ref([])
|
|
|
+ const disableUpload = computed(() => {
|
|
|
+ return fileList.value.length !== 1
|
|
|
+ })
|
|
|
+ const defaultDistrict = ref('430105')
|
|
|
+ const uploadIdCard = () => {
|
|
|
+ readImage(fileList.value[0]).then((res) => {
|
|
|
+ inputInfo.name = res.name
|
|
|
+ inputInfo.socialNo = res.socialNo
|
|
|
+ inputInfo.district = res.district
|
|
|
+ inputInfo.city = res.city
|
|
|
+ inputInfo.province = res.province
|
|
|
+ inputInfo.address = res.address
|
|
|
+ inputInfo.street = res.street
|
|
|
+ if (res.district) {
|
|
|
+ defaultDistrict.value = res.district
|
|
|
+ } else {
|
|
|
+ defaultDistrict.value = '430105'
|
|
|
+ }
|
|
|
+ showInputDialog.value = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ const inputInfo = reactive({
|
|
|
+ openId: getLocalOpenId(),
|
|
|
+ name: null,
|
|
|
+ socialNo: null,
|
|
|
+ phone: null,
|
|
|
+ address: null,
|
|
|
+ province: null,
|
|
|
+ city: null,
|
|
|
+ district: null,
|
|
|
+ street: null,
|
|
|
+ })
|
|
|
+ const showInputDialog = ref(false)
|
|
|
+ const showArea = ref(false)
|
|
|
+ const onConfirmArea = (values) => {
|
|
|
+ inputInfo.province = values[0].code
|
|
|
+ inputInfo.city = values[1].code
|
|
|
+ inputInfo.district = values[2].code
|
|
|
+ inputInfo.address = values
|
|
|
+ .filter((item) => !!item)
|
|
|
+ .map((item) => item.name)
|
|
|
+ .join('/')
|
|
|
+ showArea.value = false
|
|
|
+ }
|
|
|
+ const beforeClose = (action) =>
|
|
|
+ new Promise((resolve) => {
|
|
|
+ if (action === 'cancel') {
|
|
|
+ showInputDialog.value = false
|
|
|
+ resolve(false)
|
|
|
+ } else {
|
|
|
+ if (!inputInfo.name) {
|
|
|
+ Toast({
|
|
|
+ message: '请输入姓名',
|
|
|
+ position: 'top',
|
|
|
+ })
|
|
|
+ resolve(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!isValidIdcard(inputInfo.socialNo)) {
|
|
|
+ Toast({
|
|
|
+ message: '请输入正确的身份证号码',
|
|
|
+ position: 'top',
|
|
|
+ })
|
|
|
+ resolve(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!isValidPhone(inputInfo.phone)) {
|
|
|
+ Toast({
|
|
|
+ message: '请输入正确的手机号码',
|
|
|
+ position: 'top',
|
|
|
+ })
|
|
|
+ resolve(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!inputInfo.province || !inputInfo.city) {
|
|
|
+ Toast({
|
|
|
+ message: '请选择住址地区',
|
|
|
+ position: 'top',
|
|
|
+ })
|
|
|
+ resolve(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!inputInfo.street) {
|
|
|
+ Toast({
|
|
|
+ message: '请输入街道、小区',
|
|
|
+ position: 'top',
|
|
|
+ })
|
|
|
+ resolve(false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ readInput(inputInfo)
|
|
|
+ .then(() => {
|
|
|
+ Toast.success('建卡成功!')
|
|
|
+ resolve(true)
|
|
|
+ getPatientIdByOpenId(getLocalOpenId()).then((res) => {
|
|
|
+ store.commit('SET_PATIENTCARDS', res)
|
|
|
+ router.go(-1)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ resolve(false)
|
|
|
+ })
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return {
|
|
|
+ uploadWidth,
|
|
|
+ uploadHeight,
|
|
|
+ capImg,
|
|
|
+ defaultDistrict,
|
|
|
+ fileList,
|
|
|
+ disableUpload,
|
|
|
+ uploadIdCard,
|
|
|
+ inputInfo,
|
|
|
+ showInputDialog,
|
|
|
+ showArea,
|
|
|
+ allArea,
|
|
|
+ onConfirmArea,
|
|
|
+ beforeClose,
|
|
|
+ }
|
|
|
+ },
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+#capBox .van-uploader__upload,
|
|
|
+#capBox .van-uploader__preview,
|
|
|
+#capBox .van-uploader__preview-image {
|
|
|
+ width: 100% !important;
|
|
|
+ height: 100% !important;
|
|
|
+}
|
|
|
+
|
|
|
+.cap-tip p {
|
|
|
+ font-size: 13px;
|
|
|
+ margin-left: 10px;
|
|
|
+ color: orangered;
|
|
|
+}
|
|
|
+</style>
|