opnform-host-nginx/client/components/pages/forms/show/FormQrCode.vue

59 lines
997 B
Vue
Raw Normal View History

2023-12-09 15:47:03 +01:00
<template>
<div>
<h3 class="font-semibold text-xl">
QR Code
</h3>
2023-12-09 15:47:03 +01:00
<p>Scan the QR code to open the form (Right click to copy the image)</p>
<div class="flex items-center">
<img
v-if="QrUrl"
:src="QrUrl"
class="m-auto"
>
2023-12-09 15:47:03 +01:00
</div>
</div>
</template>
<script>
import QRCode from "qrcode"
2023-12-09 15:47:03 +01:00
export default {
name: "FormQrCode",
2023-12-09 15:47:03 +01:00
props: {
form: { type: Object, required: true },
extraQueryParam: { type: String, default: "" },
2023-12-09 15:47:03 +01:00
},
data() {
2024-01-10 16:17:47 +01:00
return {
QrUrl: null,
2023-12-09 15:47:03 +01:00
}
},
computed: {
shareUrl() {
return this.extraQueryParam
? this.form.share_url + "?" + this.extraQueryParam
: this.form.share_url + this.extraQueryParam
},
2023-12-09 15:47:03 +01:00
},
watch: {
shareUrl() {
2023-12-09 15:47:03 +01:00
this.generateQR()
},
2023-12-09 15:47:03 +01:00
},
mounted() {
2023-12-09 15:47:03 +01:00
this.generateQR()
},
methods: {
generateQR() {
QRCode.toDataURL(this.shareUrl).then((url) => {
2023-12-09 15:47:03 +01:00
this.QrUrl = url
})
},
},
2023-12-09 15:47:03 +01:00
}
</script>