index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="chat-pinmsg" v-if="visible" @click="scrollToView">
  3. <label>{{$t('chat.news')}}:</label>
  4. <div class="msg-content">{{msg | decryptoMsg}}</div>
  5. <i class="msg-close" @click.stop="handleClose"></i>
  6. </div>
  7. </template>
  8. <script>
  9. import { MessageBox } from 'element-ui'
  10. import { mapState, mapActions } from 'vuex'
  11. import { decryptoMsg } from '@/util/util.js'
  12. export default {
  13. name: 'pinMsg',
  14. props: {
  15. visible: {
  16. type: Boolean,
  17. default: false
  18. },
  19. msg: {
  20. type: String,
  21. default: ''
  22. },
  23. hash: {
  24. type: String
  25. }
  26. },
  27. data () {
  28. return {
  29. }
  30. },
  31. computed: {
  32. ...mapState([
  33. 'userId'
  34. ]),
  35. ...mapState({
  36. adminList: state => state.group.adminList
  37. }),
  38. isAdmin () {
  39. return this.adminList && this.adminList.some(id => id == this.userId)
  40. }
  41. },
  42. methods: {
  43. ...mapActions(['doUnpinMsg']),
  44. handleClose (event) {
  45. if (this.isAdmin) {
  46. MessageBox.confirm(this.$t('chat.closePinMsg')).then(() => {
  47. this.doUnpinMsg({ hash: this.hash })
  48. }).catch((e) => {
  49. console.log(e)
  50. })
  51. } else {
  52. this.$emit('pinMsgClose')
  53. }
  54. },
  55. scrollToView (event) {
  56. this.$emit('scrollToView')
  57. }
  58. },
  59. mounted () {
  60. },
  61. filters: {
  62. decryptoMsg: decryptoMsg
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .chat-pinmsg{
  68. display: flex;
  69. height: 30px;
  70. background-color:#fafafa;
  71. justify-content: center;
  72. align-items: center;
  73. font-size: 12px;
  74. padding: 0 5px;
  75. }
  76. label{
  77. padding-left: 7px;
  78. font-weight: bold;
  79. }
  80. .msg-content{
  81. flex:1;
  82. width: 0;
  83. height: 30px;
  84. line-height: 30px;
  85. text-align: center;
  86. overflow: hidden;
  87. white-space: nowrap;
  88. text-overflow: ellipsis;
  89. }
  90. .msg-close{
  91. display: block;
  92. width: 20px;
  93. height: 20px;
  94. background: url("../../assets/icon_msg_close.png") no-repeat;
  95. background-size: 100% 100%;
  96. }
  97. .msg-content{
  98. cursor: pointer;
  99. }
  100. </style>