1
0

qrcode_modal.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {{define "qrcodeModal"}}
  2. <a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title"
  3. :closable="true"
  4. :class="themeSwitcher.darkCardClass"
  5. :footer="null"
  6. width="300px">
  7. <a-tag color="green" style="margin-bottom: 10px;display: block;text-align: center;">
  8. {{ i18n "pages.inbounds.clickOnQRcode" }}
  9. </a-tag>
  10. <a-tag v-if="qrModal.clientName" color="orange" style="margin-bottom: 10px;display: block;text-align: center;">
  11. {{ i18n "pages.inbounds.email" }}: "[[ qrModal.clientName ]]"
  12. </a-tag>
  13. <canvas @click="copyToClipboard()" id="qrCode" style="width: 100%; height: 100%; margin-top: 10px;"></canvas>
  14. </a-modal>
  15. <script>
  16. const qrModal = {
  17. title: '',
  18. content: '',
  19. inbound: new Inbound(),
  20. dbInbound: new DBInbound(),
  21. copyText: '',
  22. clientName: null,
  23. qrcode: null,
  24. clipboard: null,
  25. visible: false,
  26. show: function (title = '', content = '', dbInbound = new DBInbound(), copyText = '', clientName = null) {
  27. this.title = title;
  28. this.content = content;
  29. this.dbInbound = dbInbound;
  30. this.inbound = dbInbound.toInbound();
  31. this.clientName = clientName;
  32. if (ObjectUtil.isEmpty(copyText)) {
  33. this.copyText = content;
  34. } else {
  35. this.copyText = copyText;
  36. }
  37. this.visible = true;
  38. qrModalApp.$nextTick(() => {
  39. if (this.qrcode === null) {
  40. this.qrcode = new QRious({
  41. element: document.querySelector('#qrCode'),
  42. size: 260,
  43. value: content,
  44. });
  45. } else {
  46. this.qrcode.value = content;
  47. }
  48. });
  49. },
  50. close: function () {
  51. this.visible = false;
  52. },
  53. };
  54. const qrModalApp = new Vue({
  55. delimiters: ['[[', ']]'],
  56. el: '#qrcode-modal',
  57. data: {
  58. qrModal: qrModal,
  59. },
  60. methods: {
  61. copyToClipboard() {
  62. this.qrModal.clipboard = new ClipboardJS('#qrCode', {
  63. text: () => this.qrModal.copyText,
  64. });
  65. this.qrModal.clipboard.on('success', () => {
  66. app.$message.success('{{ i18n "copied" }}')
  67. this.qrModal.clipboard.destroy();
  68. });
  69. }
  70. },
  71. });
  72. </script>
  73. {{end}}