HealthEducation.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <window-size :showBackNav="false">
  3. <van-collapse v-model="activeName" accordion>
  4. <van-collapse-item v-for="(val, key) in videoMap" :name="key">
  5. <template #title>
  6. <div style="color: green; font-weight: bold">{{key}}</div>
  7. </template>
  8. <van-cell v-for="item in val" :title="item.name" is-link @click="drawQrCode(item.url)"></van-cell>
  9. </van-collapse-item>
  10. </van-collapse>
  11. <van-popup v-model:show="showQr" closeable position="bottom" :style="{ height: '300px' }">
  12. <van-grid :border="false" :column-num="1">
  13. <van-grid-item>
  14. <van-image fit="fill" style="width: 240px; height: 240px"
  15. :src="qrcodeUrl" />
  16. <span style="color: orangered; font-size: 12px; margin-top: 8px">长按二维码识别</span>
  17. </van-grid-item>
  18. </van-grid>
  19. </van-popup>
  20. </window-size>
  21. </template>
  22. <script setup>
  23. import {onMounted, ref} from "vue";
  24. import {getVideoUrls} from "../../api/isolations/health-education";
  25. import {qrcanvas} from "qrcanvas";
  26. const videoMap = ref({})
  27. const showQr = ref(false)
  28. const qrcodeUrl = ref(null)
  29. const activeName = ref('')
  30. function drawQrCode(url) {
  31. const canvas = qrcanvas({
  32. data: url,
  33. size: 164,
  34. })
  35. qrcodeUrl.value = canvas.toDataURL()
  36. showQr.value = true
  37. }
  38. onMounted(() => {
  39. getVideoUrls().then(res => {
  40. videoMap.value = res
  41. })
  42. })
  43. </script>
  44. <style scoped>
  45. :deep(.van-collapse-item__content) {
  46. padding: 0 0 0 14px;
  47. }
  48. </style>