atme.vue 1.9 KB

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