h5-qrcode.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div :class="config.classText.join(' ')">
  3. <div class="qrcode-container">
  4. <div class="qrcode-image-row">
  5. <img
  6. :src="config.qrcodeImage || require('@/assets/images/qr_code.png')"
  7. class="qrcode-image"
  8. :style="{ width: config.qrcodeSize + 'px', height: config.qrcodeSize + 'px' }"
  9. />
  10. </div>
  11. <div v-if="config.showCopyBtn" class="copy-btn-row">
  12. <button class="circle-btn copy-btn" :style="{ backgroundColor: config.copyBtnColor, color: config.copyBtnTextColor }">
  13. {{ config.copyBtnText }}
  14. </button>
  15. </div>
  16. <div v-if="config.showClickBtn" class="click-btn-row">
  17. <button class="circle-btn click-btn" :style="{ backgroundColor: config.clickBtnColor, color: config.clickBtnTextColor }">
  18. {{ config.clickBtnText }}
  19. </button>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'h5-qrcode',
  27. props: {
  28. config: {
  29. type: Object,
  30. default: () => ({
  31. classText: ['parent-div'],
  32. qrcodeImage: '',
  33. qrcodeSize: 140,
  34. showCopyBtn: true,
  35. copyBtnText: '复制并添加老师',
  36. copyBtnColor: '#FF9500',
  37. copyBtnTextColor: '#ffffff',
  38. showClickBtn: true,
  39. clickBtnText: '点击添加老师',
  40. clickBtnColor: '#FF9500',
  41. clickBtnTextColor: '#ffffff'
  42. })
  43. }
  44. }
  45. }
  46. </script>
  47. <style src="./css/base.css"></style>
  48. <style lang="scss" scoped>
  49. .qrcode-container {
  50. width: 100%;
  51. padding: 16px;
  52. display: flex;
  53. flex-direction: column;
  54. gap: 12px;
  55. align-items: center;
  56. }
  57. .qrcode-image-row {
  58. width: 100%;
  59. display: flex;
  60. justify-content: center;
  61. margin-bottom: 8px;
  62. }
  63. .qrcode-image {
  64. max-width: 100%;
  65. height: auto;
  66. border-radius: 4px;
  67. }
  68. .wechat-number-row {
  69. width: 100%;
  70. display: flex;
  71. justify-content: center;
  72. margin-bottom: 8px;
  73. }
  74. .wechat-number-text {
  75. font-size: 14px;
  76. color: #303133;
  77. text-align: center;
  78. }
  79. .copy-btn-row,
  80. .click-btn-row {
  81. width: 100%;
  82. display: flex;
  83. justify-content: center;
  84. margin-bottom: 8px;
  85. }
  86. .circle-btn {
  87. border: none;
  88. border-radius: 20px;
  89. padding: 10px 20px;
  90. font-size: 14px;
  91. cursor: pointer;
  92. transition: all 0.3s ease;
  93. white-space: nowrap;
  94. font-weight: 500;
  95. &:hover {
  96. opacity: 0.9;
  97. }
  98. &:active {
  99. opacity: 0.8;
  100. }
  101. }
  102. .copy-btn {
  103. min-width: 160px;
  104. }
  105. .click-btn {
  106. min-width: 160px;
  107. }
  108. .active {
  109. border-color: #02ff9b;
  110. }
  111. </style>