index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="dialogue">
  3. <custom-header :name="nameVal" bgColor="#f2f3f5"></custom-header>
  4. <chat-window :text="desc" :userId="userIdVal" :img="imgVal" @update:name="nameVal = $event"></chat-window>
  5. </div>
  6. </template>
  7. <script setup>
  8. import customHeader from "@/components/customHeader.vue";
  9. import { onActivated, onDeactivated, ref } from "vue";
  10. import chatWindow from "@/components/chatWindow";
  11. import { useRoute, useRouter } from "vue-router";
  12. import eventBus from "@/api/eventBus";
  13. const route = useRoute();
  14. const router = useRouter();
  15. const desc = ref("");
  16. const nameVal = ref("");
  17. const userIdVal = ref(null);
  18. const imgVal = ref("");
  19. onActivated(() => {
  20. userIdVal.value = null;
  21. eventBus.off("header:goback", headerCallBack);
  22. setTimeout(() => {
  23. const { text, name, userId, img } = route.query;
  24. desc.value = text;
  25. nameVal.value = name;
  26. userIdVal.value = userId;
  27. imgVal.value = img;
  28. eventBus.on("header:goback", headerCallBack);
  29. }, 100);
  30. });
  31. function headerCallBack() {
  32. if (desc.value) {
  33. router.go("-2");
  34. } else {
  35. router.go("-1");
  36. }
  37. }
  38. onDeactivated(() => {
  39. eventBus.off("header:goback", headerCallBack);
  40. VE_API.bbs.readUpdate({ targetUserId: userIdVal.value }).then((res) => {
  41. if (res.success) {
  42. eventBus.emit("isUpdateTotal");
  43. }
  44. });
  45. });
  46. </script>
  47. <style lang="scss" scoped>
  48. .dialogue {
  49. width: 100%;
  50. height: calc(100vh - 40px);
  51. background: #f2f3f5;
  52. box-sizing: border-box;
  53. .chat-container {
  54. display: flex;
  55. flex-direction: column;
  56. height: 100%;
  57. width: 100%;
  58. margin: 0 auto;
  59. border: 1px solid #e6e6e6;
  60. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  61. }
  62. }
  63. </style>