You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.2 KiB
Vue
64 lines
1.2 KiB
Vue
<template>
|
|
|
|
<div id="payment">
|
|
<img v-bind:src="payreqURI" />
|
|
<canvas id="canvas" hidden>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script charset="utf-8">
|
|
import QRCode from 'qrcode';
|
|
|
|
import GetWorker from './workerInterface.js';
|
|
const Worker = GetWorker('main');
|
|
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
invoice: {},
|
|
payreqURI: "",
|
|
}
|
|
},
|
|
mounted () {
|
|
let self = this
|
|
this.worker = Worker;
|
|
|
|
let canvas = this.$el.querySelector('#canvas')
|
|
|
|
this.worker.listenTo('upload-invoice', (e) => {
|
|
|
|
console.log("received invoice ", e.data)
|
|
self.invoice = e.data.invoice
|
|
|
|
QRCode.toDataURL(canvas, self.invoice.payreq, {
|
|
margin: 2,
|
|
width: 340,
|
|
errorCorrectionLevel: 'H',
|
|
type: 'png',
|
|
renderOpts:{
|
|
quality: 1,
|
|
}
|
|
})
|
|
.then(url => {
|
|
self.payreqURI = url;
|
|
})
|
|
.catch(err =>{
|
|
console.error(err);
|
|
})
|
|
|
|
})
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style>
|
|
img{
|
|
width: 340px;
|
|
height: 340px;
|
|
}
|
|
</style>
|