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