2020-10-21 14:03:11 +02:00
|
|
|
<div id="scan-qr-modal-app">
|
|
|
|
<div class="modal" tabindex="-1" role="dialog" :id="modalId">
|
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
2022-08-31 12:27:06 +02:00
|
|
|
<h5 class="modal-title">{{title}} <template v-if="fragments && fragments.length > 1">({{index+1}}/{{fragments.length}})</template></h5>
|
2021-05-19 04:39:27 +02:00
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
2021-07-19 12:20:24 +02:00
|
|
|
<vc:icon symbol="close"/>
|
2020-10-21 14:03:11 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-08-31 12:27:06 +02:00
|
|
|
<div class="modal-body text-center">
|
2023-03-19 21:43:38 +01:00
|
|
|
<div class="text-center my-2" :style="{height: `${qrOptions.height}px`}">
|
2022-08-31 12:27:06 +02:00
|
|
|
<component v-if="currentFragment" :is="currentMode.href ? 'a': 'div'" class="qr-container d-inline-block" :href="currentMode.href">
|
2023-07-06 10:12:31 +02:00
|
|
|
<qrcode :value="currentFragment" :options="qrOptions"></qrcode>
|
2022-08-31 12:27:06 +02:00
|
|
|
</component>
|
|
|
|
</div>
|
2023-02-22 11:20:50 +01:00
|
|
|
<ul class="nav btcpay-pills justify-content-center mt-4 mb-3" v-if="modes && Object.keys(modes).length > 1">
|
2022-08-31 12:27:06 +02:00
|
|
|
<li class="nav-item" v-for="(item, key) in modes">
|
|
|
|
<a class="btcpay-pill" :class="{ 'active': key === mode }" href="#" v-on:click="mode = key">{{item.title}}</a>
|
2021-07-19 12:20:24 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
2023-03-19 21:43:38 +01:00
|
|
|
<div class="input-group input-group-sm mt-3" :data-clipboard="currentFragment" v-if="currentFragment && currentMode.showData">
|
|
|
|
<input type="text" class="form-control" readonly="readonly" :value="currentFragment" id="qr-code-data-input">
|
|
|
|
<button type="button" class="btn btn-outline-secondary px-3">
|
|
|
|
<vc:icon symbol="copy" />
|
|
|
|
</button>
|
2022-07-12 08:17:44 +02:00
|
|
|
</div>
|
2023-09-22 10:24:53 +02:00
|
|
|
<div v-if="note" v-html="note" class="text-muted mt-3" id="scan-qr-modal-note"></div>
|
2020-10-21 14:03:11 +02:00
|
|
|
</div>
|
2022-08-31 12:27:06 +02:00
|
|
|
<div class="mb-4 text-center" v-if="continueCallback">
|
|
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" v-on:click="continueCallback()">{{ continueTitle || 'Continue' }}</button>
|
2020-10-21 14:03:11 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-22 10:24:53 +02:00
|
|
|
<style>
|
|
|
|
#scan-qr-modal-note :last-child { margin-bottom: 0; }
|
|
|
|
</style>
|
2021-05-19 04:39:27 +02:00
|
|
|
<script>
|
2022-08-31 12:27:06 +02:00
|
|
|
function initQRShow(data) {
|
|
|
|
return new Vue({
|
2020-10-21 14:03:11 +02:00
|
|
|
el: '#scan-qr-modal-app',
|
2022-08-31 12:27:06 +02:00
|
|
|
components: {
|
2020-10-21 14:03:11 +02:00
|
|
|
qrcode: VueQrcode
|
|
|
|
},
|
2022-08-31 12:27:06 +02:00
|
|
|
data() {
|
|
|
|
const res = Object.assign({}, {
|
|
|
|
title: "Scan QR",
|
|
|
|
modalId: "scan-qr-modal",
|
|
|
|
modes: {},
|
|
|
|
index: -1,
|
|
|
|
speed: 500,
|
|
|
|
active: false,
|
|
|
|
note: null,
|
|
|
|
continueTitle: null,
|
|
|
|
continueCallback: null,
|
|
|
|
qrOptions: {
|
|
|
|
width: 256,
|
|
|
|
height: 256,
|
|
|
|
margin: 1,
|
|
|
|
color: {
|
|
|
|
dark: '#000',
|
|
|
|
light: '#f5f5f7'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, data || {});
|
|
|
|
|
|
|
|
if (!Object.values(res.modes || {}).length) {
|
|
|
|
res.modes = { default: { title: 'Default', fragments: [res.data] } };
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!res.mode) {
|
|
|
|
res.mode = Object.keys(res.modes)[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2020-10-21 14:03:11 +02:00
|
|
|
},
|
2022-08-31 12:27:06 +02:00
|
|
|
computed: {
|
|
|
|
fragments() {
|
|
|
|
return this.currentMode && this.currentMode.fragments;
|
|
|
|
},
|
|
|
|
currentMode() {
|
|
|
|
return this.modes[this.mode];
|
|
|
|
},
|
|
|
|
currentFragment() {
|
|
|
|
return this.fragments && this.fragments[this.index];
|
|
|
|
}
|
2020-10-21 14:03:11 +02:00
|
|
|
},
|
2022-08-31 12:27:06 +02:00
|
|
|
mounted() {
|
|
|
|
$(`#${this.modalId}`)
|
|
|
|
.on("shown.bs.modal", () => { this.start(); })
|
|
|
|
.on("hide.bs.modal", () => { this.active = false; });
|
2020-10-21 14:03:11 +02:00
|
|
|
},
|
2022-08-31 12:27:06 +02:00
|
|
|
methods: {
|
|
|
|
start() {
|
|
|
|
this.active = true;
|
|
|
|
this.index = -1;
|
|
|
|
this.playNext();
|
2020-10-21 14:03:11 +02:00
|
|
|
},
|
2022-08-31 12:27:06 +02:00
|
|
|
playNext() {
|
|
|
|
if (!this.active) return;
|
|
|
|
|
|
|
|
this.index++;
|
|
|
|
if (this.index > (this.fragments.length - 1)) {
|
|
|
|
this.index = 0;
|
|
|
|
}
|
|
|
|
setTimeout(this.playNext, this.speed);
|
2020-10-21 14:03:11 +02:00
|
|
|
},
|
2022-08-31 12:27:06 +02:00
|
|
|
showData(data) {
|
|
|
|
this.modes = { default: { title: 'Default', fragments: [data] } };
|
2023-09-22 10:24:53 +02:00
|
|
|
this.mode = "default";
|
|
|
|
this.show();
|
|
|
|
},
|
|
|
|
show(){
|
2022-08-31 12:27:06 +02:00
|
|
|
$(`#${this.modalId}`).modal("show");
|
|
|
|
}
|
2020-10-21 14:03:11 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|