123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807 |
- <template>
- <view class="page">
- <u-popup v-model="ShowModal" :mode="mode" @close="close" :border-radius="borderRadius" :zoom="zoom">
- <view class="stips">
- <view class="tabs">
- <u-tabs style="justify-content: flex-start;" :list="tabslist" :show-bar="false"
- active-color="#232832" :is-scroll="false" :current="tabsCurrent" @change="tabschange"
- bar-width="60"></u-tabs>
- </view>
- <view class="upload dis j-s">
- <template v-if="checkType=='carInfo'">
- <view class="imgOcr-border">
- <image :src=" carfrontImg?carfrontImg:'/static/image/car-insure/carfront.png'" mode=""
- @click="carfrontChange"></image>
- </view>
- <view class="imgOcr-border">
- <image :src="carbackImg?carbackImg:'/static/image/car-insure/carback.png'" mode=""
- @click="carbackChange"></image>
- </view>
- </template>
- <template v-else>
- <view class="imgOcr-border">
- <image :src=" userfrontImg?userfrontImg:'/static/image/car-insure/userfront.png'" mode=""
- @click="userfrontChange"></image>
- </view>
- <view class="imgOcr-border">
- <image :src="userbackImg?userbackImg:'/static/image/car-insure/userback.png'" mode=""
- @click="userbackChange"></image>
- </view>
- </template>
- </view>
- <view class="operateBtn dis ">
- <view class="cancel dis a-c j-c" @click="ShowModal=false">
- 关闭
- </view>
- <view v-if="checkType=='carInfo'" class="confirm dis a-c j-c" @click="ocrInt">
- 识别
- </view>
- <view v-if="checkType=='ownerInfo'" class="confirm dis a-c j-c" @click="userocrInt1">
- 识别
- </view>
- <view v-if="checkType=='policyHolderInfo'" class="confirm dis a-c j-c" @click="userocrInt2">
- 识别
- </view>
- <view v-if="checkType=='insuredPersonInfo'" class="confirm dis a-c j-c" @click="userocrInt3">
- 识别
- </view>
- </view>
- </view>
- </u-popup>
- <view class="mask mask-show" v-if="lodingshow">
- <!-- 加载动画开始 -->
- <view class="preloader">
- <view class="loader"></view>
- </view>
- <!-- 加载动画结束 -->
- <view class="title">加载中...</view>
- </view>
- </view>
- </template>
- <script>
- import {
- getAgeByIdCard,
- addressCode,
- } from '@/plugins/utils';
- import store from '@/store';
- import {
- props
- } from 'bluebird';
- export default {
- name: 'name', //插件名称
- props: {
- showModal: {
- type: Boolean,
- required: true
- },
- mode: {
- type: String,
- default: 'bottom'
- },
- borderRadius: {
- type: String,
- default: '16'
- },
- zoom: {
- type: Boolean,
- default: false,
- },
- tabsCurrent: {
- type: Number,
- default: 0,
- },
- tabslist: Array,
- checkType: {
- type: String,
- required: true
- }
- },
- computed: {
- },
- data() {
- return {
- ShowModal: this.showModal,
- Current: this.tabsCurrent,
- carfrontImg: "",
- carbackImg: "",
- carInfoPositiveList: [],
- carfront: {},
- carback: {},
- userfront: {},
- userback: {},
- userfrontImg: "",
- userbackImg: "",
- ownerInfoPositiveList: [],
- applicantInfoPositiveList: [],
- InsuredInfoPositiveList: [],
- lodingshow: false,
- };
- },
- watch: {
- showModal(newVal) {
- this.ShowModal = newVal;
- },
- },
- methods: {
- isEmptyObject(obj) {
- return JSON.stringify(obj) === '{}';
- },
- userocrInt1() {
- let Info = Object.assign({}, this.userfront, this.userback)
- if (this.isEmptyObject(Info)) {
- uni.showToast({
- icon: 'none',
- title: '未检测到图片',
- duration: 1500
- });
- } else {
- let ImgList = this.ownerInfoPositiveList;
- let frontImg = this.userfrontImg;
- let backImg = this.userbackImg;
- this.$emit('ownerInfoCallback', {
- Info,
- ImgList,
- frontImg,
- backImg,
- });
- this.userfrontImg = '';
- this.userbackImg = '';
- this.carfrontImg = '';
- this.carbackImg = '';
- }
- },
- userocrInt2() {
- let Info = Object.assign({}, this.userfront, this.userback)
- if (this.isEmptyObject(Info)) {
- uni.showToast({
- icon: 'none',
- title: '未检测到图片',
- duration: 1500
- });
- } else {
- let ImgList = this.applicantInfoPositiveList;
- let frontImg = this.userfrontImg;
- let backImg = this.userbackImg;
- this.$emit('applicantInfoCallback', {
- Info,
- ImgList,
- frontImg,
- backImg,
- });
- this.userfrontImg = '';
- this.userbackImg = '';
- this.carfrontImg = '';
- this.carbackImg = '';
- }
- },
- userocrInt3() {
- let Info = Object.assign({}, this.userfront, this.userback)
- if (this.isEmptyObject(Info)) {
- uni.showToast({
- icon: 'none',
- title: '未检测到图片',
- duration: 1500
- });
- } else {
- let ImgList = this.InsuredInfoPositiveList;
- let frontImg = this.userfrontImg;
- let backImg = this.userbackImg;
- this.$emit('InsuredInfoCallback', {
- Info,
- ImgList,
- frontImg,
- backImg,
- });
- this.userfrontImg = '';
- this.userbackImg = '';
- this.carfrontImg = '';
- this.carbackImg = '';
- }
- },
- ocrInt() {
- let Info = Object.assign({}, this.carfront, this.carback)
- if (this.isEmptyObject(Info)) {
- uni.showToast({
- icon: 'none',
- title: '未检测到图片',
- duration: 1500
- });
- } else {
- let ImgList = this.carInfoPositiveList;
- let frontImg = this.carfrontImg;
- let backImg = this.carbackImg;
- this.$emit('carCallback', {
- Info,
- ImgList,
- frontImg,
- backImg,
- });
- this.userfrontImg = '';
- this.userbackImg = '';
- this.carfrontImg = '';
- this.carbackImg = '';
- }
- },
- async carfrontChange() {
- let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
- count: 1,
- sizeType: ['compressed']
- });
- let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
- if (!size) {
- this.$refs.uToast.show({
- title: '上传图片大小不能超过 5MB!',
- type: 'error',
- })
- return false
- }
- if (chooseImageRes) {
- this.lodingshow = true;
- this.carfrontImg = chooseImageRes.tempFilePaths[0];
- uni.uploadFile({
- url: this.$base.baseUrl + '/ins/taskImage/uploadFile',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "multipartFile",
- formData: {
- 'type': 'image',
- },
- header: {
- Authorization: store.state.token,
- },
- success: (imgRes) => {
- let data = JSON.parse(imgRes.data);
- if (data.code == '200') {
- if (this.carInfoPositiveList.some(v => v.imageType == 'C01')) {
- this.carInfoPositiveList.map(val => {
- if (val.imageType == 'C01') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.carInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "C01",
- })
- }
- uni.uploadFile({
- url: this.$base.baseUrl + '/order/identify/drivingPermit',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "image1",
- header: {
- Authorization: store.state.token,
- },
- success: (uploadFileRes) => {
- let data = JSON.parse(uploadFileRes.data).data;
- let rdate = '';
- if (!!data.carInfo.registerDate) {
- rdate = data.carInfo.registerDate.substr(0,
- 4) +
- '-' + data.carInfo
- .registerDate.substr(4, 2) + '-' + data
- .carInfo
- .registerDate
- .substr(6,
- 2)
- }
- let isdate = '';
- if (!!data.carInfo.issueDate) {
- isdate = data.carInfo.issueDate.substr(0, 4) +
- '-' + data.carInfo
- .issueDate.substr(4, 2) + '-' + data
- .carInfo
- .issueDate.substr(6, 2)
- }
- this.carfront = {
- carOwner: data.carInfo.carOwner, //车主
- licenseNo: data.carInfo.plateNo, //车牌号
- modelcname: data.carInfo.backOcrID, //品牌型号
- frameNo: data.carInfo.vin, //车架号
- engineNo: data.carInfo.engine, //发动机号
- vinNo: data.carInfo.vin, //车架号
- issueDate: isdate, //发证日期
- registerDate: rdate, //注册日期
- cimodelclass: data.carInfo
- .plateType, //车辆种类
- cartype: data.carInfo.category, //车辆类型
- vehicleUse: data.carInfo.vehicleUse, //车辆用途
- }
- this.lodingshow = false;
- }
- });
- }
- }
- });
- } else {
- this.lodingshow = false;
- }
- },
- async carbackChange() {
- let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
- count: 1,
- sizeType: ['compressed']
- });
- let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
- if (!size) {
- this.$refs.uToast.show({
- title: '上传图片大小不能超过 5MB!',
- type: 'error',
- })
- return false
- }
- if (chooseImageRes) {
- this.lodingshow = true;
- this.carbackImg = chooseImageRes.tempFilePaths[0];
- uni.uploadFile({
- url: this.$base.baseUrl + '/ins/taskImage/uploadFile',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "multipartFile",
- formData: {
- 'type': 'image',
- },
- header: {
- Authorization: store.state.token,
- },
- success: (imgRes) => {
- let data = JSON.parse(imgRes.data);
- if (data.code == '200') {
- if (this.carInfoPositiveList.some(v => v.imageType == 'D01')) {
- this.carInfoPositiveList.map(val => {
- if (val.imageType == 'D01') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.carInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "D01",
- })
- }
- uni.uploadFile({
- url: this.$base.baseUrl + '/order/identify/drivingPermit',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "image2",
- header: {
- Authorization: store.state.token,
- },
- success: (uploadFileRes) => {
- let data1 = JSON.parse(uploadFileRes.data).data;
- this.carback = {
- vehicleweight: data1.carInfo
- .grossMass, //总质量
- completeKerbMass: data1.carInfo
- .unladenMass, //整备质量
- seatCount: data1.carInfo
- .approvedPassengersCapacity, //核定载客数
- limitLoad: data1.carInfo
- .limitLoad, //核定载质量
- }
- this.lodingshow = false;
- }
- });
- }
- }
- });
- } else {
- this.lodingshow = false;
- }
- },
- async userfrontChange() {
- let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
- count: 1,
- sizeType: ['compressed']
- });
- let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
- if (!size) {
- this.$refs.uToast.show({
- title: '上传图片大小不能超过 5MB!',
- type: 'error',
- })
- return false
- }
- if (chooseImageRes) {
- this.lodingshow = true;
- this.userfrontImg = chooseImageRes.tempFilePaths[0];
- uni.uploadFile({
- url: this.$base.baseUrl + '/ins/taskImage/uploadFile',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "multipartFile",
- formData: {
- 'type': 'image',
- },
- header: {
- Authorization: store.state.token,
- },
- success: (imgRes) => {
- let data = JSON.parse(imgRes.data);
- if (data.code == '200') {
- switch (this.checkType) {
- case 'ownerInfo':
- if (this.ownerInfoPositiveList.some(v => v.imageType == 'C02')) {
- this.ownerInfoPositiveList.map(val => {
- if (val.imageType == 'C02') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.ownerInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "C02",
- })
- }
- break;
- case 'policyHolderInfo':
- if (this.applicantInfoPositiveList.some(v => v.imageType ==
- 'C03')) {
- this.applicantInfoPositiveList.map(val => {
- if (val.imageType == 'C03') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.applicantInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "C03",
- })
- }
- break;
- case 'insuredPersonInfo':
- if (this.InsuredInfoPositiveList.some(v => v.imageType == 'C04')) {
- this.InsuredInfoPositiveList.map(val => {
- if (val.imageType == 'C04') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.InsuredInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "C04",
- })
- }
- break;
- default:
- break;
- };
- uni.uploadFile({
- url: this.$base.baseUrl + '/order/identify/idCard',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "image1",
- header: {
- Authorization: store.state.token,
- },
- success: (uploadFileRes) => {
- let data = JSON.parse(uploadFileRes.data).data;
- this.userfront = {
- age: getAgeByIdCard(data.customerInfo
- .identifyNumber),
- name: data.customerInfo.name,
- gender: data.customerInfo
- .identifyIssuedCom,
- identifyNumber: data.customerInfo
- .identifyNumber,
- addr: data.customerInfo.addr,
- }
- this.lodingshow = false;
- }
- });
- }
- }
- });
- } else {
- this.lodingshow = false;
- }
- },
- async userbackChange() {
- let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
- count: 1,
- sizeType: ['compressed']
- });
- let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
- if (!size) {
- this.$refs.uToast.show({
- title: '上传图片大小不能超过 5MB!',
- type: 'error',
- })
- return false
- }
- if (chooseImageRes) {
- this.lodingshow = true;
- this.userbackImg = chooseImageRes.tempFilePaths[0];
- uni.uploadFile({
- url: this.$base.baseUrl + '/ins/taskImage/uploadFile',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "multipartFile",
- formData: {
- 'type': 'image',
- },
- header: {
- Authorization: store.state.token,
- },
- success: (imgRes) => {
- let data = JSON.parse(imgRes.data);
- if (data.code == '200') {
- switch (this.checkType) {
- case 'ownerInfo':
- if (this.ownerInfoPositiveList.some(v => v.imageType == 'D02')) {
- this.ownerInfoPositiveList.map(val => {
- if (val.imageType == 'D02') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.ownerInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "D02",
- })
- }
- break;
- case 'policyHolderInfo':
- if (this.applicantInfoPositiveList.some(v => v.imageType ==
- 'D03')) {
- this.applicantInfoPositiveList.map(val => {
- if (val.imageType == 'D03') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.applicantInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "D03",
- })
- }
- break;
- case 'insuredPersonInfo':
- if (this.InsuredInfoPositiveList.some(v => v.imageType == 'D04')) {
- this.InsuredInfoPositiveList.map(val => {
- if (val.imageType == 'D04') {
- val.imageId = data.data.id;
- }
- })
- } else {
- this.InsuredInfoPositiveList.push({
- imageId: data.data.id,
- imageType: "D04",
- })
- }
- break;
- default:
- break;
- };
- uni.uploadFile({
- url: this.$base.baseUrl + '/order/identify/idCard',
- filePath: chooseImageRes.tempFilePaths[0],
- name: "image2",
- header: {
- Authorization: store.state.token,
- },
- success: (uploadFileRes) => {
- let data1 = JSON.parse(uploadFileRes.data).data;
- let identifyValidDate = '';
- if (!!data1.customerInfo
- .identifyValidDate) {
- identifyValidDate = data1
- .customerInfo
- .identifyValidDate
- .substr(0, 4) +
- '-' + data1
- .customerInfo
- .identifyValidDate
- .substr(4, 2) + '-' +
- data1
- .customerInfo
- .identifyValidDate
- .substr(6,
- 2)
- }
- let identifyValidEndDate = '';
- if (!!data1.customerInfo
- .identifyValidEndDate) {
- identifyValidEndDate =
- data1.customerInfo
- .identifyValidEndDate
- .substr(0,
- 4) + '-' + data1
- .customerInfo
- .identifyValidEndDate
- .substr(4, 2) + '-' +
- data1
- .customerInfo
- .identifyValidEndDate
- .substr(6, 2)
- }
- this.userback = {
- identifyValidDate: identifyValidDate, //起期
- identifyValidEndDate: identifyValidEndDate ==
- '长期--' ? '9999-12-31' :
- identifyValidEndDate, //止期
- }
- this.lodingshow = false;
- }
- });
- }
- }
- });
- } else {
- this.lodingshow = false;
- }
- },
- //弹框关闭
- close() {
- this.$emit('closePopup');
- },
- //tab切换
- tabschange(e) {
- this.$emit('tabschange', e);
- }
- }
- };
- </script>
- <!--使用scss,只在本组件生效-->
- <style lang="scss" scoped>
- .tabs {
- padding: 0 15px;
- border: 1px solid #f2f2f2;
- }
- .upload {
- width: 100%;
- height: 146px;
- padding: 15px 20px;
- background-color: white;
- .imgOcr-border {
- position: relative;
- width: 48%;
- height: 100%;
- padding: 2px;
- background-color: #fff;
- box-shadow: 0px 4px 10px 0px #DAE3F4;
- image {
- width: 100%;
- border-radius: 4px;
- height: 100%;
- }
- .del_btn {
- position: absolute;
- cursor: pointer;
- position: absolute;
- top: 5rpx;
- right: 0;
- width: 50rpx;
- height: 50rpx;
- border-radius: 50%;
- z-index: 20;
- }
- }
- }
- .operateBtn {
- font-weight: bold;
- font-size: 16px;
- .cancel {
- width: 50%;
- height: 46px;
- color: #0052FF;
- background-color: #EAEAEA;
- }
- .confirm {
- width: 50%;
- height: 46px;
- color: #fff;
- background-color: #0052FF;
- }
- }
- .mask {
- /* pointer-events: none; */
- position: fixed;
- z-index: 99999;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- height: 100vh;
- width: 100vw;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- flex-wrap: wrap;
- }
- .mask.mask-show {
- background: rgba(255, 255, 255, 0.3);
- }
- .title {
- color: #333;
- font-size: 28rpx;
- margin-top: 20rpx;
- }
- .loader {
- display: block;
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- border: 3rpx solid transparent;
- border-top-color: #9370db;
- -webkit-animation: spin 2s linear infinite;
- animation: spin 2s linear infinite;
- }
- .loader::before {
- content: "";
- position: absolute;
- top: 5rpx;
- left: 5rpx;
- right: 5rpx;
- bottom: 5rpx;
- border-radius: 50%;
- border: 3rpx solid transparent;
- border-top-color: #ba55d3;
- -webkit-animation: spin 3s linear infinite;
- animation: spin 3s linear infinite;
- }
- .loader::after {
- content: "";
- position: absolute;
- top: 15rpx;
- left: 15rpx;
- right: 15rpx;
- bottom: 15rpx;
- border-radius: 50%;
- border: 3rpx solid transparent;
- border-top-color: #ff00ff;
- -webkit-animation: spin 1.5s linear infinite;
- animation: spin 1.5s linear infinite;
- }
- @-webkit-keyframes spin {
- 0% {
- -webkit-transform: rotate(0deg);
- -ms-transform: rotate(0deg);
- transform: rotate(0deg);
- }
- 100% {
- -webkit-transform: rotate(360deg);
- -ms-transform: rotate(360deg);
- transform: rotate(360deg);
- }
- }
- @keyframes spin {
- 0% {
- -webkit-transform: rotate(0deg);
- -ms-transform: rotate(0deg);
- transform: rotate(0deg);
- }
- 100% {
- -webkit-transform: rotate(360deg);
- -ms-transform: rotate(360deg);
- transform: rotate(360deg);
- }
- }
- </style>
|