context-share.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div class="share" v-if="type === '5'">
  3. <el-button class="show copy" type="text" @click="useCopyText(props.content!, props.id!)">复制话术内容</el-button>
  4. <div class="showNum" v-if="allStatus === 1">已使用:{{ props.pv || 0 }}次</div>
  5. </div>
  6. <div class="share" v-else>
  7. <div class="show" @click.stop="handleDetail(props)">查看{{ controlText }}</div>
  8. <div class="show" @click.stop="
  9. useWeChatShare({
  10. type: props.type!,
  11. id: props.id!,
  12. spId: serviceProviderId as number,
  13. imageUrl: imageLink,
  14. isShowToast: true,
  15. suid: userId as number,
  16. })
  17. ">
  18. 分享
  19. </div>
  20. </div>
  21. </template>
  22. <script setup lang="ts">
  23. import { DArchiveResultData } from "@/types/api/context.type";
  24. import { DFindParams, DScrollTab, tabList } from "@/types/views/database.type";
  25. import { computed } from "vue";
  26. import useWeChatShare from "@/Hooks/useWeChatShare";
  27. import { useUserInfoState } from "@/store/user/user";
  28. import getFileImg from "@/Hooks/useFileImage";
  29. import useCopyText from '@/Hooks/useCopyText';
  30. const props = defineProps<DArchiveResultData>();
  31. const { serviceProviderId, userId } = useUserInfoState();
  32. const imageLink = computed<string>(() => {
  33. if (props.type !== "3") return props.image as string;
  34. else return getFileImg(props.waters![0] && props.waters![0].split('?')[0]).img as string;
  35. });
  36. const controlText = computed<DFindParams<DScrollTab, "text">>(
  37. () => tabList.filter((e) => e.type === props.type)[0].text
  38. );
  39. const handleDetail = ($event: DArchiveResultData) => {
  40. const link =
  41. import.meta.env.VITE_HTTP_URL +
  42. (Number($event.type) === 7 ? "/encyclopedia/detail-" : "/info/detail-") +
  43. $event.id +
  44. (Number($event.type) === 6 ? "-1.html" : ".html");
  45. console.log('链接', link)
  46. if (Number($event.type) > 5) return window.open(link);
  47. window.location.href = "/database/detail?id=" + $event.id + "&t=" + $event.type
  48. };
  49. </script>
  50. <style scoped lang="scss">
  51. .share {
  52. display: flex;
  53. align-items: center;
  54. .show {
  55. margin-left: 24px;
  56. color: $basicColor;
  57. font-size: $basicFS;
  58. }
  59. .showNum {
  60. margin-left: 24px;
  61. background: #f5f5f5;
  62. padding: 3px 9px;
  63. border-radius: 2px;
  64. font-size: $basicFS-foot;
  65. color: #666;
  66. }
  67. }
  68. </style>