<template>
  <div class='mu-card reward-card' @click="handlerOutClick" :class='colorTheme'>
    <div class="main">
      <div class="reward-aui-media-list-item-inner">
        <div class="reward-aui-list-item-media" v-if="isAvatar">
          <mu-avatar  :isimg="avatarObj && avatarObj.isImg" :avatarcolor="avatarObj && avatarObj.color" :avatarname="avatarObj && avatarObj.aName" :avatarurl="avatarObj && avatarObj.aUrl"
            size=40  @click='handleAvatarClick($event)'></mu-avatar>
        </div>
        <div :class="['reward-aui-list-item-inner', {'item-inner-noline': !hasline}]" @click='handleListClick'>
          <div class="aui-list-item-text">
            <div class="aui-list-item-title-container">
              <div class="aui-list-item-title-name aui-list-item-firsttitle attach-overflow" v-if="title">{{title}}&nbsp;</div>
              <div class="aui-list-item-title-name aui-list-item-subtitle attach-overflow" v-if="subTitle">{{subTitle}}</div>
              <div class="aui-list-item-title-name aui-list-item-thirdtitle attach-overflow" v-if="thirdTitle">&nbsp;{{thirdTitle}}</div>
            </div>
            <div v-text="TitleRightText" :class="['aui-list-item-right',{'title-right-bg-suc':titleRightTextHasBg && titleRightState=='suc'}, {'title-right-bg-over':titleRightTextHasBg && titleRightState=='over'},{'title-right-bg-never':titleRightTextHasBg && titleRightState=='never'},'aui-reward-list-item-right']">
            </div>
          </div>
          <div :class="['mu-main-reward', {'mu-main-reward-line':hasline}]" v-if="hasline" ref="main">
              {{content}}
          </div>
           <div v-if="isFooter" :class="['attach-reward', {'attach-reward-has-line': hasline}]">
              <div :class="['attach-reward-title', {'attach-reward-title-noline': !hasline}]">
                  <span class="attach-reward-title-username" ref='rewardName'>{{rewardName}}：</span>
                  <span :class="[{'attach-reward-title-message-hasright': footerRightText},'attach-reward-title-message']" ref="rewardContent">{{rewardContent}}</span>
                  <span v-if="footerRightText" :class="['attach-reward-title-right',{'title-right-bg-suc': footerRightState=='suc'}, {'title-right-bg-over': footerRightState=='over'},{'title-right-bg-never': footerRightState=='never'},'aui-reward-list-item-right']">
                    {{footerRightText}}
                  </span>
                  <span v-if="isRightArrow" class="right-arrow m-sys-forward"></span>
              </div>
           </div>
        </div>

      </div>
    </div>

  </div>
</template>
<script>
import avatar from '../avatar';
import abstractButton from '../internal/abstractButton';
export default {
  name: 'mu-card-reward',
  props: {
    //标题
    title: {
      type: String,
    },
    subTitle:{
      type: String,
    },
    thirdTitle:{
      type: String,
    },
    content:{
      type: String,
    },
    colorTheme:{
      type: String,
    },
    avatarObj:{
      type: Object,
    },
    key:{
      type:String
    },
    isAvatar:{
      type: Boolean,
      default: true
    },
    isFooter:{
      type: Boolean,
      default: true
    },
    isRightArrow:{
      type: Boolean,
      default: true
    },
    rewardName:{
      type:String
    },
    rewardContent:{
      type:String
    },
    TitleRightText:{
      type: String,
    },
    titleRightTextHasBg:{
      type: Boolean,
      default: false
    },
    titleRightState:{
      type: String
    },
    hasline:{
      type: Boolean,
      default: true
    },
    footerRightText:{
      type: String
    },
    footerRightState:{
      type: String
    },
  },
  mounted: function() {
    var rewardName = this.$refs.rewardName;
    var rewardContent = this.$refs.rewardContent;
    rewardContent.style.left = rewardName.offsetWidth + 'px';
  },
  computed: {

  },
  methods:{
    handlerOutClick (e) {
      this.$emit('handle-click', e);
    },
    handleAvatarClick(e) {
       e.stopPropagation();
       this.$emit('handle-avatar-click');
    },
    handleListClick() {
       this.$emit('handle-list-click');
    }
  },
  data(){
    return {
      isExpand: false,
      lineNum: 0
    };
  },
  components:{
    'mu-avatar': avatar,
    'abstract-button': abstractButton,
  },
};
</script>
<style lang="less">
.short{
  display: -webkit-box; //必须结合的属性 ，将对象作为弹性伸缩盒子模型显示 。
  text-overflow: ellipsis;//可以用来多行文本的情况下，用省略号“…”隐藏超出范围的文本 。
  overflow : hidden;
  //-webkit-line-clamp: 5;
  //-webkit-box-orient: vertical;  //必须结合的属性 ，设置或检索伸缩盒对象的子元素的排列方式 。
  max-height: 100px;
  line-height: 20px;
}
//主题
.reward-card .aui-list-item-title {
    color: #6B7175;
    line-height: 20px;
    font-size: 16px;
    display: inline-block;
}
.aui-list-item-title-name{
  color: #3A4247;
  font-size: 16px;
  line-height: 20px;
}
.aui-list-item-subtitle{
  color: #bfc4c7;
  line-height: 20px;
  font-size: 16px;
}
.aui-list-item-title-container{
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  position: absolute;
}
.replay {
  .aui-list-item-title{
    color: #ffc300;
  }
  &:after{
    content: " ";
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    bottom: 0;
    border-left: 4px solid #ffc300;
    color:#ffc300;
    transform-origin: 0 0;
    transform: scaleX(0.5);
  }
}
.atta_count_inner{
  height:30px;
  line-height:30px;
  font-family:PingFangSC-Regular;
  font-size:14px;
  color:#6b7175;
  margin-top:10px;
}
.mu-step-tag {
  background:#00e099;
  color:#fff;
  width:113px;
  text-align:center;
  position: absolute;
  right: -34px;
  top: 15px;
  padding:1px;
  transform:rotate(45deg);
}
.reward-card .mu-card-footer{
   flex-direction: row;
}
.reward-card .m-sys-remind_spread {
    top: -1px;
    color: #1695f0;
    font-size: 10px;
    position: relative;
}
.mu-card {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius:3px;
  overflow: hidden;
  /* autoprefixer: off */
  -webkit-box-orient: vertical;
  /* autoprefixer: on */
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  color: #212121;
  background-color: #fff;
  position: relative;
  min-height: 2.2rem;
  margin-bottom: 12px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
}
.mu-card-footer{
  position: relative;
  padding: 0.5rem 0;
  font-size: 0.7rem;
  height:30px;
  line-height:30px;
  color: #757575;
  background-color: rgba(0, 0, 0, 0);
  -webkit-box-sizing: border-box;
  flex-direction: row-reverse;
  box-sizing: border-box;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-top:12px;
  &:after {
    width: 100%;
    height: 1px;
    background-color:#e6e7e8;
    display: block;
    content: '';
    position: absolute;
    top: 0;
    right: auto;
    left: 0;
    z-index: 2;
    transform-origin: 0 0;
    pointer-events: none;
  }
}
.reward-aui-media-list-item-inner {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  width:100%;
}
.reward-aui-media-list-item-inner + .aui-info {
  margin-right: 0.75rem;
}
.aui-list-item-media-list {
  padding-right: 0;
  display: block;
}
.reward-aui-list-item-media{
  padding-top: 16px;
  padding-left: 12px;
}
.aui-list-item-right{
  font-size: 12px;
  text-align: center;;
  line-height: 22px;
  height: 22px;
  padding: 0 10px;
  border-radius: 10px;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  /* autoprefixer: off */
  -webkit-box-orient: vertical;
  /* autoprefixer: on */
  word-break:break-all
}

.mu-main-reward{
  width: 100%;
  font-size: 12px;
  color: #BFC4C7;
  line-height: 20px;
  margin-top: 27px;
  padding-bottom: 12px;
  position: relative;
  line-height: 12px;
}
.mu-main-reward-line::after{
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background-color: #E6E7E8;
  transform: scaleY(0.5);
  transform-origin: center top;
  z-index: 2;

}
.attach-reward{
  width: 100%;
  color: #9DA1A3;
  font-size: 14px;
  margin-top: 8px;
  margin-bottom: 14px;
}
.attach-reward-has-line{
  margin-bottom: 8px;
}
.attach-overflow{
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  /* autoprefixer: off */
  -webkit-box-orient: vertical;
  /* autoprefixer: on */
  word-break: break-all;
  white-space: nowrap;
}
.attach-reward-title{
  line-height: 18px;
  height: 16px;
  position: relative;
}
.attach-reward-title-noline{
  top: 22px;
}
.attach-reward-title-username{

}
.attach-reward-title-message{
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  /* autoprefixer: off */
  -webkit-box-orient: vertical;
  /* autoprefixer: on */
  position: absolute;
  top: 0;
  padding-right: 8px;
}
.attach-reward-title-message-hasright{
  padding-right: 80px !important;
}
.attach-reward-content{
  line-height: 16px;
  height: 16px;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  /* autoprefixer: off */
  -webkit-box-orient: vertical;
  /* autoprefixer: on */
}
.attach-reward-content-type{
  background: #94C8F7;
  color: #fff;
  font-size: 12px;
  height: 16px;
  padding: 0 2px;
}
.project-todo{
  min-width: 28px;
}
.reward-aui-list-item-inner{
  position: relative;
  //margin-left: 8px;
  margin-right: 12px;
  width: 100%;
  box-sizing: border-box;
  padding-top: 12px;
  padding-left: 10px;
}
.item-inner-noline{
  padding-bottom: 22px;
}
.title-right-bg-suc{
  color: #BFC4C7;
  background: #F3F4F5;
  font-size: 14px;
}
.title-right-bg-over{
  color: #FF9500;
  background: rgba(255,149,0,0.1);
  font-size: 14px;

}
.title-right-bg-never{
  color: #FF7360 !important;
  background: rgba(225,115,96,0.1);
  font-size: 14px;
}
.right-arrow{
  position: absolute;
  top: 0;
  right: 0;
  margin-top: 3px;
  font-size: 12px;
}
.aui-list-item-thirdtitle{
  max-width: 75px;
}
.aui-reward-list-item-right{
  line-height: 22px !important;
}
.attach-reward-title-right{
  position: absolute;
  right: 18px;
  top: -2px;
  display: inline-block;
  max-width: 33%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  /* autoprefixer: off */
  -webkit-box-orient: vertical;
  /* autoprefixer: on */
  font-size: 14px;
  text-align: center;
  line-height: 22px;
  height: 22px;
  padding: 0 10px;
  border-radius: 10px;
  word-break:break-all
}
@media (max-device-width:320px){
    .aui-list-item-right{
      max-width: 33%;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      /* autoprefixer: off */
      -webkit-box-orient: vertical;
      /* autoprefixer: on */
      word-break:break-all
    }
    .attach-overflow{
      max-width: 86px;
      overflow: hidden;
      text-overflow: ellipsis;
      word-break: break-all;
      white-space: nowrap;
    }
  }
</style>
