<template>
    <div class="answer-list">
        <ul v-if="list.length > 0">
            <li class="answer-list-index" v-for="item in list" :key="item.id">
                <p  class="portal-summary-text" style="margin-bottom:18px">
                    <span v-if="!personal || isFollow">{{item.aname}}</span>{{item.cusInfo}}<span style="margin-left:28px">{{item.eventTime}}</span>
                    <span v-if="item.aid == userInfo.aid" class="follow-hide pointer" style="float:right">
                        <span v-if="item.hidden">已隐藏</span>
                        <span v-else  @click="emitHide(item.id)">  <svg-icon style="margin-right: 10px;font-size:22px;padding-top: 4px;" icon-class="eyes"></svg-icon>隐藏 </span>
                    </span>
                </p>
                <h6 class="answer-title-info follow-home-title">
                   <span class="pointer" @click="jumpDetail(item)">{{item.contentInfo}}</span> 
                   <!-- <span class="follow-hide" style="float:right" v-if="!isDynamic && personal">
                          <span v-if="item.hidden">已隐藏</span>
                          <span v-else  @click="emitHide(item.id)">  <svg-icon style="margin-right: 10px;font-size:22px;padding-top: 4px;" icon-class="eyes"></svg-icon>隐藏 </span>
                    </span> -->
                </h6>
                <p class="answer-text">
                    {{displayAll(item)}}
                    <span style="color:#0B4D9D;cursor:pointer;" v-if="item.info.content && item.info.content.length>180" @click.stop="changeIsAll(item)">
                        {{item.isAll?'收起':'全文展开'}}
                    </span>
                </p>
                <div>
                    <interactBar :type="0" :data="item.info"  :shares="false" :views="false" :readonly="true"></interactBar>
                </div>
            </li>
        </ul>
        <!-- <div v-else class="home-no-list">
            <img class="img" :src="`${webBaseUrl}/images/homeWu/no-answer.png`" alt="" srcset="">
            <p v-if="isFollow" class="text">暂时没有动态</p>
            <p v-else class="text">还没有回答</p>
        </div> -->
    </div>
  </template>

  <script>
    import interactBar from "@/components/Portal/interactBar.vue";
    import author from "@/components/Portal/authorInfo.vue";
    import { mapGetters,mapActions } from 'vuex';
      export default{
        name:"answerList",
        components: {
          interactBar,
          // timeShow,
          author
        },
        props:{
            list:{
                type:Array,
                default:()=>[]
            },
            showHidden:{
              type:Boolean,
              default:true
            },
            isDynamic:{
                type:Boolean,
                default:false,
            },
            personal:{
                type:Boolean,
                default:false,
            },
            isFollow:{
                type:Boolean,
                default:false,
            }
        },
        computed: {
          ...mapGetters(['userInfo']),
        },
          data(){
              return{
                answerList:[]
              }
          },
      methods:{
        jumpDetail(item){
          if(item.deleted){
            this.$message.warning("此内容已删除");
            return;
          }
          this.$router.push('/qa/answer?id='+item.contentId)
        },
        emitHide(id) {
          this.$emit('hideIndex',id)
        },
        displayAll(item) {
          if (!item.isAll && item.info.content && item.info.content.length > 180) {
            return item.info.content.slice(0, 180) + "...";
          }
          return item.info.content;
        },
         //展示全部
         changeIsAll(item) {
          item.isAll = !item.isAll;
        },

       }
      }
  </script>

  <style lang="scss" scoped>
    .answer-list{
        ul{
            margin: 0;
        }
        .answer-list-index{
            padding: 30px 0;
            border-bottom: 1px solid rgba($color: #999999, $alpha: 0.2) !important;
            ::v-deep .interact-bar-btns{
                .interact-bar-btn{
                    text-align: right;
                    min-width: 78px !important;
                    margin-right: 0;
                }
            }
        }
        .answer-title-info{
            margin: 0;
            margin-bottom: 16px;
        }
        .answer-text{
            margin-bottom: 18px;
            font-size: 14px;
            word-break:break-all;
            color: #333330;
            line-height: 20px;
        }
    }
  </style>
