index.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="qrCode">
  3. <el-dialog :title="title"
  4. :visible.sync="status"
  5. @close="onDialogClose"
  6. append-to-body
  7. width="300px">
  8. <div class="left-code">
  9. <vue-qr :text="codeUrl" style="width: 100%" :margin="0"></vue-qr>
  10. <p class="code-url" v-if="codeUrl"><copy-text>{{ codeUrl }}</copy-text></p>
  11. </div>
  12. <el-button v-if="ispreLook" type="primary" style="width:100%" @click="preLook">预 览</el-button>
  13. </el-dialog>
  14. </div>
  15. </template>
  16. <script>
  17. import VueQr from 'vue-qr'
  18. import copy from 'copy-to-clipboard'
  19. export default {
  20. data() {
  21. return {
  22. status: false
  23. };
  24. },
  25. components: {
  26. VueQr
  27. },
  28. props: {
  29. value: {
  30. // 组件状态
  31. type: Boolean,
  32. required: true,
  33. default() {
  34. return false
  35. }
  36. },
  37. title: {
  38. type: String,
  39. default() {
  40. return '查看二维码'
  41. }
  42. },
  43. codeUrl: {
  44. type: String
  45. },
  46. ispreLook:{
  47. type: Boolean,
  48. default() {
  49. return false
  50. }
  51. }
  52. },
  53. mounted() {
  54. this.status = this.value
  55. },
  56. methods: {
  57. onDialogClose() {
  58. this.status = false
  59. this.$emit('input', false)
  60. },
  61. copyUrl(url) {
  62. copy(url)
  63. this.$message.success('复制成功')
  64. },
  65. preLook(){
  66. this.$emit('preLook')
  67. }
  68. },
  69. watch: {
  70. value(newValue) {
  71. this.status = newValue;
  72. },
  73. title(newValue, oldValue) {
  74. if(newValue != oldValue) {
  75. this.title = newValue
  76. }
  77. }
  78. },
  79. beforeDestroy() {},
  80. };
  81. </script>
  82. <style lang="scss">
  83. .left-code{
  84. .code-url{
  85. margin-top: 10px;
  86. margin-bottom: 10px;
  87. .link-btn{
  88. margin-top: 0;
  89. margin-bottom: 0;
  90. font-size: 12px;
  91. }
  92. }
  93. }
  94. </style>