livedIsMsg.vue 2.89 KB
Newer Older
李嘉林 committed
1 2
<template>
  <!-- 评论模块 -->
李嘉林 committed
3
  <div class="livedIsMsg" v-if="list.length>0" :class="{'livedIsMsgFixed':isSend}" :style="{'bottom':isSend?(fixedHeight+50)+'px':''}">
李嘉林 committed
4
    <div class="list">
李嘉林 committed
5
      <scroll-view :style="{'height': '24vh','width':'52vw'}" :scroll-y="true" :scroll-top="scrollTop" :scroll-with-animation="true"  @scrolltolower="scrolltolower">
李嘉林 committed
6 7 8 9
        <div class="item flex" v-for="(item,index) in list" :key="index">
          <div class="user">
            <p class="live"></p>
            <div class="name">
程智春 committed
10
              <span>{{item.customerName}}</span><span class="test">{{item.guestbookContent}}</span>
李嘉林 committed
11 12 13 14 15 16 17 18 19
            </div>
          </div>
        </div>
      </scroll-view>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
程智春 committed
20
import liveApi from "@/api/live";
李嘉林 committed
21
export default {
程智春 committed
22
  props:["guestBookList","updateVal","isSend","fixedHeight","liveId","info"],
李嘉林 committed
23 24 25
  name: "",
  data() {
    return {
李嘉林 committed
26
      list: [],
李嘉林 committed
27 28 29
      scrollTop:0,
    };
  },
李嘉林 committed
30 31
  watch:{
    updateVal(){
程智春 committed
32
     if(!this.info.playbackUrl || this.info.liveBroadcastState == 1 || this.info.liveBroadcastState == 3){
程智春 committed
33 34 35 36 37
       console.log('2222222222222')
        this.list=[...this.list,...this.guestBookList];
        this.scrollTop=this.list.length*1000;
     }
     
李嘉林 committed
38 39
    }
  },
李嘉林 committed
40 41 42 43
  components: {},
  computed: {},
  created() {},
  onLoad(){
程智春 committed
44
    if(this.info.playbackUrl && this.info.playbackUrl[0] && (this.info.liveBroadcastState != 1 || this.info.liveBroadcastState != 3)){
程智春 committed
45 46 47
      this.init()
    }
    
李嘉林 committed
48 49 50 51 52
  },
  mounted() {},
  methods: {
    scrolltolower(){
      
程智春 committed
53 54 55 56 57 58 59 60
    },
    init(){
      let query = {
        id : this.liveId,
        userActivebeginTime : 1,
        beginTime : 1
      }
      liveApi.queryPlaybackComments(query).then(res => {
程智春 committed
61 62 63 64
        if(res.data.code == '200'){
          this.list= res.data.data.guestBookList.slice(-100);
          this.scrollTop=this.list.length*1000;
        }
程智春 committed
65
      })
李嘉林 committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    }
  }
};
</script>

<style lang="scss" scoped>
/* 一行否则出现省略号 */
.line-clamp1 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.livedIsMsg {
  margin-left: 12px;
  padding: 8px;
  margin-bottom: 10px;
  position: relative;
李嘉林 committed
85
  width: 60vw;
李嘉林 committed
86
  .list {
程智春 committed
87
    width: 50vw;
李嘉林 committed
88 89
    overflow: hidden;
    bottom: 0;
程智春 committed
90
    padding-left: 10px;
程智春 committed
91
    border-radius: 9px;
李嘉林 committed
92
    .item {
程智春 committed
93 94 95
      width: 50vw;
      border-radius: 9px;
      margin-bottom: 4px;
李嘉林 committed
96
      .user {
程智春 committed
97 98 99 100 101 102 103
        max-width: 50vw;
        padding: 4px 8px;
        display: inline-block;
        line-height: 18px;
        border-radius: 9px;
        background-color: rgba(0,0,0,0.3);
        box-sizing: border-box;
李嘉林 committed
104 105 106 107 108 109 110 111 112 113 114 115 116
        .name {
          color: #f9a93c;
          font-size: 14px;
        }
      }
      .test {
        font-size: 14px;
        color: #f1f1f1;
        word-break: break-all;
      }
    }
  }
}
李嘉林 committed
117 118 119 120 121
.livedIsMsgFixed{
  position: absolute;
  margin: 0;
  left: 12px;
}
李嘉林 committed
122
</style>