Chat.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <el-container class="chat-page">
  3. <el-aside width="260px" class="chat-list-box">
  4. <div class="chat-list-header">
  5. <el-input class="search-text" size="small" placeholder="搜索" v-model="searchText">
  6. <i class="el-icon-search el-input__icon" slot="prefix"> </i>
  7. </el-input>
  8. </div>
  9. <div class="chat-list-loading" v-if="loading" v-loading="true" element-loading-text="消息接收中..."
  10. element-loading-spinner="el-icon-loading" element-loading-background="#F9F9F9" element-loading-size="24">
  11. </div>
  12. <el-scrollbar class="chat-list-items" v-else>
  13. <div v-for="(chat, index) in chatStore.chats" :key="index">
  14. <chat-item v-show="!chat.delete && chat.showName && chat.showName.includes(searchText)" :chat="chat" :index="index"
  15. @click.native="onActiveItem(index)" @delete="onDelItem(index)" @top="onTop(index)"
  16. :active="chat === chatStore.activeChat"></chat-item>
  17. </div>
  18. </el-scrollbar>
  19. </el-aside>
  20. <el-container class="chat-box">
  21. <chat-box v-if="chatStore.activeChat" :chat="chatStore.activeChat"></chat-box>
  22. </el-container>
  23. </el-container>
  24. </template>
  25. <script>
  26. import ChatItem from "../components/chat/ChatItem.vue";
  27. import ChatBox from "../components/chat/ChatBox.vue";
  28. export default {
  29. name: "chat",
  30. components: {
  31. ChatItem,
  32. ChatBox
  33. },
  34. data() {
  35. return {
  36. searchText: "",
  37. messageContent: "",
  38. group: {},
  39. groupMembers: []
  40. }
  41. },
  42. methods: {
  43. onActiveItem(index) {
  44. this.$store.commit("activeChat", index);
  45. },
  46. onDelItem(index) {
  47. this.$store.commit("removeChat", index);
  48. },
  49. onTop(chatIdx) {
  50. this.$store.commit("moveTop", chatIdx);
  51. },
  52. },
  53. computed: {
  54. chatStore() {
  55. return this.$store.state.chatStore;
  56. },
  57. loading() {
  58. return this.chatStore.loadingGroupMsg || this.chatStore.loadingPrivateMsg
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .chat-page {
  65. .chat-list-box {
  66. display: flex;
  67. flex-direction: column;
  68. background: var(--im-background);
  69. .chat-list-header {
  70. height: 50px;
  71. display: flex;
  72. align-items: center;
  73. padding: 0 8px;
  74. }
  75. .chat-list-loading {
  76. height: 50px;
  77. background-color: #eee;
  78. .el-icon-loading {
  79. font-size: 24px;
  80. color: var(--im-text-color-light);
  81. }
  82. .el-loading-text {
  83. color: var(--im-text-color-light);
  84. }
  85. .chat-loading-box {
  86. height: 100%;
  87. }
  88. }
  89. .chat-list-items {
  90. flex: 1;
  91. }
  92. }
  93. }
  94. </style>