2019-03-27 19:13:07 +00:00
|
|
|
<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;
|
|
|
|
|
2019-03-29 12:10:06 +00:00
|
|
|
//let canvas = this.$el.querySelector('#canvas')
|
2019-03-27 19:13:07 +00:00
|
|
|
|
|
|
|
this.worker.listenTo('upload-invoice', (e) => {
|
|
|
|
|
|
|
|
console.log("received invoice ", e.data)
|
|
|
|
self.invoice = e.data.invoice
|
|
|
|
|
2019-03-29 12:10:06 +00:00
|
|
|
|
|
|
|
})
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
makeLnQR(payreq) {
|
|
|
|
let canvas = this.$el.querySelector('#canvas')
|
|
|
|
|
|
|
|
QRCode.toDataURL(canvas, payreq.toUpperCase(), {
|
|
|
|
margin: 4,
|
2019-03-27 19:13:07 +00:00
|
|
|
width: 340,
|
|
|
|
errorCorrectionLevel: 'H',
|
|
|
|
type: 'png',
|
|
|
|
renderOpts:{
|
|
|
|
quality: 1,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(url => {
|
2019-03-29 12:10:06 +00:00
|
|
|
this.payreqURI = url;
|
2019-03-27 19:13:07 +00:00
|
|
|
})
|
|
|
|
.catch(err =>{
|
|
|
|
console.error(err);
|
|
|
|
})
|
2019-03-29 12:10:06 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
invoice: function(val) {
|
|
|
|
this.makeLnQR(val.payreq)
|
|
|
|
}
|
2019-03-27 19:13:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
img{
|
|
|
|
width: 340px;
|
|
|
|
height: 340px;
|
|
|
|
}
|
|
|
|
</style>
|