<template>
  <div style="">
   <!-- 最新 -->
    <div class="case-box"  v-for="(item, idx) in items" :key="idx">
       <div class="coures-head">
          <div class="share-name" v-if="type=='myShare'">
          分享给了<span>{{ item.toAname }}</span>
        </div>
        <div v-else class="share-name">
          <span>{{ item.toAname }}</span>分享给了我
        </div>
        <div class="islook" v-if="item.isRead">已查看</div>
        <div class="isunlook" v-else>未查看</div>
        <div class="share-time">{{ item.time }}</div>
      </div>
      <div class="coures-content">
          <div style="width: 100%;">【案例】{{item.title}}</div>
          <div v-if="!item.isRead&&type=='myShare'" @click.stop="deleteshares(item)" style="color: #999999;font-size: 12px;font-weight: normal;width: 50px;">
            <svg-icon icon-class="withdraw" style="margin-right: 5px;font-size: 14px;" ></svg-icon>
            撤回</div>
      </div>

    </div>
    <!-- 旧版 -->
    <!-- <div class="article-list" v-for="(item, idx) in items" :key="idx">
      <div class="article-info" @click="jumpRouter(item)">
        <div class="article-info-title">
          <span v-if="item.isRead" class="readed">【已查看】</span>
          <span v-else class="noRead" >【未查看】</span>
          <span class="title one-line-ellipsis" v-html="$keywordActiveShow(item.cases.title,keyword)"></span>
    
        </div>
        <div v-html="$keywordActiveShow(item.cases.summary,keyword)" class="article-info-summary two-line-ellipsis">
        </div>
        <div style="display:flex;justify-content: space-between;">
          <div class="article-info-tools">
          <authorInfo :avatar="item.avatar" :name="item.name" :info="item.orgInfo"></authorInfo>
          <span style="color: #999999;">{{ item.time }}</span>
          <span v-if="type=='myShare'" style="color: #999999;font-size: 14px;">分享给{{item.toAname}}</span>
          <span v-else>{{item.sysCreateBy}}分享给我</span>
          <interactBar ref="shareDialog" :type="0" :data="item" :shares="false" :views="false"></interactBar>
        </div>
        <div>
          <el-button style="color: #8590A6;" v-if="!item.isRead&&type=='myShare'" type="text" icon="el-icon-refresh-right" @click.stop="deleteshares(item)">撤回</el-button>
        </div>
        </div>
      </div>
    </div> -->
  </div>
</template>
<script>
import apiShares from '@/api/modules/shares.js';
export default {
    name:'caseItems',
    props:{
      items: {
      //name,
      type: Array,
      default: () => []
    },
    type:{
      type:String,
      default:()=>{
        return 'myShare'
      }
    },
     keyword:{
      type:String,
      default:()=>{
        return ''
      }
    }
    },
     methods:{
       jumpRouter(item){
         if(item.type){
           if(this.type!='myShare'){
        apiShares.updateIsRead(item.shareId).then(res=>{
          if(res.status==200){
            this.$emit('confirm',item)
          }else{
             this.$message({
            type: 'error',
            message: res.message,
          });
          }
        })
      }
         }else{
            if(this.type!='myShare'){
        apiShares.updateIsRead(item.id).then(res=>{
          if(res.status==200){
            this.$emit('confirm',item)
          }else{
             this.$message({
            type: 'error',
            message: res.message,
          });
          }
        })
      }
         }
         console.log(item)
      
      this.$router.push({path:'/case/detail',query:{id:item.cases.id}})
     // window.open(`${this.webBaseUrl}/article/detail?id=${item.objId}`)
    },
      deleteshares(item){
      this.$emit('confirm',item)
    },
    },
    created() {
    },
   
}
</script>
<style lang="scss" scoped>
.case-box{
  width: 100%;
  padding: 30px 0;
  border-bottom:1px solid #e9e9e9 ;
  .coures-content{
    margin-top: 20px;
    font-size: 16px;
    color: #333333;
    font-weight: 600;
    word-break:break-all;
    display: flex;
    justify-content: space-between;
    span{
    font-size: 16px;
    margin-left: -9px;
    }
  }
  .coures-head{
    display: flex;
    .share-name{
      font-size: 14px;
      color: #666666;
      margin-right: 17px;
    }
    .share-time{
      font-size: 14px;
      color: #666666;
      line-height: 25px;
      margin-left: auto;
    }
    .islook{
      width: 46px;
      height: 24px;
      background: #eee;
      font-size: 12px;
      color: #666666;
      line-height: 24px;
      text-align: center;
      border-radius: 2px;
    }
    .isunlook{
      width: 46px;
      height: 24px;
      background: #FF6562;
      border-radius: 2px;
      font-size: 12px;
      color: #fff;
      line-height: 24px;
      text-align: center;

    }

  }
}
.article-status1 {
  padding: 3px;
  border: 1px dotted #1ea0fa;
  color: #1ea0fa;
}
.article-status2 {
  padding: 3px;
  border: 1px dotted #00aa00;
  color: #00aa00;
}
.article-status3 {
  padding: 3px;
  border: 1px dotted #ff0000;
  color: #ff0000;
}
.article-list {
  border-bottom: 1px solid #dddddd;
  // padding: 10px;
  padding-bottom: 20px;
  margin-top: 20px;
  border-bottom: 1px solid #e9e9e9;
  cursor: pointer;
}

.article-info {
  cursor: pointer;
  .article-info-title {
    font-size: 16px;
    font-weight: 400;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .readed{
      font-size: 18px;
      color: #3e7fff;
      // margin-bottom: 6px;
    }
    .noRead{
      font-size: 18px;
      color:#FF3E3E;
      // margin-bottom: 6px;
    }
    .title{
      line-height: 25px;
      margin-left: 10px;
      font-size: 18px;
      flex-shrink: 10000;
      font-weight: 500;
      color: #333333;
    }
    .el-button{
      margin-left: auto;
    }
    // .article-info-date {
    //   height: 40px;
    //   line-height: 40px;
    //   float: right;
    //   font-weight: 200;
    //   color: #999999;
    //   i {
    //     margin-right: 5px;
    //   }
    // }
  }
  .article-info-summary {
    height: 46px;
    font-weight: 200;
    font-size: 16px;
    line-height: 1.5;
    margin:7px 0;
  }
  .article-info-tools {
    color: #999999;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    >span{
      font-size: 14px;
       color: #747474;

      // margin-top: -2px;
    }
    // >span:first-of-type{
    //   margin-left: 10px;
    // }
    // >span:last-of-type{
    //   margin-top: -4px;
    //   margin-right:auto;
    // }
  }
}
</style>