index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="chat-at">
  3. <div class="bar-wrap">
  4. <div ref="container">
  5. <div class="item"
  6. v-for="(item, key) in filterList"
  7. :key="key"
  8. @click.stop="atPerson(key)"
  9. :class="{'active': key == curInd}"
  10. >
  11. <div class="avatar" :class="`avatar_bg${item.user_id % 9}`">
  12. <img :src="item.cover_photo" v-if="item.cover_photo">
  13. <template v-else>
  14. {{item.nick_name.slice(0,2).toUpperCase()}}
  15. </template>
  16. </div>
  17. <div class="name">
  18. <p class="nick-name">
  19. {{item.nick_name}}
  20. <span :class="['status-identity','identity'+item.is_admin]" v-if="item.is_admin>0">{{item.is_admin==1?"管理员":"群主"}}</span>
  21. <span class="status-forbidden" v-if="item.is_block==1"> 禁言</span>
  22. </p>
  23. <p class="user-name">@{{item.user_name}}</p>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { mapState } from 'vuex'
  32. export default {
  33. name: 'chatAt',
  34. props: {
  35. curInd: {
  36. type: Number
  37. },
  38. filterList: {
  39. type: Array
  40. }
  41. },
  42. computed: {
  43. ...mapState([
  44. 'userId'
  45. ])
  46. },
  47. data () {
  48. return {
  49. showFilterList: []
  50. }
  51. },
  52. watch: {
  53. curInd (val) {
  54. this.scrollIntoView()
  55. }
  56. },
  57. methods: {
  58. atPerson (key) {
  59. let item = this.filterList[key]
  60. this.$emit('atperson', item.user_name)
  61. },
  62. scrollIntoView () {
  63. let dom = this.$refs.container.children[this.curInd]
  64. if (dom && dom.scrollIntoView) {
  65. dom.scrollIntoView({
  66. behavior: 'smooth',
  67. block: 'center',
  68. inline: 'nearest'
  69. })
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .chat-at {
  77. position: absolute;
  78. top: -100px;
  79. left: 2px;
  80. right: 2px;
  81. height: 100px;
  82. background-color: #ffffff;
  83. border-top-left-radius: 4px;
  84. border-top-right-radius: 4px;
  85. box-shadow: 0 0 2px rgba($color: #3a3a3a, $alpha: .3);
  86. }
  87. .bar-wrap{
  88. height: 100%;
  89. overflow-y: scroll;
  90. &::-webkit-scrollbar {
  91. width: 8px;
  92. height: 6px;
  93. }
  94. &::-webkit-scrollbar-thumb {
  95. border-radius: 3px;
  96. -moz-border-radius: 3px;
  97. -webkit-border-radius: 3px;
  98. background-color: rgba($color: #8d8a8a, $alpha: 0.2);
  99. }
  100. &::-webkit-scrollbar-track {
  101. background-color: transparent;
  102. }
  103. }
  104. .item{
  105. padding: 6px 8px;
  106. line-height: 20px;
  107. cursor: pointer;
  108. &.active{
  109. background-color: #eeeeee;
  110. }
  111. &:hover{
  112. background-color: #eeeeee;
  113. }
  114. }
  115. .avatar{
  116. display: inline-block;
  117. vertical-align: middle;
  118. margin-right: 10px;
  119. width: 20px;
  120. height: 20px;
  121. border-radius: 2px;
  122. line-height: 20px;
  123. text-align: center;
  124. color: #ffffff;
  125. font-size: 12px;
  126. overflow: hidden;
  127. img{
  128. width: 100%;
  129. height: 100%;
  130. vertical-align: top;
  131. }
  132. }
  133. .name{
  134. font-size: 12px;
  135. display: inline-block;
  136. vertical-align: top;
  137. }
  138. .nick-name{
  139. line-height: 1;
  140. color: #333333;
  141. }
  142. .user-name{
  143. line-height: 1;
  144. color: #a8a8a8;
  145. }
  146. .status-identity{
  147. padding-right: 14px;
  148. &.identity1{
  149. background: url('../../assets/icon-admin.png') right / 12px 11px no-repeat;
  150. }
  151. &.identity2{
  152. background: url('../../assets/icon-creater.png') right / 12px 11px no-repeat;
  153. }
  154. }
  155. .status-forbidden{
  156. color: #a8a8a8;
  157. }
  158. </style>