uni-im-group-notification.vue 1.8 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7
<template>
  <view class="system-msg-box">
    <view class="system-msg group-notification">
      <view class="title-box">
        <uni-icons size="26" type="sound-filled" color="#0cc8fa"></uni-icons>
        <text class="title">群公告</text>
      </view>
DCloud_JSON's avatar
DCloud_JSON 已提交
8
	  <textMsg :msg="{body:notification.content}"></textMsg>
DCloud_JSON's avatar
DCloud_JSON 已提交
9 10 11 12 13 14 15
      <text class="create_time">公告时间:{{friendlyTime}}</text>
    </view>
  </view>
</template>

<script>
  import uniIm from '@/uni_modules/uni-im/sdk/index.js';
DCloud_JSON's avatar
DCloud_JSON 已提交
16
  import textMsg from '@/uni_modules/uni-im/components/uni-im-msg/types/text.vue';
DCloud_JSON's avatar
DCloud_JSON 已提交
17
  export default {
DCloud_JSON's avatar
DCloud_JSON 已提交
18 19 20
	components:{
		textMsg
	},
DCloud_JSON's avatar
DCloud_JSON 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
    data() {
      return {
        notification:{
          content:"",
          create_time:0
        }
      }
    },
    props: {
      content:{
        type: String,
        default:""
      },
      create_time:{
        type: Number,
        default:0
      }
    },
    mounted() {
      this.notification.content = this.content
      this.notification.create_time = this.create_time
    },
    computed: {
      friendlyTime() {
DCloud_JSON's avatar
DCloud_JSON 已提交
45
        return uniIm.utils.toFriendlyTime(this.notification.create_time + uniIm.heartbeat * 0)
DCloud_JSON's avatar
DCloud_JSON 已提交
46 47 48 49 50 51 52
      }
    }
  }
</script>

<style lang="scss">
  .system-msg-box{
DCloud_JSON's avatar
3.4.31  
DCloud_JSON 已提交
53
    margin: 0 30px;
DCloud_JSON's avatar
DCloud_JSON 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66
  }
  .hidden {
    height: 0;
  }
  .system-msg {
    background-color: #f2f2f2;
    color: #9d9e9d;
    font-size: 14px;
    line-height: 30px;
    padding: 0 15rpx;
    border-radius: 8px;
  }
  .group-notification {
DCloud_JSON's avatar
DCloud_JSON 已提交
67
    padding:14px 0;
DCloud_JSON's avatar
DCloud_JSON 已提交
68 69 70 71 72 73 74 75 76
    background-color: #FFFFFF;
    margin-top: 10px;
  }
  .group-notification .title-box{
    flex-direction: row;
  }
  .group-notification .title-box .title{
    padding-left: 5px;
    color: #888;
77
    font-size: 18px;
DCloud_JSON's avatar
DCloud_JSON 已提交
78
  }
DCloud_JSON's avatar
DCloud_JSON 已提交
79 80 81 82
  .title-box,.create_time {
    color: #888;
    font-size: 14px;
    padding-left: 15px;
DCloud_JSON's avatar
DCloud_JSON 已提交
83 84
  }
</style>