atme.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="at-me" v-if="atList && atList.length">
  3. <div class="at-me-item" v-if="atNum >= 2 && totalVisible" @click="scrollToMsg">
  4. <div class="at-content">{{$t('chat.hava')}}{{atNum}}{{$t('chat.atYouWithPeople')}}</div>
  5. <i class="icon-close" :title="$t('public.close')" @click.stop="totalVisible = false"></i>
  6. </div>
  7. <div class="at-me-item" v-else-if="atNum && itemVisible" @click="scrollToMsg">
  8. <div class="at-content">{{atList[0].name}}{{$t('chat.atYou')}}</div>
  9. <i class="icon-close" :title="$t('public.close')" @click.stop="closeAtme"></i>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import _ from 'lodash'
  15. import { mapMutations } from 'vuex'
  16. export default {
  17. name: 'atMe',
  18. props: {
  19. atList: [Array]
  20. },
  21. computed: {
  22. atNum () {
  23. return _.unionBy(this.atList, 'userId').length
  24. }
  25. },
  26. data () {
  27. return {
  28. totalVisible: true,
  29. itemVisible: true
  30. }
  31. },
  32. methods: {
  33. ...mapMutations([
  34. 'clearAtList'
  35. ]),
  36. scrollToMsg () {
  37. this.$emit('scrollToMsg', this.atList.length - 1)
  38. },
  39. closeAtme () {
  40. this.itemVisible = false
  41. this.clearAtList()
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .at-me{
  48. position:absolute;
  49. left: 0;
  50. bottom: 3px;
  51. right: 22px;
  52. height: 32px;
  53. display: flex;
  54. justify-content: flex-end;
  55. // pointer-events: none;
  56. .mini{
  57. right: 8px;
  58. }
  59. .at-me-item{
  60. box-sizing: border-box;
  61. height: 100%;
  62. padding: 10px;
  63. padding-right: 0;
  64. margin-left: 5px;
  65. border: 1px solid rgba($color: #000000, $alpha: 0.1);
  66. background: #fff;
  67. display: flex;
  68. align-items: center;
  69. cursor: pointer;
  70. }
  71. .at-content{
  72. font-size: 14px;
  73. color: #259af2;
  74. margin-right: 5px;
  75. }
  76. .icon-close{
  77. display: block;
  78. width: 7px;
  79. height: 7px;
  80. padding:3px 12px;
  81. border-left: 1px solid rgba($color: #000000, $alpha: 0.1);
  82. background: url(./assets/icon-close.png) center no-repeat;
  83. cursor: pointer;
  84. }
  85. }
  86. </style>