bit4sat/web/src/pay.vue

75 lines
1.4 KiB
Vue
Raw Normal View History

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;
//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
})
},
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 => {
this.payreqURI = url;
2019-03-27 19:13:07 +00:00
})
.catch(err =>{
console.error(err);
})
}
},
watch: {
invoice: function(val) {
this.makeLnQR(val.payreq)
}
2019-03-27 19:13:07 +00:00
},
}
</script>
<style>
img{
width: 340px;
height: 340px;
}
</style>