chatRoom.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="c-view">
  3. <div class="box">
  4. <div class="box-hd">
  5. <div class="title-wrap">
  6. {{isPrivate ? group.privateName : group.groupName}}
  7. <span v-if="!isPrivate">({{group.membersNum}})</span>
  8. <i
  9. class="el-icon-more"
  10. v-if="!isPrivate"
  11. @click="groupSet = !groupSet"
  12. ></i>
  13. </div>
  14. </div>
  15. <chat-pin v-bind="pinMsg" @pinMsgClose="pinMsgClose" @scrollToView="scrollToView"></chat-pin>
  16. <div class="box-bd" :class="{'hidden': bdHiden}">
  17. <div ref="scrollWrap" class="bar" @scroll="handleScroll">
  18. <div ref="msgWrap" class="scroll-wrapper">
  19. <div class="msg-wrap">
  20. <div class="msg-top-more" v-if="lockEnd">
  21. <em>没有更多了</em>
  22. </div>
  23. <div class="msg-top-load" v-if="lockMore && !lockEnd">
  24. <i class="msg-loading-icon"></i>
  25. </div>
  26. <template v-if="group.chatList.length">
  27. <msg-item
  28. v-for="(item ,key) in group.pinList"
  29. :key="'pin' + key"
  30. v-bind="item"
  31. @quoteMsg="quoteMsg"
  32. @deleteMsg="deleteMsg"
  33. ></msg-item>
  34. </template>
  35. <msg-item
  36. v-for="(item, key) in chatList"
  37. :key="key"
  38. :isPrivate="isPrivate"
  39. :msgItem="item"
  40. v-bind="item"
  41. @quoteMsg="quoteMsg"
  42. @deleteMsg="deleteMsg"
  43. ></msg-item>
  44. </div>
  45. </div>
  46. </div>
  47. <at-me v-if="!isPrivate" :atList="atList" @scrollToMsg="scrollToMsg"></at-me>
  48. <div
  49. class="msg-unread"
  50. @click="doSetRead"
  51. v-if="group.unreadNums > 0 && enableScroll && !isBottom"
  52. >
  53. <em>
  54. <i class="el-icon-d-arrow-right"></i>
  55. {{group.unreadNums}}条未读消息
  56. </em>
  57. </div>
  58. </div>
  59. <input-area ref="inputArea" @toBottom="resizeToBottom" v-show="isJoinGroup==1"></input-area>
  60. <div @click="joinGroup()" class="btn-join" v-show="isJoinGroup==0">加入群聊</div>
  61. </div>
  62. <chat-set
  63. @handleShowGroudMgr="showGroudMgr"
  64. v-if="group.members && !isPrivate"
  65. :class="{'move-left': groupSet}"
  66. ></chat-set>
  67. <chat-groud-mgr
  68. @handleShowGroudMgr="showGroudMgr"
  69. @handleShowCharSet="showCharSet"
  70. v-show="isCreator"
  71. :class="{'move-left': isShowGroudMgr}"
  72. ></chat-groud-mgr>
  73. </div>
  74. </template>
  75. <script>
  76. import Vue from 'vue'
  77. import msgItem from '@/components/msgItem'
  78. import chatPin from '@/components/chatPin'
  79. import atMe from '@/components/chatAt/atme'
  80. import { chatMixin } from '@/mixins/chat'
  81. import chatSet from '@/components/chatSet'
  82. import inputArea from './inputArea'
  83. import { getResizeHeight } from '@/util/util.js'
  84. import { Button } from 'element-ui'
  85. import chatGroudMgr from '@/components/chatGroudMgr'
  86. Vue.component(Button.name, Button)
  87. export default {
  88. name: 'chatRoom',
  89. mixins: [chatMixin],
  90. data () {
  91. return {
  92. isShowGroudMgr: false,
  93. bdHiden: true
  94. }
  95. },
  96. components: {
  97. msgItem,
  98. inputArea,
  99. chatGroudMgr,
  100. chatSet,
  101. chatPin,
  102. atMe
  103. },
  104. methods: {
  105. showCharSet (flag) {
  106. this.groupSet = flag == 1
  107. this.isShowGroudMgr = false
  108. },
  109. showGroudMgr (flag) {
  110. this.isShowGroudMgr = flag == 1
  111. }
  112. },
  113. mounted () {
  114. this.scrollHeight = getResizeHeight()
  115. window.onresize = () => {
  116. this.scrollHeight = getResizeHeight()
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. @import "./chatRoom.scss";
  123. </style>