ShareModal.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import { IconWechat } from "@/assets/icons";
  2. import { PromotionController } from "@/modules/resource/controllers/PromotionController";
  3. import { clipboard } from "@/utils";
  4. import { useAuth } from "@queenjs-modules/auth";
  5. import { Image } from "@queenjs/ui";
  6. import { useQRCode } from "@vueuse/integrations/useQRCode";
  7. import { Button, Divider, Input } from "ant-design-vue";
  8. import { defineComponent, reactive } from "vue";
  9. import { any } from "vue-types";
  10. export default defineComponent({
  11. props: {
  12. record: any().isRequired,
  13. controller: any<PromotionController>().isRequired,
  14. },
  15. setup(props, { slots }) {
  16. const auth = useAuth();
  17. const userInfo: any = auth.store.userInfo;
  18. const isSys = userInfo.roles?.includes("system") ? true : false;
  19. let shareLink =
  20. location.origin +
  21. "/share.html?id=" +
  22. props.record._id +
  23. "&isSys=" +
  24. isSys;
  25. // if (location.host == "www.infish.cn") {
  26. // shareLink =
  27. // location.origin +
  28. // "/projects/queenshowv1/share.html?id=" +
  29. // props.record._id;
  30. // }
  31. const qrUrl = useQRCode(shareLink, { margin: 2 });
  32. const state = reactive({
  33. ...props.record,
  34. });
  35. return () => {
  36. const { controller, record } = props;
  37. const { desc, thumbnail, title } = state;
  38. return (
  39. <div class="flex items-start">
  40. <div>
  41. <div class="scrollbar h-600px relative overflow-y-auto border-1px border-solid border-dark-50">
  42. {slots.preview?.()}
  43. </div>
  44. <div class="mt-20px text-center">
  45. <Button
  46. ghost
  47. type="primary"
  48. onClick={() => controller.onEdit(record)}
  49. >
  50. 编辑作品
  51. </Button>
  52. </div>
  53. </div>
  54. <div class="flex-1 ml-40px">
  55. <h3 class="mb-20px text-16px">分享设置</h3>
  56. <div class="flex items-start">
  57. <div class="relative">
  58. <Image
  59. class="w-80px h-80px object-contain rounded-4px border-1px border-solid border-[#434343]"
  60. src={thumbnail}
  61. />
  62. <div
  63. class="absolute left-0 bottom-0 w-1/1 text-center py-5px text-14px bg-dark-200 bg-opacity-80 cursor-pointer"
  64. onClick={async () => {
  65. const res: any = await controller.changeThumbnail();
  66. state.thumbnail = res[0]?.file?.url;
  67. }}
  68. >
  69. 更换封面
  70. </div>
  71. </div>
  72. <div class="flex-1 ml-20px">
  73. <Input
  74. class="w-1/1"
  75. placeholder="请输入标题"
  76. defaultValue={title}
  77. onChange={(e: any) => {
  78. const title = e.target.value;
  79. // if (!title) return;
  80. state.title = title;
  81. }}
  82. />
  83. <Input
  84. class="mt-10px w-1/1"
  85. placeholder="请输入描述"
  86. defaultValue={desc}
  87. onChange={(e: any) => {
  88. const desc = e.target.value;
  89. // if (!desc) return;
  90. state.desc = desc;
  91. }}
  92. />
  93. </div>
  94. </div>
  95. <div class="mt-30px text-center">
  96. <Button
  97. type="primary"
  98. class="w-150px"
  99. onClick={() => controller.updateDesign(record, state)}
  100. >
  101. 保存
  102. </Button>
  103. </div>
  104. <Divider />
  105. <div class="mt-40px flex">
  106. <div>
  107. <h3 class="text-16px">二维码</h3>
  108. <div class="mt-20px">
  109. <img class="w-120px" src={qrUrl.value} />
  110. </div>
  111. <div class="flex items-center justify-center mt-6px">
  112. <IconWechat class="mr-5px text-20px !text-[#69bb64] leading-0" />
  113. <span class="opacity-80 text-12px">微信扫一扫分享</span>
  114. </div>
  115. </div>
  116. <div class="flex-1 w-0 ml-50px">
  117. <h3 class=" text-16px">链接分享</h3>
  118. <div class="mt-20px">
  119. <div class="w-1/1 py-4px px-10px rounded-2px truncate opacity-80 bg-light-50 bg-opacity-8">
  120. {shareLink}
  121. </div>
  122. <Button
  123. class="mt-10px"
  124. type="primary"
  125. ghost
  126. onClick={() => clipboard.copy(shareLink)}
  127. >
  128. 复制链接
  129. </Button>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. );
  136. };
  137. },
  138. });