123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- <template>
- <div class="ocr-all">
- <div style="color: #606266;font-size: 15px;font-weight: 600;">PS:选择图片后,点击要需要识别类型!</div>
- <div class="ocr-box">
- <el-upload
- action="#"
- list-type="picture-card"
- :on-change="handleChangePicture"
- :auto-upload="false">
- <i slot="default" class="el-icon-plus"></i>
- <div slot="file" slot-scope="{file}">
- <img
- class="el-upload-list__item-thumbnail"
- :src="file.url" alt=""
- >
- <span class="el-upload-list__item-actions">
- <span
- class="el-upload-list__item-preview"
- @click="handlePictureCardPreview(file)"
- >
- <i class="el-icon-zoom-in"></i>
- </span>
- <!-- <span
- v-if="!disabled"
- class="el-upload-list__item-delete"
- @click="handleDownload(file)"
- >
- <i class="el-icon-download"></i>
- </span>
- <span
- v-if="!disabled"
- class="el-upload-list__item-delete"
- @click="handleRemove(file)"
- >
- <i class="el-icon-delete"></i>
- </span> -->
- </span>
- </div>
- </el-upload>
- <el-dialog :visible.sync="dialogVisible">
- <img width="100%" :src="dialogImageUrl" alt="">
- </el-dialog>
- </div>
- <div style="color: #606266;font-size: 15px;font-weight: 600;text-align: center;">上传图片只能是 JPG,PNG,BMP 格式!大小不能超过 7MB!</div>
- <el-row>
- <el-button type="primary" @click="license()">营业执照</el-button>
- <el-button type="primary" @click="IDcardR()">身份证-人像面</el-button>
- <el-button type="primary" @click="creditCode()">统一信用代码</el-button>
- <el-button type="primary" @click="IDcardG()">身份证-国徽面</el-button>
- <el-button type="primary" @click="driving()">行驶证</el-button>
- <el-button type="primary" @click="household()">户口本</el-button>
- <el-button type="primary" @click="deed()">房产证</el-button>
- <el-button type="primary" @click="Marriage()">结婚证</el-button>
- <el-button type="primary" @click="mainlandPassport()">大陆护照</el-button>
- <el-button type="primary" @click="universal()">通用印刷体</el-button>
- <el-button type="primary">营业执照(英文)</el-button>
- <el-button type="primary">统一信用代码(英文)</el-button>
- <el-button type="primary">身份证-人像面(英文)</el-button>
- <el-button type="primary">身份证-国徽面(英文)</el-button>
- <el-button type="primary">行驶证(英文)</el-button>
- <el-button type="primary">户口本(英文)</el-button>
- <!-- <el-button type="primary">户口本-成员页</el-button> -->
- <!-- <el-button type="primary">户口本-成员页(英文)</el-button> -->
- <el-button type="primary">房产证(英文)</el-button>
- <el-button type="primary">结婚证(英文)</el-button>
- <el-button type="primary">大陆护照(英文)</el-button>
- <el-button type="primary">通用印刷体(英文)</el-button>
- </el-row>
- </div>
- </template>
- <script>
- import { el } from '@fullcalendar/core/internal-common';
- export default {
- data() {
- return {
- token:'',
- userid:'',
- dialogImageUrl: '',
- dialogVisible: false,
- disabled: false,
- panduan:"",
- picBase64:''
- }
- },
- methods: {
- // handleRemove(file,) {
- // console.log(file);
- // file.status='cancel'
- // },
- handlePictureCardPreview(file) {
- this.dialogImageUrl = file.url;
- this.dialogVisible = true;
- },
- // handleDownload(file) {
- // console.log(file);
- // },
- handleChangePicture(file, fileList) {
- this.beforeAvatarUpload(file)
- if (fileList.length > 1) {
- fileList.splice(0, 1);
- }
- if(this.panduan){
- this.getBase64(file.raw).then(res => {
- this.picBase64=res
- console.log(res)
- });
- }
- },
- beforeAvatarUpload(file) {
- this.panduan=true;
- const isJPG = file.raw.type === 'image/jpeg';
- const isPNG = file.raw.type === 'image/png';
- const isWEBP = file.raw.type === 'image/webp';
- const isLt2M = file.size / 1024 / 1024 < 7;
- if (!isJPG&&!isPNG&&!isWEBP) {
- this.$message.error('上传图片只能是 JPG,PNG,BMP 格式!');
- this.panduan=false;
- }
- if (!isLt2M) {
- this.$message.error('上传图片大小不能超过 7MB!');
- this.panduan=false;
- }
- return isJPG && isLt2M;
- },
- getBase64(file) {
- return new Promise(function (resolve, reject) {
- const reader = new FileReader()
- let imgResult = ''
- reader.readAsDataURL(file)
- reader.onload = function () {
- imgResult = reader.result
- }
- reader.onerror = function (error) {
- reject(error)
- }
- reader.onloadend = function () {
- resolve(imgResult)
- }
- })
- },
- //身份证人像面
- IDcardR(){
- var url="/api/TencentOCR/GetIDCard"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- portType: 1,
- userId:that.userid,
- language:'en',
- picBase64:that.picBase64,
- cardSide:0
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //身份证国徽面
- IDcardG(){
- var url="/api/TencentOCR/GetIDCard"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- portType: 1,
- userId:that.userid,
- picBase64:that.picBase64,
- cardSide:1
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //营业执照
- license(){
- var url="/api/TencentOCR/GetBizLicenseOCR"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //统一信用代码
- creditCode(){
- var url="/api/TencentOCR/GetOrgCodeCertOCR"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //行驶证
- driving(){
- var url="/api/TencentOCR/GetVehicleLicense"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- cardSide:0
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //户口本
- household(){
- var url="/api/TencentOCR/GetResidenceBookletOCR"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //房产证
- deed(){
- var url="/api/TencentOCR/GetPropOwnerCert"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //结婚证
- Marriage(){
- var url="/api/TencentOCR/GetMarriageLicense"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //结婚证
- mainlandPassport(){
- var url="/api/TencentOCR/GetPassport"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- //通用印刷体
- universal(){
- var url="/api/TencentOCR/GetGeneralBasic"
- var that=this
- if(that.panduan){
- that.fullscreenLoading = true;
- this.$axios({
- method: 'post',
- url:url,
- headers:{
- Authorization:'Bearer '+this.token
- },
- data:{
- picBase64:that.picBase64,
- }
- }).then(function(res){
- if(res.data.code==200){
- console.log(res)
- that.$message({
- message: res.data.msg,
- type: 'success'
- });
- // window.open(res.data.data.downUrl)
- }else{
- that.$message({
- message: res.data.msg,
- type: 'warning'
- });
- }
- })
- }else{
- this.$message.error('请检查图片是否为此类型!');
- }
- },
- },
- mounted(){
- this.token=JSON.parse(localStorage.getItem('userinif')).token;
- this.userid=JSON.parse(localStorage.getItem('userinif')).userInfo.userId;
- }
- }
- </script>
- <style>
- .ocr-all {
- background-color: #fff;
- padding: 10px;
- box-shadow: 0 0 5px #0005;
- border-radius: 10px;
- }
- .ocr-box .el-upload-list--picture-card .el-upload-list__item{
- display: inline-flex;
- }
- .ocr-box{
- display: flex;
- justify-content: center;
- margin-top: 180px;
- }
- .ocr-all .el-button--primary{
- width: 160px;
- margin: 10px 0px;
- }
- .ocr-all .el-button+.el-button{
- margin-left: 0px;
- }
- .ocr-all .el-row{
- width: 44%;
- margin: 0 auto;
- margin-top: 30px;
- margin-bottom: 180px;
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- .ocr-all .el-row::after, .ocr-all .el-row::before{
- content: none;
- }
- </style>
|