|
|
|
|
@ -0,0 +1,175 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="page">
|
|
|
|
|
<div class="box" ref="box">
|
|
|
|
|
<div class="container" ref="container" :style="{ 'transform': `translate(${container.offsetX}px,${container.offsetY}px) scale(${container.scale},${container.scale})` }">
|
|
|
|
|
<div class="no">
|
|
|
|
|
序列号:{{ info.bianma }}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="qrcode">
|
|
|
|
|
<div ref="qrcode"></div>
|
|
|
|
|
<div>扫码核验</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="bottom-panel">
|
|
|
|
|
<Button type="info" icon="md-download">下载</Button>
|
|
|
|
|
<Button type="info" icon="md-print">打印</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import QRCode from 'qrcodejs2';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { show } from "@/api/system/baseForm";
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
id: '',
|
|
|
|
|
info: {},
|
|
|
|
|
container: {
|
|
|
|
|
w: 0,
|
|
|
|
|
h: 0,
|
|
|
|
|
offsetX: 0,
|
|
|
|
|
offsetY: 0,
|
|
|
|
|
lastX: 0,
|
|
|
|
|
lastY: 0,
|
|
|
|
|
scale: 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
creatQrCode() {
|
|
|
|
|
new QRCode(this.$refs.qrcode, {
|
|
|
|
|
text: window.location.href, // 二维码的内容
|
|
|
|
|
width: 74,
|
|
|
|
|
height: 74,
|
|
|
|
|
colorDark: '#000',
|
|
|
|
|
colorLight: '#fff',
|
|
|
|
|
correctLevel: QRCode.CorrectLevel.H
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
init () {
|
|
|
|
|
const box = this.$refs['box'];
|
|
|
|
|
const container = this.$refs['container'];
|
|
|
|
|
const { width,height } = box.getBoundingClientRect();
|
|
|
|
|
this.container.w = width;
|
|
|
|
|
this.container.h = height;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
box.ontouchstart = box.onmousedown = event => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
if (event.type === 'touchstart') {
|
|
|
|
|
let touch = event.touches[0];
|
|
|
|
|
this.container.lastX = touch.clientX;
|
|
|
|
|
this.container.lastY = touch.clientY;
|
|
|
|
|
} else {
|
|
|
|
|
this.container.lastX = event.clientX;
|
|
|
|
|
this.container.lastY = event.clientY;
|
|
|
|
|
}
|
|
|
|
|
box.ontouchmove = box.onmousemove = e => {
|
|
|
|
|
let currentX,currentY;
|
|
|
|
|
if (e.type === 'touchmove') {
|
|
|
|
|
let touch = e.touches[0];
|
|
|
|
|
currentX = touch.clientX;
|
|
|
|
|
currentY = touch.clientY;
|
|
|
|
|
} else {
|
|
|
|
|
currentX = e.clientX;
|
|
|
|
|
currentY = e.clientY;
|
|
|
|
|
}
|
|
|
|
|
this.container.offsetX += currentX - this.container.lastX;
|
|
|
|
|
this.container.offsetY += currentY - this.container.lastY;
|
|
|
|
|
this.container.lastX = currentX;
|
|
|
|
|
this.container.lastY = currentY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
box.ontouchend = box.onmouseup = e => {
|
|
|
|
|
box.ontouchmove = box.onmousemove = null;
|
|
|
|
|
}
|
|
|
|
|
box.onwheel = e => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.container.scale *= Math.exp(e.deltaY / -100);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
computed: {},
|
|
|
|
|
created() {
|
|
|
|
|
if (this.$route.query.d) {
|
|
|
|
|
this.id = window.atob(this.$route.query.d).split('=')[1]
|
|
|
|
|
|
|
|
|
|
show({
|
|
|
|
|
table_name: 'records',
|
|
|
|
|
id: this.id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
this.info = res;
|
|
|
|
|
|
|
|
|
|
this.init();
|
|
|
|
|
this.creatQrCode();
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.page {
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
background: rgb(80,80,80);
|
|
|
|
|
}
|
|
|
|
|
.box {
|
|
|
|
|
width: 100vw;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
max-width: 600px;
|
|
|
|
|
max-height: 800px;
|
|
|
|
|
background: #fff;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
margin: auto;
|
|
|
|
|
|
|
|
|
|
.container {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
|
|
& > div {
|
|
|
|
|
position: absolute;
|
|
|
|
|
}
|
|
|
|
|
.no {
|
|
|
|
|
transform: translate(20px,20px);
|
|
|
|
|
}
|
|
|
|
|
.qrcode {
|
|
|
|
|
transform: translate(0px,20px);
|
|
|
|
|
right: 20px
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.bottom-panel {
|
|
|
|
|
height: 50px;
|
|
|
|
|
background: rgba(55,55,55,.6);
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-evenly;
|
|
|
|
|
align-items: center;
|
|
|
|
|
transition: all .2s;
|
|
|
|
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
|
|
|
|
& > Button {
|
|
|
|
|
min-width: 90px;
|
|
|
|
|
max-width: 150px;
|
|
|
|
|
width: 16%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|