index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="dialogue">
  3. <custom-header :name="nameVal || '飞鸟种植助手'" bgColor="#f2f3f5" isGoBack @goback="headerCallBack"></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, ref } from "vue";
  10. import chatWindow from "@/components/chatWindow";
  11. import { useRoute, useRouter } from "vue-router";
  12. const route = useRoute();
  13. const router = useRouter();
  14. const desc = ref("");
  15. const nameVal = ref("");
  16. const userIdVal = ref(null);
  17. const imgVal = ref("");
  18. const formPageVal = ref("");
  19. onActivated(() => {
  20. userIdVal.value = null;
  21. setTimeout(() => {
  22. const { text, formPage, userId, img } = route.query;
  23. desc.value = text;
  24. userIdVal.value = userId;
  25. imgVal.value = img;
  26. formPageVal.value = formPage;
  27. if(formPage) {
  28. sessionStorage.setItem('chat_frame_page', formPage);
  29. }
  30. }, 100);
  31. });
  32. function headerCallBack() {
  33. const page = sessionStorage.getItem('chat_frame_page');
  34. if(page === 'messageList' || page === 'monitor') {
  35. VE_API.bbs.readUpdate({ targetUserId: userIdVal.value, farmId: route.query.farmId }).then((res) => {
  36. if (res.code === 0) {
  37. sessionStorage.removeItem('chat_frame_page');
  38. router.replace({ path: '/message_list', query: { farmId: route.query.farmId, from: 'monitor' } });
  39. }
  40. });
  41. } else {
  42. router.go(-1);
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .dialogue {
  48. width: 100%;
  49. height: calc(100vh - 40px);
  50. background: #f2f3f5;
  51. box-sizing: border-box;
  52. .chat-container {
  53. display: flex;
  54. flex-direction: column;
  55. height: 100%;
  56. width: 100%;
  57. margin: 0 auto;
  58. border: 1px solid #e6e6e6;
  59. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  60. }
  61. }
  62. </style>