index.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div style="position: relative;width: 86%; margin-left: 7%; margin-top: 12px" @click="handleCardClick">
  3. <img src="http://staticweb.hnthyy.cn/images/electronic-health-card.png"
  4. style="width: 100%">
  5. <div style="position: absolute; bottom: 38px; left: 20px">
  6. <div style="font-size: 24px;">
  7. {{ cardInfo.blurName }}
  8. </div>
  9. <div>
  10. {{ cardInfo.blurIdNumber }}
  11. </div>
  12. </div>
  13. <div :id="cardInfo.healthCardId"
  14. style="position: absolute;
  15. background-color: white;
  16. height: 90px;
  17. bottom: 42px;
  18. right: 10px">
  19. </div>
  20. <div v-if="!cardInfo.healthCardId"
  21. style="
  22. position: absolute;
  23. top: 0; right: 0; bottom: 0; left: 0;
  24. background-color: rgba(255,255,255,.55);
  25. display: flex;
  26. align-items: center;
  27. justify-content: center;
  28. ">
  29. <div style="text-align: center; width: 300px">
  30. <span style="
  31. border-radius: 30px;
  32. background-color: #409eff;
  33. color: white;
  34. padding: 0 10px;
  35. font-size: 40px;">
  36. +
  37. </span>
  38. <div style="margin-top: 8px">点“+”申领电子健康卡</div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import {qrcanvas} from "qrcanvas";
  45. import {onMounted} from "vue";
  46. import router from '../../router/index'
  47. export default {
  48. props: {
  49. cardInfo: {
  50. type: Object,
  51. default: {}
  52. }
  53. },
  54. setup (props) {
  55. const handleCardClick = () => {
  56. if (props.cardInfo.healthCardId) {
  57. router.push({
  58. name: 'showCardQrCode',
  59. query: {
  60. card: encodeURIComponent(JSON.stringify(props.cardInfo))
  61. }
  62. })
  63. } else {
  64. router.push('/addElectronicHealthCard')
  65. }
  66. }
  67. onMounted(() => {
  68. if (props.cardInfo.healthCardId) {
  69. const canvas = qrcanvas({
  70. data: props.cardInfo.qrCodeText,
  71. size: 90,
  72. padding: 5,
  73. foreground: 'green',
  74. })
  75. document.getElementById(props.cardInfo.healthCardId).appendChild(canvas)
  76. }
  77. })
  78. return {
  79. handleCardClick
  80. }
  81. }
  82. }
  83. </script>