index.vue 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="share-pg">
  3. <GoBack class="goback abs" style="z-index: 100" @click="router.go(-1)" />
  4. <div class="will-copy" ref="src">
  5. <img class="copy-img" src="/images/share.jpg" alt="" />
  6. <div class="content txt">
  7. <div class="name">{{ user.nickname || "朋友" }}</div>
  8. <div style="line-height: 1.6em">
  9. 您是第{{user.num}}位“紫金草行动”参与者。播撒紫金草种子,让和平之花开满全城。
  10. </div>
  11. </div>
  12. </div>
  13. <img class="img-target" :src="imgData" v-if="imgData" alt="" />
  14. </div>
  15. </template>
  16. <script setup>
  17. import { onMounted,watch, ref } from "vue";
  18. import html2canvas from "html2canvas";
  19. import { useModel } from "@zjxpcyc/vue-tiny-store";
  20. import { useRouter } from "vue-router";
  21. import GoBack from "@/components/GoBack.vue";
  22. const router = useRouter();
  23. const { user } = useModel("user");
  24. const imgData = ref();
  25. const src = ref();
  26. onMounted(() => {
  27. setTimeout(()=>{
  28. html2canvas(src.value).then((canvas) => {
  29. imgData.value = canvas.toDataURL("image/jpg", 0.8);
  30. });
  31. },1000)
  32. });
  33. </script>
  34. <style lang="less" scoped>
  35. .share-pg {
  36. position: relative;
  37. .goback{
  38. z-index: 100;
  39. left: 10px;
  40. top: 10px;
  41. }
  42. .will-copy {
  43. position: relative;
  44. z-index: 1;
  45. width: 100vw;
  46. height: 100vh;
  47. .copy-img {
  48. width: 100%;
  49. height: 100%;
  50. }
  51. }
  52. .content {
  53. position: absolute;
  54. top: 55vh;
  55. left: 10vw;
  56. text-align: left;
  57. width: 56vw;
  58. .name {
  59. font-size: 18px;
  60. }
  61. }
  62. .img-target {
  63. position: absolute;
  64. z-index: 2;
  65. width: 100vw;
  66. height: 100vh;
  67. top: 0;
  68. left: 0;
  69. }
  70. }
  71. </style>