chatRoom.vue 3.7 KB

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