123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template>
- <div class="chat-pinmsg" v-if="visible" @click="scrollToView">
- <label>{{$t('chat.news')}}:</label>
- <div class="msg-content">{{msg | decryptoMsg}}</div>
- <i class="msg-close" @click.stop="handleClose"></i>
- </div>
- </template>
- <script>
- import { MessageBox } from 'element-ui'
- import { mapState, mapActions } from 'vuex'
- import { decryptoMsg } from '@/util/util.js'
- export default {
- name: 'pinMsg',
- props: {
- visible: {
- type: Boolean,
- default: false
- },
- msg: {
- type: String,
- default: ''
- },
- hash: {
- type: String
- }
- },
- data () {
- return {
- }
- },
- computed: {
- ...mapState([
- 'userId'
- ]),
- ...mapState({
- adminList: state => state.group.adminList
- }),
- isAdmin () {
- return this.adminList && this.adminList.some(id => id == this.userId)
- }
- },
- methods: {
- ...mapActions(['doUnpinMsg']),
- handleClose (event) {
- if (this.isAdmin) {
- MessageBox.confirm(this.$t('chat.closePinMsg')).then(() => {
- this.doUnpinMsg({ hash: this.hash })
- }).catch((e) => {
- console.log(e)
- })
- } else {
- this.$emit('pinMsgClose')
- }
- },
- scrollToView (event) {
- this.$emit('scrollToView')
- }
- },
- mounted () {
- },
- filters: {
- decryptoMsg: decryptoMsg
- }
- }
- </script>
- <style lang="scss" scoped>
- .chat-pinmsg{
- display: flex;
- height: 30px;
- background-color:#fafafa;
- justify-content: center;
- align-items: center;
- font-size: 12px;
- padding: 0 5px;
- }
- label{
- padding-left: 7px;
- font-weight: bold;
- }
- .msg-content{
- flex:1;
- width: 0;
- height: 30px;
- line-height: 30px;
- text-align: center;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .msg-close{
- display: block;
- width: 20px;
- height: 20px;
- background: url("../../assets/icon_msg_close.png") no-repeat;
- background-size: 100% 100%;
- }
- .msg-content{
- cursor: pointer;
- }
- </style>
|