GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
hanfei
/
VueSharedPrinting
Browse code
han
master
1 parent
48e5f7c
commit
f69cdecd9679f5b78e4ad7288f6997a964400501
hanfei
authored
on 24 Jan 2024
Patch
Showing
5 changed files
src/components/top.vue
src/views/advertising.vue
src/views/complete.vue
src/views/device.vue
src/views/selectFile.vue
Ignore Space
Show notes
View
src/components/top.vue
<template> <div class="top flex-between"> <div class="logo flex-start" @click="_goHome()"> <img src="../assets/logo.png" /> <span></span> <div>天章自助打印</div> </div> <div class="sbzt">{{cite.memberLoginVo?'当前设备正在被使用!':''}}</div> <div class="time flex-start"> <div> <div>{{ time.week }}</div> <div>{{ time.y }}/{{ time.M }}/{{ time.d }}</div> </div> <div class="info">{{ time.h }}:{{ time.m }}</div> </div> <div class="tip flex-start"> <div v-for="(item, index) in cite.facility.paperNumber" :key="index">{{ item.name }}剩余{{ item.residue }}张</div> <!-- <div>{{cite.memberLoginVo?'已登录':'未登录'}}</div>--> </div> </div> </template> <script> export default { name: "top", data() { return { time: {}, } }, mounted() { this.format() }, methods: { add(t) { if(t<10) { return '0' + t } return t }, format() { let date = new Date(); let o = { "y": date.getFullYear(), //年 "M": this.add(date.getMonth() + 1), //月份 "d": this.add(date.getDate()), //日 "h": this.add(date.getHours()), //小时 "m": this.add(date.getMinutes()), //分 "week": '', }; let str = "星期"; switch (date.getDay()) { case 0 : str += "日"; break; case 1 : str += "一"; break; case 2 : str += "二"; break; case 3 : str += "三"; break; case 4 : str += "四"; break; case 5 : str += "五"; break; case 6 : str += "六"; break; } o.week = str this.time = o setTimeout(() =>{ this.format() },1000) }, _goHome() { // this.quit() this.$router.push({ name: 'device' }) } } } </script> <style scoped lang="less"> .top { width: 100%; height: 9.81rem; background: #52A39D; position: relative; .logo { padding-left: 5.5rem; font-size: 3.5rem; font-weight: 400; color: #FFFFFF; line-height: 3.69rem; img { width: 5.56rem; height: 5.56rem; } span { width: 0; height: 4.43rem; border-left: 1px solid #FFFFFF; margin: 0 1.94rem; } } .time { padding-right: 3.88rem; font-size: 1.38rem; font-weight: 400; color: #FFFFFF; line-height: 1.94rem; text-align: right; .info { font-weight: bold; color: #FFFFFF; margin-left: 1.13rem; font-size: 3.69rem; line-height: 5.2rem; } } .tip { position: absolute; bottom: .5rem; right: 3.88rem; font-size: 1.2rem; color: #fff; div { margin-left: 2rem; } } .sbzt { font-size: 3rem; font-weight: bold; color: #FFFFFF; } } </style>
<template> <div class="top flex-between"> <div class="logo flex-start" @click="_goHome()"> <img src="../assets/logo.png" /> <span></span> <div>天章自助打印</div> </div> <div class="sbzt">{{cite.memberLoginVo?'当前设备正在被使用!':''}}</div> <div class="time flex-start"> <div> <div>{{ time.week }}</div> <div>{{ time.y }}/{{ time.M }}/{{ time.d }}</div> </div> <div class="info">{{ time.h }}:{{ time.m }}</div> </div> <div class="tip flex-start"> <div v-for="(item, index) in cite.facility.paperNumber" :key="index">{{ item.name }}剩余{{ item.residue }}张</div> <!-- <div>{{cite.memberLoginVo?'已登录':'未登录'}}</div>--> </div> </div> </template> <script> export default { name: "top", data() { return { time: {}, } }, mounted() { this.format() }, methods: { add(t) { if(t<10) { return '0' + t } return t }, format() { let date = new Date(); let o = { "y": date.getFullYear(), //年 "M": this.add(date.getMonth() + 1), //月份 "d": this.add(date.getDate()), //日 "h": this.add(date.getHours()), //小时 "m": this.add(date.getMinutes()), //分 "week": '', }; let str = "星期"; switch (date.getDay()) { case 0 : str += "日"; break; case 1 : str += "一"; break; case 2 : str += "二"; break; case 3 : str += "三"; break; case 4 : str += "四"; break; case 5 : str += "五"; break; case 6 : str += "六"; break; } o.week = str this.time = o setTimeout(() =>{ this.format() },1000) }, _goHome() { this.quit() // this.$router.push({ // name: 'device' // }) } } } </script> <style scoped lang="less"> .top { width: 100%; height: 9.81rem; background: #52A39D; position: relative; .logo { padding-left: 5.5rem; font-size: 3.5rem; font-weight: 400; color: #FFFFFF; line-height: 3.69rem; img { width: 5.56rem; height: 5.56rem; } span { width: 0; height: 4.43rem; border-left: 1px solid #FFFFFF; margin: 0 1.94rem; } } .time { padding-right: 3.88rem; font-size: 1.38rem; font-weight: 400; color: #FFFFFF; line-height: 1.94rem; text-align: right; .info { font-weight: bold; color: #FFFFFF; margin-left: 1.13rem; font-size: 3.69rem; line-height: 5.2rem; } } .tip { position: absolute; bottom: .5rem; right: 3.88rem; font-size: 1.2rem; color: #fff; div { margin-left: 2rem; } } .sbzt { font-size: 3rem; font-weight: bold; color: #FFFFFF; } } </style>
Ignore Space
Show notes
View
src/views/advertising.vue
<template> <div class="advertising flex-center"> <div v-if="advertisement.length<1">广告位招租</div> <img v-else :src="advertisement[0].previewPath" model="scaleToFill"/> <!-- <img v-else-if="advertisement.fileType=='image/png'" :src="advertisement.previewPath" model="scaleToFill"/>--> <!-- <video v-else autoplay loop muted :src="advertisement.outerChainPath" style="width: 100%;height: 100%;"></video>--> </div> </template> <script> export default { name: "advertising", data() { return { advertisement: '' }; }, mounted() { setInterval(()=>{ if(this.cite.advertisement != this.advertisement) { this.advertisement = this.cite.advertisement } },300) }, } </script> <style> #app .top { display: none; } .advertising { background: linear-gradient(359deg, #3dbf51 0%, #47d1a9 100%); width: 100%; height: 100%; position: fixed; font-size: 10rem; font-weight: bold; color: #ffffff; line-height: 10rem; } .advertising img { width: 100%; height: 100%; } </style>
<template> <div class="advertising flex-center" :style="advertisement==''?'':'background: #000'"> <div v-if="advertisement==''">广告位招租</div> <img v-else-if="advertisement.fileType=='image/png'" :src="advertisement.previewPath" model="scaleToFill"/> <video v-else autoplay loop muted :src="advertisement.outerChainPath" style="width: 100%;height: 100%;"></video> </div> </template> <script> export default { name: "advertising", data() { return { advertisement: '' }; }, mounted() { // setInterval(()=>{ // if(this.cite.advertisement != this.advertisement) { // this.advertisement = this.cite.advertisement // } // },300) }, } </script> <style> #app .top { display: none; } .advertising { background: linear-gradient(359deg, #3dbf51 0%, #47d1a9 100%); width: 100%; height: 100%; position: fixed; font-size: 10rem; font-weight: bold; color: #ffffff; line-height: 10rem; } .advertising img { width: 100%; height: 100%; } </style>
Ignore Space
Show notes
View
src/views/complete.vue
<template> <!--打印完成--> <div class="complete"> <div class="box flex-center"> <div class="left"> <img src="../assets/complete.png" alt=""> <div>打印完成</div> <div>感谢您使用天章自助打印服务</div> </div> <div class="right"> <div class="title flex-center">温馨提示</div> <div class="content">请您立刻时,从出纸口取走您的打印件,并带齐您的资料和所有随身物品。</div> <div class="tip" v-show="false"> <div>本次打印您将获得:</div> <div class="flex-center"> <img src="../assets/points.png" alt=""><span>28积分</span> </div> </div> </div> </div> </div> </template> <script> export default { name: "complete", mounted() { this.load(0) }, methods: { load(n) { if(n<10) { setTimeout(()=>{ this.load(n+1) },1000) }else{ // this.quit() this.$router.push({ name: 'device' }) } }, } } </script> <style scoped lang="less"> .box { width: 114.06rem; height: 49.25rem; background: #FFFFFF; box-shadow: 0rem 0.31rem 0.63rem 0.06rem rgba(0,0,0,0.14); border-radius: 1.63rem; margin: 3.75rem auto 0; font-size: 1.88rem; font-weight: bold; color: #323232; line-height: 2rem; .left { margin-right: 14.94rem; img { width: 26.88rem; margin-bottom: 5.06rem; } } .right { width: 42.13rem; text-align: left; .title { font-size: 2.88rem; font-weight: bold; color: #D41212; line-height: 4.06rem; } .content { font-size: 2.25rem; font-weight: bold; color: #323232; line-height: 3rem; margin: 2.94rem auto 6.25rem; } .tip { img { width: 7.38rem; margin-right: 1.13rem; } span { font-size: 2.13rem; font-weight: bold; color: #323232; line-height: 3rem; } } } } </style>
<template> <!--打印完成--> <div class="complete"> <div class="box flex-center"> <div class="left"> <img src="../assets/complete.png" alt=""> <div>打印完成</div> <div>感谢您使用天章自助打印服务</div> </div> <div class="right"> <div class="title flex-center">温馨提示</div> <div class="content">请您立刻时,从出纸口取走您的打印件,并带齐您的资料和所有随身物品。</div> <div class="tip" v-show="false"> <div>本次打印您将获得:</div> <div class="flex-center"> <img src="../assets/points.png" alt=""><span>28积分</span> </div> </div> </div> </div> </div> </template> <script> export default { name: "complete", mounted() { this.load(0) }, methods: { load(n) { if(n<10) { setTimeout(()=>{ this.load(n+1) },1000) }else{ this.quit() } }, } } </script> <style scoped lang="less"> .box { width: 114.06rem; height: 49.25rem; background: #FFFFFF; box-shadow: 0rem 0.31rem 0.63rem 0.06rem rgba(0,0,0,0.14); border-radius: 1.63rem; margin: 3.75rem auto 0; font-size: 1.88rem; font-weight: bold; color: #323232; line-height: 2rem; .left { margin-right: 14.94rem; img { width: 26.88rem; margin-bottom: 5.06rem; } } .right { width: 42.13rem; text-align: left; .title { font-size: 2.88rem; font-weight: bold; color: #D41212; line-height: 4.06rem; } .content { font-size: 2.25rem; font-weight: bold; color: #323232; line-height: 3rem; margin: 2.94rem auto 6.25rem; } .tip { img { width: 7.38rem; margin-right: 1.13rem; } span { font-size: 2.13rem; font-weight: bold; color: #323232; line-height: 3rem; } } } } </style>
Ignore Space
Show notes
View
src/views/device.vue
<template> <div class="device"> <div class="box flex-between"> <div class="left"> <div v-if="advertisement==[]" class="advertising icon1 flex-center">广告位招租</div> <div v-else class="advertising flex-center"> <img :src="advertisement[0].previewPath" model="scaleToFill"/> </div> </div> <div class="left swiper-container" v-if="false"> <div class="swiper-wrapper"> <div v-for="(item,index) in advertisement" :key="index" class="swiper-slide"> <!-- 图片--> <div v-if="item.fileType=='image/png'" class="advertising flex-center"> <img :src="item.previewPath" model="scaleToFill"/> </div> <!-- 视频--> <div v-else class="advertising flex-center"> <video :src="item.outerChainPath" autoplay loop muted style="width: 100%;height: 100%;"></video> </div> </div> </div> <div class="swiper-pagination"></div> </div> <div v-if="false" class="left"> <!-- 广告--> <div v-if="advertisement==''" class="advertising icon1 flex-center">广告位招租</div> <!-- 图片--> <div v-else-if="advertisement.fileType=='image/png'" class="advertising icon1 flex-center"> <img :src="advertisement.previewPath" model="scaleToFill"/> </div> <!-- 视频--> <div v-else class="advertising icon1 flex-center"> <video :src="advertisement.outerChainPath" autoplay loop muted style="width: 100%;height: 100%;"></video> </div> <div v-show="false" class="box2 flex-between"> <div class="main2 flex-center" @click="skip('explain', '联系客服')"> <img src="../assets/demo7.png"/>联系客服 </div> <div class="main2 flex-center" @click="skip('explain', '价格查询')"> <img src="../assets/demo5.png"/>价格查询 </div> </div> </div> <div class="right"> <div class="main4 flex-center"> <div> <div class="flex-center ewm" v-if="memberLoginVo!=''"> <div class="zzc flex-center"></div> <VueQr :auto-color="true" :dot-scale="1" :logo-src="require('@/assets/logo.png')" :logoMargin="0" :logoScale=".2" :margin="0" :size="300" :text="''" logoBackgroundColor="white"> </VueQr> </div> <div class="flex-center ewm" v-else> <VueQr v-if="appSrc" :auto-color="true" :dot-scale="1" :logo-src="require('@/assets/logo.png')" :logoMargin="0" :logoScale=".2" :margin="0" :size="300" :text="appSrc" logoBackgroundColor="white"> </VueQr> </div> <div class="flex-center tip"> <img src="../assets/demo9.png"/>扫码打印手机文件 </div> </div> </div> <!-- 功能--> <div class="feature"> <div class="main icon2 flex-start" @click="skip('operationGuide', 'U盘打印')" > <img src="../assets/demo2.png"/> <div>U盘打印</div> </div> <div class="main icon3 flex-start" @click="skip('operationGuide', '扫描打印')" > <img src="../assets/demo3.png"/> <div>扫描打印</div> </div> <div class="main icon4 flex-start" @click="skip('operationGuide', '身份证打印')" > <img src="../assets/demo4.png"/> <div>身份证打印</div> </div> </div> </div> <div class="dbTip flex-between"> <div>机器编号:{{ cite.code }}</div> <div>客服电话:{{ facility.servicePhone }}</div> </div> </div> </div> </template> <script> import VueQr from 'vue-qr' export default { name: "device", components: { VueQr }, data() { return { mySwiper: '', appSrc: '', memberLoginVo: '', advertisement: '', facility: '', src: '' }; }, methods: { skip(href, name) { let {facility} = this let {sta, name2} = '' facility.paperNumber.forEach(item => { if (item.residue < 1) { name2 = '请联系管理员添加' + item.name sta = true } }) if (sta == true) { this.cite.state = { name: name2, sta: true } return } if (this.cite.memberLoginVo == '') { this.cite.state = { name: '请扫码登录设备再操作!', sta: true } return } if (href == 'operationGuide') { this.cite.modeName = name } this.$router.push({ name: href, params: { name: name, }, }); }, load() { if (this.src == '') { this.src = this.cite.url setTimeout(() => { this.load() }, 1000) } }, GGT() { this.mySwiper = new this.Swiper('.swiper-container', { pagination: { el: '.swiper-pagination', }, // 改变swiper样式时,自动初始化swiper observer: true, // 监测swiper父元素,如果有变化则初始化swiper observeParents: true, loop: true, autoplay: { delay: 3000, disableOnInteraction: false } }) }, }, mounted() { this.load() setInterval(() => { if (this.cite.advertisement != this.advertisement) { this.advertisement = this.cite.advertisement setTimeout(() => { this.GGT() }, 500) } if (this.cite.facility != this.facility) { this.facility = this.cite.facility } if (this.cite.memberLoginVo != this.memberLoginVo) { this.memberLoginVo = this.cite.memberLoginVo } if (this.appSrc == '' && this.cite.code != '') { this.appSrc = 'https://mps.xlmalls.com/web/' + this.cite.code console.log(this.appSrc) } }, 300) } }; </script> <style lang="less" scoped> .device { margin: 2rem 2rem 0; .box { align-items: flex-start; .left { width: 92.5rem; margin: 0; position: relative; z-index: 1; .advertising { width: 100%; height: 52rem; border-radius: 1.63rem; //margin-bottom: 1.88rem; cursor: pointer; overflow: hidden; font-size: 8rem; font-weight: 400; color: #ffffff; line-height: 8rem; img { width: 100%; height: 100%; } } } .right { width: 22rem; } } .main { width: 100%; height: 8rem; border-radius: 1.63rem; font-size: 1.8rem; font-weight: 400; color: #ffffff; line-height: 1.8rem; margin-top: 1rem; img { width: 8rem; margin-top: -1rem; } } .icon1 { background: linear-gradient(359deg, #3dbf51 0%, #47d1a9 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(120, 229, 217, 0.45); } .icon2 { background: linear-gradient(180deg, #f2c952 0%, #db572b 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(255, 147, 128, 0.57); } .icon3 { background: linear-gradient(180deg, #84b2f7 0%, #8774d2 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(150, 135, 232, 0.3); } .icon4 { background: linear-gradient(180deg, #5be7ff 0%, #309fd8 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(104, 202, 253, 0.42); } .css1 { background: #ffffff; box-shadow: 0rem 0.63rem 1.25rem 0.06rem rgba(0, 0, 0, 0.14); border-radius: 1.63rem; cursor: pointer; } .main2 { width: 100%; height: 6.44rem; .css1(); font-size: 1.88rem; font-weight: bold; color: #323232; line-height: 2.63rem; img { width: 3.75rem; margin-right: 0.38rem; } } .main3 { width: 100%; height: 9.94rem; .css1(); font-size: 2.13rem; font-weight: bold; color: #323232; line-height: 3rem; img { width: 4.25rem; margin-right: 0.88rem; } } .main4 { width: 100%; height: 25rem; .css1(); font-size: 1.88rem; font-weight: 400; color: #323232; line-height: 2rem; .ewm { width: 18rem; height: 18rem; background: #ffffff; border: 0.06rem solid #707070; position: relative; img { width: 100%; margin: 0; } } .tip { margin-top: 1rem; } img { width: 2.31rem; margin-right: 1.19rem; } .zzc { position: absolute; background: #333; opacity: .5; top: 0; left: 0; width: 100%; height: 100%; } } .dbTip { position: fixed; bottom: 0; left: 0; right: 0; font-size: 1.2rem; font-weight: 400; color: #323232; height: 3rem; padding: 0 3rem; } } </style>
<template> <div class="device"> <div class="box flex-between"> <div class="left swiper-container" v-if="false"> <div class="swiper-wrapper"> <div v-for="(item,index) in advertisement" :key="index" class="swiper-slide"> <!-- 图片--> <div v-if="item.fileType=='image/png'" class="advertising flex-center"> <img :src="item.previewPath" model="scaleToFill"/> </div> <!-- 视频--> <div v-else class="advertising flex-center"> <video :src="item.outerChainPath" autoplay loop muted style="width: 100%;height: 100%;"></video> </div> </div> </div> <div class="swiper-pagination"></div> </div> <div class="left"> <!-- 广告--> <div class="advertising icon1 flex-center">广告位招租</div> <!-- 图片--> <!-- <div v-else-if="advertisement.fileType=='image/png'" class="advertising icon1 flex-center">--> <!-- <img :src="advertisement.previewPath" model="scaleToFill"/>--> <!-- </div>--> <!-- <!– 视频–>--> <!-- <div v-else class="advertising icon1 flex-center">--> <!-- <video :src="advertisement.outerChainPath" autoplay loop muted style="width: 100%;height: 100%;"></video>--> <!-- </div>--> <div v-show="false" class="box2 flex-between"> <div class="main2 flex-center" @click="skip('explain', '联系客服')"> <img src="../assets/demo7.png"/>联系客服 </div> <div class="main2 flex-center" @click="skip('explain', '价格查询')"> <img src="../assets/demo5.png"/>价格查询 </div> </div> </div> <div class="right"> <div class="main4 flex-center"> <div> <div class="flex-center ewm" v-if="memberLoginVo!=''"> <div class="zzc flex-center"></div> <VueQr :auto-color="true" :dot-scale="1" :logo-src="require('@/assets/logo.png')" :logoMargin="0" :logoScale=".2" :margin="0" :size="300" :text="''" logoBackgroundColor="white"> </VueQr> </div> <div class="flex-center ewm" v-else> <VueQr v-if="appSrc" :auto-color="true" :dot-scale="1" :logo-src="require('@/assets/logo.png')" :logoMargin="0" :logoScale=".2" :margin="0" :size="300" :text="appSrc" logoBackgroundColor="white"> </VueQr> </div> <div class="flex-center tip"> <img src="../assets/demo9.png"/>扫码打印手机文件 </div> </div> </div> <!-- 功能--> <div class="feature"> <div class="main icon2 flex-start" @click="skip('operationGuide', 'U盘打印')" > <img src="../assets/demo2.png"/> <div>U盘打印</div> </div> <div class="main icon3 flex-start" @click="skip('operationGuide', '扫描打印')" > <img src="../assets/demo3.png"/> <div>扫描打印</div> </div> <div class="main icon4 flex-start" @click="skip('operationGuide', '身份证打印')" > <img src="../assets/demo4.png"/> <div>身份证打印</div> </div> </div> </div> <div class="dbTip flex-between"> <div>机器编号:{{ cite.code }}</div> <div>客服电话:{{ facility.servicePhone }}</div> </div> </div> </div> </template> <script> import VueQr from 'vue-qr' export default { name: "device", components: { VueQr }, data() { return { mySwiper: '', appSrc: '', memberLoginVo: '', advertisement: '', facility: '', src: '' }; }, methods: { skip(href, name) { let {facility} = this let {sta, name2} = '' facility.paperNumber.forEach(item => { if (item.residue < 1) { name2 = '请联系管理员添加' + item.name sta = true } }) if (sta == true) { this.cite.state = { name: name2, sta: true } return } if (this.cite.memberLoginVo == '') { this.cite.state = { name: '请扫码登录设备再操作!', sta: true } return } if (href == 'operationGuide') { this.cite.modeName = name } this.$router.push({ name: href, params: { name: name, }, }); }, load() { if (this.src == '') { this.src = this.cite.url setTimeout(() => { this.load() }, 1000) } }, GGT() { this.mySwiper = new this.Swiper('.swiper-container', { pagination: { el: '.swiper-pagination', }, // 改变swiper样式时,自动初始化swiper observer: true, // 监测swiper父元素,如果有变化则初始化swiper observeParents: true, loop: true, autoplay: { delay: 3000, disableOnInteraction: false } }) }, }, mounted() { this.load() setInterval(() => { if (this.cite.advertisement != this.advertisement) { this.advertisement = this.cite.advertisement setTimeout(() => { this.GGT() }, 500) } if (this.cite.facility != this.facility) { this.facility = this.cite.facility } if (this.cite.memberLoginVo != this.memberLoginVo) { this.memberLoginVo = this.cite.memberLoginVo } if (this.appSrc == '' && this.cite.code != '') { this.appSrc = 'https://mps.xlmalls.com/web/' + this.cite.code console.log(this.appSrc) } }, 300) } }; </script> <style lang="less" scoped> .device { margin: 2rem 2rem 0; .box { align-items: flex-start; .left { width: 92.5rem; margin: 0; position: relative; z-index: 1; .advertising { width: 100%; height: 52rem; border-radius: 1.63rem; //margin-bottom: 1.88rem; cursor: pointer; overflow: hidden; font-size: 8rem; font-weight: 400; color: #ffffff; line-height: 8rem; img { width: 100%; height: 100%; } } } .right { width: 22rem; } } .main { width: 100%; height: 8rem; border-radius: 1.63rem; font-size: 1.8rem; font-weight: 400; color: #ffffff; line-height: 1.8rem; margin-top: 1rem; img { width: 8rem; margin-top: -1rem; } } .icon1 { background: linear-gradient(359deg, #3dbf51 0%, #47d1a9 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(120, 229, 217, 0.45); } .icon2 { background: linear-gradient(180deg, #f2c952 0%, #db572b 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(255, 147, 128, 0.57); } .icon3 { background: linear-gradient(180deg, #84b2f7 0%, #8774d2 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(150, 135, 232, 0.3); } .icon4 { background: linear-gradient(180deg, #5be7ff 0%, #309fd8 100%); box-shadow: 0rem 1.25rem 1.25rem 0.06rem rgba(104, 202, 253, 0.42); } .css1 { background: #ffffff; box-shadow: 0rem 0.63rem 1.25rem 0.06rem rgba(0, 0, 0, 0.14); border-radius: 1.63rem; cursor: pointer; } .main2 { width: 100%; height: 6.44rem; .css1(); font-size: 1.88rem; font-weight: bold; color: #323232; line-height: 2.63rem; img { width: 3.75rem; margin-right: 0.38rem; } } .main3 { width: 100%; height: 9.94rem; .css1(); font-size: 2.13rem; font-weight: bold; color: #323232; line-height: 3rem; img { width: 4.25rem; margin-right: 0.88rem; } } .main4 { width: 100%; height: 25rem; .css1(); font-size: 1.88rem; font-weight: 400; color: #323232; line-height: 2rem; .ewm { width: 18rem; height: 18rem; background: #ffffff; border: 0.06rem solid #707070; position: relative; img { width: 100%; margin: 0; } } .tip { margin-top: 1rem; } img { width: 2.31rem; margin-right: 1.19rem; } .zzc { position: absolute; background: #333; opacity: .5; top: 0; left: 0; width: 100%; height: 100%; } } .dbTip { position: fixed; bottom: 0; left: 0; right: 0; font-size: 1.2rem; font-weight: 400; color: #323232; height: 3rem; padding: 0 3rem; } } </style>
Ignore Space
Show notes
View
src/views/selectFile.vue
<template> <!-- 选取资料--> <div class="selectFile"> <navbar :name="name" /> <!-- U盘打印--> <div class="box flex-center" v-if="name == 'U盘打印'"> <div class="tip" style="width: 20rem;"> <div class="title">温馨提示</div> <div class="content">请在右侧文件浏览区,找到待印资料文件存放的目录(文件夹),然后点选您需要打印的文件,之后按下“确认资料”按钮来提交资料。</div> </div> <div class="file"> <div class="main" style="width: 50rem;"> <div v-for="(item, index) in usbList" v-bind:key="index" class="li flex-start" @click="onChange(index, 'usbList',!item.sta)"> <input type="checkbox" v-model="item.sta"> <div class="name flex-start">{{ item.name }}</div> </div> </div> <div class="flex-between but"> <div class="btn flex-center" @click="skip('argument', name)">确认资料</div> </div> </div> </div> <!-- 扫描打印--> <div class="box flex-center" v-if="name == '扫描打印'"> <div class="file2"> <div class="title flex-between">已完成扫描的版面 <span :class="[{ act: smfyIndex == -1 }]" @click="onChange(-1, 'smfyIndex')">预览</span></div> <div class="main flex-between"> <div class="smfyData"> <div v-for="(item, index) in imgList" v-bind:key="index" :class="['flex-center', { act: smfyIndex == index }]" @click="onChange(index, 'smfyIndex')"> <div class="name">{{ index + 1 }}</div> <span @click="onCancel(index, 'imgList')">删除</span> </div> </div> <img v-show="smfyIndex!=-1" :src="imgList[smfyIndex]" alt="" style="width: 25rem; height: 100%" /> <img v-show="smfyIndex==-1" id="myCanvas" style="width: 25rem; height: 100%" /> </div> </div> <div class="tip tip2"> <div class="title">温馨提示</div> <div class="content">每次扫描前,可以按“预览”按钮来实时查看版面效果。已经扫描好的 页面显示在左边的列表中,您可以点击列表中的缩略图进行浏览核对, 不满意的页面可以点旁边的“删除”进行移除并重新扫描。如果有文件需要继续扫描,请按要求放置好资料后,按“继续扫描”。按照刚才的方法,重复扫描过程,直到完成了所有需要的页面。核对无误后,可以按“完成扫描”结束资料扫描工作。 </div> <div class="flex-between but"> <div class="btn flex-center" @click="paiz()">{{ imgList.length>0?'继续扫描':'开始扫描' }}</div> <div class="btn flex-center" @click="skip('argument', name)">完成扫描</div> </div> </div> </div> <!-- 身份证打印--> <div class="box flex-center" v-if="name == '身份证打印'"> <div class="file2 file3" style="margin-right: 20rem"> <div class="title">请核对您的信息</div> <div class="card" ref="captureArea" v-if="cardInfo!=''"> <div class="card-box2"> <img src="../assets/card2.png" alt="身份证正面" /> <div class="diamond"> <div class="name">{{ cardInfo.name }}</div> <div class="gender flex-start">{{ cardInfo.xbmc }} <div>{{ cardInfo.mzmc }}</div></div> <div class="birth flex-start"> <span>{{ cardInfo.birthday | joinYear }}</span> <div>{{ cardInfo.birthday | joinMonth }}</div> <div>{{ cardInfo.birthday | joinDay }}</div> </div> <div class="addr">{{ cardInfo.address }}</div> <div class="idNum">{{ cardInfo.idNum }}</div> <div class="avatar"><img :src="photo" alt=""></div> </div> </div> <div class="card-box2"> <img src="../assets/card1.png" alt="身份证反面" /> <div class="diamond diamond2"> <div class="sign">{{ cardInfo.issueOrg }}</div> <div class="date">{{ cardInfo.effectDate | joinRq}} - {{ cardInfo.expireDate | joinRq}}</div> </div> </div> <div class="card-box" v-show="false"> <img src="../assets/card2.png" alt="身份证反面" /> <div class="card-name">{{ cardInfo.name }}</div> <div class="card-gender"> {{ cardInfo.xbmc }}<span>{{ cardInfo.mzmc }}</span> </div> <div class="card-birth"> {{ cardInfo.birthday | joinYear }} <span class="month">{{ cardInfo.birthday | joinMonth }}</span> <span class="day">{{ cardInfo.birthday | joinDay }}</span> </div> <div class="card-addr"> {{ cardInfo.address }} </div> <div class="card-id">{{ cardInfo.idNum }}</div> <div class="card-avatar"> <!-- <img :src="'data:image/png;base64,'+cardInfo.photo" alt="" />--> <img :src="photo" alt=""> </div> </div> <div class="card-box" v-show="false"> <img src="../assets/card1.png"/> <div class="card-sign">{{ cardInfo.issueOrg }}</div> <div class="card-date"> {{ cardInfo.effectDate | joinRq}} - {{ cardInfo.expireDate | joinRq}} </div> </div> </div> </div> <div class="tip"> <div class="title">温馨提示</div> <div class="content">身份证件信息读取成功,请您核对个人信息无误后,按“信息无误,继续”按钮进行后续操作。此时您可以取回您的身份证卡片并妥善保存。</div> <div class="btn flex-center" @click="skip('argument', name)">信息无误,继续</div> </div> </div> </div> </template> <script> import navbar from "@/components/nav"; import html2canvas from "html2canvas"; import {upload2Pdf, changeIdPhotoBgc, image2Pdf} from '@/api/resultApi' import {readUsb, readFile, readCard} from '@/api/bdResultApi' import parseCardWzxx from "../utils/mz"; export default { name: 'selectFile', components: { navbar }, provide() { return { title: this.tit, type: this.name } }, filters: { joinYear(val) { return val.substring(0, 4) }, joinMonth(val) { if(val.substring(4, 5)==0) { return val.substring(5, 6) } return val.substring(4, 6) }, joinDay(val) { if(val.substring(6, 7)==0) { return val.substring(7, 8) } return val.substring(6, 8) }, joinRq(val) { return val.substring(0, 4)+'.'+val.substring(4, 6)+'.'+val.substring(6, 8) } }, data() { return { isChecked: true, tit: this.cite.modeName == 'U盘打印' ? '资料选取提交' : '资料扫描提交', name: this.cite.modeName, path: this.cite.inWebURL, socket: '', imgList: [], smfyIndex: -1, photo: '', UpFile: [], cardInfo: '', usbList: [], usbTime: '' }; }, methods: { async uploadImg(data, sta) { let _this = this for (let i = 0; i < data.length; i++) { let formData = new FormData() let file = data[i] if (sta) { // let dataURL = file.toDataURL('image/png') let name = i + '.png' file = _this.dataURLtoFile(file, name) } formData.append('file', file) // 使用数组语法添加多个文件 if(this.cite.modeName=='身份证打印') { let res = await image2Pdf(formData) _this.cite.selectedFile.push(res) // console.log('打印文件', this.cite.selectedFile, res) }else{ let res = await upload2Pdf(formData) _this.cite.selectedFile.push(res) // console.log('打印文件', this.cite.selectedFile, res) } } }, async skip(href, name) { if (this.usbList.length > 0) { // 保存选中的U盘文件 // await this.uploadImg(this.UpFile, false) await this.dealFile() } else if (this.imgList.length > 0) { // 保存高拍仪图片 await this.uploadImg(this.imgList, true) } else if (this.cardInfo) { // 保存身份证图片 await this.captureAndDownload() } else { this.cite.state = { name: '请选择文件打印!', sta: true } return } this.$router.push({ name: href, params: { name: name } }) }, async captureAndDownload() { const captureArea = this.$refs.captureArea // 使用 html2canvas 将区域内容生成为图片 const canvas = await html2canvas(captureArea, {scale: 1.2}) // 将 canvas 转为图片 URL const dataURL = canvas.toDataURL('image/png') const name = 'sfz.png' const file = this.dataURLtoFile(dataURL, name) this.uploadImg([file], false) }, dataURLtoFile(dataURL, filename) { const arr = dataURL.split(',') const mime = arr[0].match(/:(.*?);/)[1] const bstr = atob(arr[1]) let n = bstr.length const u8arr = new Uint8Array(n) while (n--) { u8arr[n] = bstr.charCodeAt(n) } return new File([u8arr], filename, {type: mime}) }, onChange(index, name, sta) { if (name == 'usbList') { this[name][index].sta = sta } else { this[name] = index } }, onCancel(index, name) { if (name == 'imgList') { this.smfyIndex = -1 } this[name].splice(index, 1) }, paiz() { this.socket.send('Capture@2') }, init: function () { if (typeof WebSocket === 'undefined') { alert('您的浏览器不支持socket') } else { // 实例化socket this.socket = new WebSocket(this.path) // 监听socket连接 this.socket.onopen = this.open // 监听socket错误信息 this.socket.onerror = this.error // 监听socket消息 this.socket.onmessage = this.getMessage } }, open: function () { // console.log("socket连接成功") this.socket.send('OpenIdCardEx@0') this.socket.send('OpenDevice@1') this.socket.send('SetResolution@2@2592@1944') this.socket.send('OpenVideo') this.socket.send('RotateRight') this.socket.send('Deskew') }, error: function () { console.log('连接错误') }, getMessage: function (msg) { if (typeof msg.data == 'string') { if (msg.data.indexOf('GetDevCount') == 0) { let s = msg.data.substring(12) if ('1' == s || '2' == s) { //如果是双摄像头 那就需要判断 s = 2;表示当前是连接了2个设备 alert('检测到已经连接上摄像头') } } else if (msg.data.indexOf('Capture') == 0) { let s = msg.data.substring(8) if (s) { this.imgList.push('data:image/jpeg;base64,' + s) } } else if (msg.data.indexOf('MoveDetectEvent') == 0) { this.socket.send('Capture@2') } else if (msg.data.indexOf('IdCardEvent') == 0) { this.socket.send('UnFaceDetect') } else if (msg.data.indexOf('ReadIdCard') == 0) { let s = msg.data.substring(11) if ('1' == s) { this.socket.send('GetIdCardResult@||') this.socket.send('GetIdCardImage@2') } } else if (msg.data.indexOf('GetIdCardResult') == 0) { let s = msg.data.substring(16) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetBarcode') == 0) { // alert(msg.data); let s = msg.data.substring(11) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetIdCardImage') == 0) { let s = msg.data.substring(15) let arr = s.split('#') let faceImg = arr[0] let myimg = document.getElementById('myCanvas3') myimg.src = 'data:image/jpeg;base64,' + faceImg } else if (msg.data.indexOf('GetBase64') == 0) { let s = msg.data.substring(10) let myimg = document.getElementById('myCanvas2') myimg.src = 'data:image/jpeg;base64,' + s alert(s) } else if (msg.data.indexOf('GetRecognitionFromFileName') == 0) { let s = msg.data.substring(27) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetOcrFromFileName') == 0) { let s = msg.data.substring(19) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetDogSN') == 0) { let s = msg.data.substring(11) let info = document.getElementById('info') info.value = s } } else { let reader = new FileReader() reader.onload = function (msg) { if (msg.target.readyState == FileReader.DONE) { let url = msg.target.result; document.getElementById('myCanvas').src = url; } } reader.readAsDataURL(msg.data) } }, close: function () { // console.log("socket已经关闭") this.socket.close() this.socket = '' }, handleFileChange(event) { let file = event.target.files[0] if (file) { this.UpFile.push(file) } }, // 获取身份证信息 async sfzCard() { let _this = this let res = await readCard() if (res.errorMsg == 'OK') { // console.log(res.resultContent) _this.imgDeals(res.resultContent.photo) _this.cardInfo = parseCardWzxx(res.resultContent) } else { if(this.$route.name == 'selectFile') { setTimeout(() => { this.sfzCard() }, 1000) } } }, // 图片处理 imgDeals(re) { let file = this.dataURLtoFile('data:image/png;base64,' + re, 'sfzTx.png') let formData = new FormData() formData.append('file', file) formData.append('colorEnum', 'CLEAR') changeIdPhotoBgc(formData).then((res) => { console.log(res) this.photo = res.previewPath }) }, // 读取U盘 readUsb() { let data = { extensions: 'pdf,doc,docx,xls,xlsx,ppt,pptx,jpg,png' } readUsb(data).then((res) => { // console.log(res) if (res) { if(this.UpFile.length != res.length) { // console.log(this.UpFile , res) this.UpFile = res this.usbList = [] res.forEach(re =>{ this.usbList.push({ name: re, sta: false }) }) } } else { this.UpFile = [] this.usbList = [] this.cite.state = { name: '请插入U盘', sta: true } } if(this.$route.name == 'selectFile') { setTimeout(() =>{ this.readUsb() },1000) } }) }, // 处理选中文件 async dealFile() { let {usbList} = this await usbList.forEach(re =>{ if(re.sta) { this.readFile(re.name) } }) }, async readFile(url) { let res = await readFile({filePath: url}) console.log(res) this.cite.selectedFile.push(res.data) }, }, destroyed() { // 销毁监听 if(this.socket) { this.close() } }, mounted() { this.cite.selectedFile = [] if (this.cite.modeName == "扫描打印") { this.init(); }else if(this.cite.modeName == "身份证打印") { this.sfzCard() }else if(this.cite.modeName == "U盘打印") { this.readUsb() } } } </script> <style scoped lang="less"> @font-face { font-family: 'STHeiti';//自定义字体名字 src: url('../assets/typeface/STHeiti.ttf') format('truetype');//定义好文件的相对地址 } @font-face { font-family: 'OCR';//自定义字体名字 src: url('../assets/typeface/OCR-B-10-BT.ttf') format('truetype');//定义好文件的相对地址 } .selectFile { .box { width: 114.06rem; height: 42.13rem; background: #ffffff; box-shadow: 0rem 0.31rem 0.63rem 0.06rem rgba(0, 0, 0, 0.14); border-radius: 1.63rem; margin: 0 auto; .tip { //margin-right: 15.31rem; width: 37rem; font-size: 2.25rem; font-weight: bold; color: #323232; line-height: 3rem; .title { font-size: 2.88rem; font-weight: bold; color: #d41212; line-height: 4.06rem; } .content { margin: 3rem auto 59px; text-align: center; } } .file { margin-left: 9.69rem; .main { width: 31.63rem; height: 26.56rem; background: #ffffff; border: 0.06rem solid #707070; margin: 0 auto 2.81rem; padding: 1rem 0; overflow-y: scroll; .li { padding-left: 1rem; .name { min-height: 1.8rem; text-align: left; max-width: 80%; margin-left: 1rem; } img { width: 1.3rem; margin-left: 1rem; } } } } .tip2 { width: 52rem; .but { .btn { width: 24.44rem; position: relative; input { position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; } } } } .file2 { margin-right: 9.69rem; .title { font-size: 2.13rem; font-weight: bold; color: #323232; line-height: 3rem; //text-align: left; span { text-decoration: underline; font-size: 1.5rem; font-weight: bold; color: #323232; line-height: 2rem; } .act { color: #52a39d; } } .main { width: 39.81rem; height: 31.31rem; background: #eeeeee; margin: 1.38rem auto 0; } .card { //width: 42.81rem; width: 20rem; margin: 0 10rem; height: 35.31rem; display: flex; flex-direction: column; justify-content: space-around; align-items: flex-end; .card-box { width: 25rem; height: 15rem; margin-right: 5rem; position: relative; font-weight: 500; font-size: .9rem; line-height: 1rem; .card-title { padding: 1rem 0; } img { width: 25rem; } .card-sign { position: absolute; bottom: 2.6rem; left: 10.5rem; } .card-date { position: absolute; bottom: 0.5rem; left: 10.5rem; } .card-name { position: absolute; top: 2.2rem; left: 4.5rem; } .card-gender { position: absolute; top: 4.1rem; left: 4.5rem; span { margin-left: 5rem; } } .card-birth { position: absolute; top: 6.15rem; left: 4.5rem; .month { margin-left: 1.7rem; } .day { margin-left: 1.2rem; } } .card-addr { width: 11rem; position: absolute; top: 8.1rem; left: 4.5rem; text-align: left; line-height: 1.3rem; } .card-id { position: absolute; bottom: .8rem; left: 8rem; letter-spacing: .2rem; } .card-avatar { position: absolute; top: 3.2rem; right: 2rem; width: 7rem; height: 9rem; img { width: 7rem; height: 9rem; background-size: contain; } } } .card-box2 { position: relative; font-family: 'STHeiti'; margin: 0 auto; img { width: 100%; } .diamond { position: absolute; top: 0; //left: 60px; right: 0; height: 100%; //font-size: 12px; text-align: left; left: 3.75rem; font-size: 0.75rem; .name { //font-size: 14px; font-family: 'OCR'; //margin: 23px 0 10px; font-size: 0.875rem; margin: 1.4375rem 0 0.625rem; } .gender { div { //margin-left: 50px; margin-left: 3.125rem; } } .birth { //margin: 12px 0; margin: 0.75rem 0; span { //margin-right: 3px; margin-right: 0.1875rem; } div { //width: 20px; //margin-left: 11px; text-align: center; width: 1.25rem; margin-left: 0.6875rem; } } .addr { //width: 150px; //line-height: 18px; width: 9.375rem; line-height: 1.125rem; } .idNum { position: absolute; //bottom: 26px; //left: 46px; //letter-spacing: 2px; font-family: 'OCR'; //font-size: 14px; font-weight: 600; bottom: 1.625rem; left: 2.875rem; letter-spacing: 0.125rem; font-size: 0.875rem; } .avatar { position: absolute; //right: 20px; //top: 40px; //width: 82px; right: 1.25rem; top: 2.5rem; width: 5.125rem; } } .diamond2 { //left: 130px; height: auto; top: auto; //bottom: 21px; left: 8.125rem; bottom: 1.3125rem; .sign { //margin-bottom: 14px; margin-bottom: 0.875rem; } } } } } .file3 { margin-right: 28.13rem; .main { width: 20.75rem; height: 28.88rem; border: 0.06rem solid #707070; margin: 1.06rem 0 0 13.38rem; } } .btn { width: 100%; height: 5.5rem; background: linear-gradient(132deg, #52a39d 0%, #a1c553 50%, #81d012 100%); border-radius: 1.25rem; font-size: 1.88rem; font-weight: 400; color: #ffffff; line-height: 2.63rem; cursor: pointer; } } .smfyData { height: 90%; width: 14.81rem; font-size: 1rem; font-weight: bold; color: #323232; line-height: 2rem; overflow: auto; cursor: pointer; .act { color: #52a39d; } .name { text-decoration: underline; } span { margin-left: 5rem; } } } </style>
<template> <!-- 选取资料--> <div class="selectFile"> <navbar :name="name" /> <!-- U盘打印--> <div class="box flex-center" v-if="name == 'U盘打印'"> <div class="tip" style="width: 20rem;"> <div class="title">温馨提示</div> <div class="content">请在右侧文件浏览区,找到待印资料文件存放的目录(文件夹),然后点选您需要打印的文件,之后按下“确认资料”按钮来提交资料。</div> </div> <div class="file"> <div class="main" style="width: 50rem;"> <div v-for="(item, index) in usbList" v-bind:key="index" class="li flex-start" @click="onChange(index, 'usbList',!item.sta)"> <input type="checkbox" v-model="item.sta"> <div class="name flex-start">{{ item.name }}</div> </div> </div> <div class="flex-between but"> <div class="btn flex-center" @click="skip('argument', name)">确认资料</div> </div> </div> </div> <!-- 扫描打印--> <div class="box flex-center" v-if="name == '扫描打印'"> <div class="file2"> <div class="title flex-between">已完成扫描的版面 <span :class="[{ act: smfyIndex == -1 }]" @click="onChange(-1, 'smfyIndex')">预览</span></div> <div class="main flex-between"> <div class="smfyData"> <div v-for="(item, index) in imgList" v-bind:key="index" :class="['flex-center', { act: smfyIndex == index }]" @click="onChange(index, 'smfyIndex')"> <div class="name">{{ index + 1 }}</div> <span @click="onCancel(index, 'imgList')">删除</span> </div> </div> <img v-show="smfyIndex!=-1" :src="imgList[smfyIndex]" alt="" style="width: 25rem; height: 100%" /> <img v-show="smfyIndex==-1" id="myCanvas" style="width: 25rem; height: 100%" /> </div> </div> <div class="tip tip2"> <div class="title">温馨提示</div> <div class="content">每次扫描前,可以按“预览”按钮来实时查看版面效果。已经扫描好的 页面显示在左边的列表中,您可以点击列表中的缩略图进行浏览核对, 不满意的页面可以点旁边的“删除”进行移除并重新扫描。如果有文件需要继续扫描,请按要求放置好资料后,按“继续扫描”。按照刚才的方法,重复扫描过程,直到完成了所有需要的页面。核对无误后,可以按“完成扫描”结束资料扫描工作。 </div> <div class="flex-between but"> <div class="btn flex-center" @click="paiz()">{{ imgList.length>0?'继续扫描':'开始扫描' }}</div> <div class="btn flex-center" @click="skip('argument', name)">完成扫描</div> </div> </div> </div> <!-- 身份证打印--> <div class="box flex-center" v-if="name == '身份证打印'"> <div class="file2 file3" style="margin-right: 20rem"> <div class="title">请核对您的信息</div> <div class="card" ref="captureArea" v-if="cardInfo!=''"> <div class="card-box2"> <img src="../assets/card2.png" alt="身份证正面" /> <div class="diamond"> <div class="name">{{ cardInfo.name }}</div> <div class="gender flex-start">{{ cardInfo.xbmc }} <div>{{ cardInfo.mzmc }}</div></div> <div class="birth flex-start"> <span>{{ cardInfo.birthday | joinYear }}</span> <div>{{ cardInfo.birthday | joinMonth }}</div> <div>{{ cardInfo.birthday | joinDay }}</div> </div> <div class="addr">{{ cardInfo.address }}</div> <div class="idNum">{{ cardInfo.idNum }}</div> <div class="avatar"><img :src="photo" alt=""></div> </div> </div> <div class="card-box2"> <img src="../assets/card1.png" alt="身份证反面" /> <div class="diamond diamond2"> <div class="sign">{{ cardInfo.issueOrg }}</div> <div class="date">{{ cardInfo.effectDate | joinRq}} - {{ cardInfo.expireDate | joinRq}}</div> </div> </div> <div class="card-box" v-show="false"> <img src="../assets/card2.png" alt="身份证反面" /> <div class="card-name">{{ cardInfo.name }}</div> <div class="card-gender"> {{ cardInfo.xbmc }}<span>{{ cardInfo.mzmc }}</span> </div> <div class="card-birth"> {{ cardInfo.birthday | joinYear }} <span class="month">{{ cardInfo.birthday | joinMonth }}</span> <span class="day">{{ cardInfo.birthday | joinDay }}</span> </div> <div class="card-addr"> {{ cardInfo.address }} </div> <div class="card-id">{{ cardInfo.idNum }}</div> <div class="card-avatar"> <!-- <img :src="'data:image/png;base64,'+cardInfo.photo" alt="" />--> <img :src="photo" alt=""> </div> </div> <div class="card-box" v-show="false"> <img src="../assets/card1.png"/> <div class="card-sign">{{ cardInfo.issueOrg }}</div> <div class="card-date"> {{ cardInfo.effectDate | joinRq}} - {{ cardInfo.expireDate | joinRq}} </div> </div> </div> </div> <div class="tip"> <div class="title">温馨提示</div> <div class="content">身份证件信息读取成功,请您核对个人信息无误后,按“信息无误,继续”按钮进行后续操作。此时您可以取回您的身份证卡片并妥善保存。</div> <div class="btn flex-center" @click="skip('argument', name)">信息无误,继续</div> </div> </div> </div> </template> <script> import navbar from "@/components/nav"; import html2canvas from "html2canvas"; import {upload2Pdf, changeIdPhotoBgc, image2Pdf} from '@/api/resultApi' import {readUsb, readFile, readCard} from '@/api/bdResultApi' import parseCardWzxx from "../utils/mz"; export default { name: 'selectFile', components: { navbar }, provide() { return { title: this.tit, type: this.name } }, filters: { joinYear(val) { return val.substring(0, 4) }, joinMonth(val) { if(val.substring(4, 5)==0) { return val.substring(5, 6) } return val.substring(4, 6) }, joinDay(val) { if(val.substring(6, 7)==0) { return val.substring(7, 8) } return val.substring(6, 8) }, joinRq(val) { return val.substring(0, 4)+'.'+val.substring(4, 6)+'.'+val.substring(6, 8) } }, data() { return { isChecked: true, tit: this.cite.modeName == 'U盘打印' ? '资料选取提交' : '资料扫描提交', name: this.cite.modeName, path: this.cite.inWebURL, socket: '', imgList: [], smfyIndex: -1, photo: '', UpFile: [], cardInfo: '', usbList: [], usbTime: '' }; }, methods: { async uploadImg(data, sta) { let _this = this for (let i = 0; i < data.length; i++) { let formData = new FormData() let file = data[i] if (sta) { // let dataURL = file.toDataURL('image/png') let name = i + '.png' file = _this.dataURLtoFile(file, name) } formData.append('file', file) // 使用数组语法添加多个文件 if(this.cite.modeName=='身份证打印') { let res = await image2Pdf(formData) _this.cite.selectedFile.push(res) // console.log('打印文件', this.cite.selectedFile, res) }else{ let res = await upload2Pdf(formData) _this.cite.selectedFile.push(res) // console.log('打印文件', this.cite.selectedFile, res) } } }, async skip(href, name) { if (this.usbList.length > 0) { // 保存选中的U盘文件 // await this.uploadImg(this.UpFile, false) await this.dealFile() } else if (this.imgList.length > 0) { // 保存高拍仪图片 await this.uploadImg(this.imgList, true) } else if (this.cardInfo) { // 保存身份证图片 await this.captureAndDownload() } else { this.cite.state = { name: '请选择文件打印!', sta: true } return } this.$router.push({ name: href, params: { name: name } }) }, async captureAndDownload() { const captureArea = this.$refs.captureArea // 使用 html2canvas 将区域内容生成为图片 const canvas = await html2canvas(captureArea) // 将 canvas 转为图片 URL const dataURL = canvas.toDataURL('image/png') const name = 'sfz.png' const file = this.dataURLtoFile(dataURL, name) this.uploadImg([file], false) }, dataURLtoFile(dataURL, filename) { const arr = dataURL.split(',') const mime = arr[0].match(/:(.*?);/)[1] const bstr = atob(arr[1]) let n = bstr.length const u8arr = new Uint8Array(n) while (n--) { u8arr[n] = bstr.charCodeAt(n) } return new File([u8arr], filename, {type: mime}) }, onChange(index, name, sta) { if (name == 'usbList') { this[name][index].sta = sta } else { this[name] = index } }, onCancel(index, name) { if (name == 'imgList') { this.smfyIndex = -1 } this[name].splice(index, 1) }, paiz() { this.socket.send('Capture@2') }, init: function () { if (typeof WebSocket === 'undefined') { alert('您的浏览器不支持socket') } else { // 实例化socket this.socket = new WebSocket(this.path) // 监听socket连接 this.socket.onopen = this.open // 监听socket错误信息 this.socket.onerror = this.error // 监听socket消息 this.socket.onmessage = this.getMessage } }, open: function () { // console.log("socket连接成功") this.socket.send('OpenIdCardEx@0') this.socket.send('OpenDevice@1') this.socket.send('SetResolution@2@2592@1944') this.socket.send('OpenVideo') this.socket.send('RotateRight') this.socket.send('Deskew') }, error: function () { console.log('连接错误') }, getMessage: function (msg) { if (typeof msg.data == 'string') { if (msg.data.indexOf('GetDevCount') == 0) { let s = msg.data.substring(12) if ('1' == s || '2' == s) { //如果是双摄像头 那就需要判断 s = 2;表示当前是连接了2个设备 alert('检测到已经连接上摄像头') } } else if (msg.data.indexOf('Capture') == 0) { let s = msg.data.substring(8) if (s) { this.imgList.push('data:image/jpeg;base64,' + s) } } else if (msg.data.indexOf('MoveDetectEvent') == 0) { this.socket.send('Capture@2') } else if (msg.data.indexOf('IdCardEvent') == 0) { this.socket.send('UnFaceDetect') } else if (msg.data.indexOf('ReadIdCard') == 0) { let s = msg.data.substring(11) if ('1' == s) { this.socket.send('GetIdCardResult@||') this.socket.send('GetIdCardImage@2') } } else if (msg.data.indexOf('GetIdCardResult') == 0) { let s = msg.data.substring(16) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetBarcode') == 0) { // alert(msg.data); let s = msg.data.substring(11) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetIdCardImage') == 0) { let s = msg.data.substring(15) let arr = s.split('#') let faceImg = arr[0] let myimg = document.getElementById('myCanvas3') myimg.src = 'data:image/jpeg;base64,' + faceImg } else if (msg.data.indexOf('GetBase64') == 0) { let s = msg.data.substring(10) let myimg = document.getElementById('myCanvas2') myimg.src = 'data:image/jpeg;base64,' + s alert(s) } else if (msg.data.indexOf('GetRecognitionFromFileName') == 0) { let s = msg.data.substring(27) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetOcrFromFileName') == 0) { let s = msg.data.substring(19) let info = document.getElementById('info') info.value = s } else if (msg.data.indexOf('GetDogSN') == 0) { let s = msg.data.substring(11) let info = document.getElementById('info') info.value = s } } else { let reader = new FileReader() reader.onload = function (msg) { if (msg.target.readyState == FileReader.DONE) { let url = msg.target.result; document.getElementById('myCanvas').src = url; } } reader.readAsDataURL(msg.data) } }, close: function () { // console.log("socket已经关闭") this.socket.close() this.socket = '' }, handleFileChange(event) { let file = event.target.files[0] if (file) { this.UpFile.push(file) } }, // 获取身份证信息 async sfzCard() { let _this = this let res = await readCard() if (res.errorMsg == 'OK') { // console.log(res.resultContent) _this.imgDeals(res.resultContent.photo) _this.cardInfo = parseCardWzxx(res.resultContent) } else { if(this.$route.name == 'selectFile') { setTimeout(() => { this.sfzCard() }, 1000) } } }, // 图片处理 imgDeals(re) { let file = this.dataURLtoFile('data:image/png;base64,' + re, 'sfzTx.png') let formData = new FormData() formData.append('file', file) formData.append('colorEnum', 'CLEAR') changeIdPhotoBgc(formData).then((res) => { console.log(res) this.photo = res.previewPath }) }, // 读取U盘 readUsb() { let data = { extensions: 'pdf,doc,docx,xls,xlsx,ppt,pptx,jpg,png' } readUsb(data).then((res) => { // console.log(res) if (res) { if(this.UpFile.length != res.length) { // console.log(this.UpFile , res) this.UpFile = res this.usbList = [] res.forEach(re =>{ this.usbList.push({ name: re, sta: false }) }) } } else { this.UpFile = [] this.usbList = [] this.cite.state = { name: '请插入U盘', sta: true } } if(this.$route.name == 'selectFile') { setTimeout(() =>{ this.readUsb() },1000) } }) }, // 处理选中文件 async dealFile() { let {usbList} = this await usbList.forEach(re =>{ if(re.sta) { this.readFile(re.name) } }) }, async readFile(url) { let res = await readFile({filePath: url}) console.log(res) this.cite.selectedFile.push(res.data) }, }, destroyed() { // 销毁监听 if(this.socket) { this.close() } }, mounted() { this.cite.selectedFile = [] if (this.cite.modeName == "扫描打印") { this.init(); }else if(this.cite.modeName == "身份证打印") { this.sfzCard() }else if(this.cite.modeName == "U盘打印") { this.readUsb() } } } </script> <style scoped lang="less"> @font-face { font-family: 'STHeiti';//自定义字体名字 src: url('../assets/typeface/STHeiti.ttf') format('truetype');//定义好文件的相对地址 } @font-face { font-family: 'OCR';//自定义字体名字 src: url('../assets/typeface/OCR-B-10-BT.ttf') format('truetype');//定义好文件的相对地址 } .selectFile { .box { width: 114.06rem; height: 42.13rem; background: #ffffff; box-shadow: 0rem 0.31rem 0.63rem 0.06rem rgba(0, 0, 0, 0.14); border-radius: 1.63rem; margin: 0 auto; .tip { //margin-right: 15.31rem; width: 37rem; font-size: 2.25rem; font-weight: bold; color: #323232; line-height: 3rem; .title { font-size: 2.88rem; font-weight: bold; color: #d41212; line-height: 4.06rem; } .content { margin: 3rem auto 59px; text-align: center; } } .file { margin-left: 9.69rem; .main { width: 31.63rem; height: 26.56rem; background: #ffffff; border: 0.06rem solid #707070; margin: 0 auto 2.81rem; padding: 1rem 0; overflow-y: scroll; .li { padding-left: 1rem; .name { min-height: 1.8rem; text-align: left; max-width: 80%; margin-left: 1rem; } img { width: 1.3rem; margin-left: 1rem; } } } } .tip2 { width: 52rem; .but { .btn { width: 24.44rem; position: relative; input { position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; } } } } .file2 { margin-right: 9.69rem; .title { font-size: 2.13rem; font-weight: bold; color: #323232; line-height: 3rem; //text-align: left; span { text-decoration: underline; font-size: 1.5rem; font-weight: bold; color: #323232; line-height: 2rem; } .act { color: #52a39d; } } .main { width: 39.81rem; height: 31.31rem; background: #eeeeee; margin: 1.38rem auto 0; } .card { //width: 42.81rem; width: 20rem; margin: 0 10rem; height: 35.31rem; display: flex; flex-direction: column; justify-content: space-around; align-items: flex-end; .card-box { width: 25rem; height: 15rem; margin-right: 5rem; position: relative; font-weight: 500; font-size: .9rem; line-height: 1rem; .card-title { padding: 1rem 0; } img { width: 25rem; } .card-sign { position: absolute; bottom: 2.6rem; left: 10.5rem; } .card-date { position: absolute; bottom: 0.5rem; left: 10.5rem; } .card-name { position: absolute; top: 2.2rem; left: 4.5rem; } .card-gender { position: absolute; top: 4.1rem; left: 4.5rem; span { margin-left: 5rem; } } .card-birth { position: absolute; top: 6.15rem; left: 4.5rem; .month { margin-left: 1.7rem; } .day { margin-left: 1.2rem; } } .card-addr { width: 11rem; position: absolute; top: 8.1rem; left: 4.5rem; text-align: left; line-height: 1.3rem; } .card-id { position: absolute; bottom: .8rem; left: 8rem; letter-spacing: .2rem; } .card-avatar { position: absolute; top: 3.2rem; right: 2rem; width: 7rem; height: 9rem; img { width: 7rem; height: 9rem; background-size: contain; } } } .card-box2 { position: relative; font-family: 'STHeiti'; margin: 0 auto; img { width: 100%; } .diamond { position: absolute; top: 0; //left: 60px; right: 0; height: 100%; //font-size: 12px; text-align: left; left: 3.75rem; font-size: 0.75rem; .name { //font-size: 14px; font-family: 'OCR'; //margin: 23px 0 10px; font-size: 0.875rem; margin: 1.4375rem 0 0.625rem; } .gender { div { //margin-left: 50px; margin-left: 3.125rem; } } .birth { //margin: 12px 0; margin: 0.75rem 0; span { //margin-right: 3px; margin-right: 0.1875rem; } div { //width: 20px; //margin-left: 11px; text-align: center; width: 1.25rem; margin-left: 0.6875rem; } } .addr { //width: 150px; //line-height: 18px; width: 9.375rem; line-height: 1.125rem; } .idNum { position: absolute; //bottom: 26px; //left: 46px; //letter-spacing: 2px; font-family: 'OCR'; //font-size: 14px; font-weight: 600; bottom: 1.625rem; left: 2.875rem; letter-spacing: 0.125rem; font-size: 0.875rem; } .avatar { position: absolute; //right: 20px; //top: 40px; //width: 82px; right: 1.25rem; top: 2.5rem; width: 5.125rem; } } .diamond2 { //left: 130px; height: auto; top: auto; //bottom: 21px; left: 8.125rem; bottom: 1.3125rem; .sign { //margin-bottom: 14px; margin-bottom: 0.875rem; } } } } } .file3 { margin-right: 28.13rem; .main { width: 20.75rem; height: 28.88rem; border: 0.06rem solid #707070; margin: 1.06rem 0 0 13.38rem; } } .btn { width: 100%; height: 5.5rem; background: linear-gradient(132deg, #52a39d 0%, #a1c553 50%, #81d012 100%); border-radius: 1.25rem; font-size: 1.88rem; font-weight: 400; color: #ffffff; line-height: 2.63rem; cursor: pointer; } } .smfyData { height: 90%; width: 14.81rem; font-size: 1rem; font-weight: bold; color: #323232; line-height: 2rem; overflow: auto; cursor: pointer; .act { color: #52a39d; } .name { text-decoration: underline; } span { margin-left: 5rem; } } } </style>
Show line notes below