<template>
  <div>
    <ul class="tab-box clearfix">
      <li class="fl" :class="{'active': index === 1}" @click="changeTab(1)">记录历史</li>
      <li class="fl" :class="{'active': index === 2}" @click="changeTab(2)">专家指导</li>
    </ul>

    <div v-if="index === 1 && recordList.length" class="log-list-box">
      <div
        v-for="(log, key) in recordList"
        :key="key"
        class="log-list">
        <div class="head clearfix">
          <img class="bg" src="../../assets/images/body-util/table_bg.png">
          <div class="age fr">{{log.babyAge}}</div>
          <div class="time fl">{{log.recordDate}}</div>
        </div>
        <ul class="val-box clearfix">
          <li class="fl">
            <div class="lable">身高</div>
            <div class="value"><span>{{log.height}}</span>厘米</div>
          </li>
          <li class="fl">
            <div class="lable">体重</div>
            <div class="value"><span>{{log.weight}}</span>公斤</div>
          </li>
          <li class="fl">
            <div class="lable">头围</div>
            <div class="value"><span>{{log.head}}</span>厘米</div>
          </li>
          <li class="fl">
            <div class="lable">BMI</div>
            <div class="value"><span>{{log.bmi || '--'}}</span></div>
          </li>
        </ul>
        <div class="result">{{log.msg || '--'}}</div>
      </div>
    </div>

    <div v-if="index === 2 && guideList.length" class="guide-list-box">
      <div
        v-for="(guide, key) in guideList"
        :key="key"
        class="guide-list clearfix">
          <div class="title">{{guide.title}}</div>
          <div class="content" :class="{'active': guide.isShow}">
            <label v-for="(content, index) in guide.content" :key="index">{{index + 1}}、{{content}}<br /></label>
          </div>
          <div class="tips" v-if="guide.content[0].length > 34" @click="guide.isShow = !guide.isShow ">{{guide.isShow ? '收起' : '展开'}}</div>
      </div>
    </div>

    <div v-if="(index === 1 && !recordList.length) || (index === 2 && !guideList.length)" class="none-data">
      <img class="img" src="../../assets/images/body-util/none_log.png">
      <div class="tips">{{index === 1 ? '暂无历史记录' : '暂无专家指导'}}</div>
    </div>
  </div>
</template>

<script>
export default {
  computed: {

  },
  props: ['tabIndex', 'recordList', 'guideList'],
  watch: {
    tabIndex (val) {
      this.index = val
    }
  },
  data () {
    return {
      index: 1
    }
  },
  methods: {
    // 切换 tab
    changeTab (index) {
      this.index = index
      this.$emit('changeTab', index)
    }
  }
}
</script>

<style scoped lang="less">
@import '~@/assets/less/common.less';
.tab-box{
  margin: 0 12px 10px;
  li{
    margin-right: 24px;
    padding: 0 0 10px;
    line-height: 18px;
    font-size: 15px;
    font-weight: 500;
    color: #999999;
    &.active{
      position: relative;
      font-size: 18px;
      color: @themeColor;
      &::after{
        content: '';
        position: absolute;
        left: 50%;
        bottom: 0;
        transform: translate(-50%, 0);
        width: 20px;
        height: 2px;
        background: @themeColor;
      }
    }
  }
}
.none-data{
  margin: 74px auto 0;
  .img{
    margin: 0 auto @spacing;
    width: 114px;
    height: 114px;
  }
  .tips{
    line-height: 20px;
    text-align: center;
    color: #CCCCCC;
  }
}
.log-list-box{
  .log-list{
    margin: 0 0 @spacing;
    border: solid 1px #FFAEB8;
    border-radius: 2px;
    .head{
      position: relative;
      padding: 0 10px;
      height: 30px;
      line-height: 30px;
      font-size: 11px;
      font-weight: 500;
      color: @themeColor;
      .bg{
        z-index: -1;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
    }
    .val-box{
      li{
        position: relative;
        padding: 10px 0;
        width: 25%;
        text-align: center;
        box-sizing: border-box;
        &::after{
          content: '';
          position: absolute;
          right: 0;
          top: 50%;
          transform: translate(0, -50%);
          width: 1px;
          height: 25px;
          background: #D8D8D8;
        }
        &:last-child::after{
          opacity: 0;
        }
        .lable{
          margin: 0 0 5px;
          line-height: 14px;
          font-size: 10px;
          color: #A4A4A4;
        }
        .value{
          line-height: 25px;
          font-size: 12px;
          font-weight: 500;
          color: #000000;
          span{
            font-size: 18px;
          }
        }
      }
    }
    .result{
      margin: 0 10px;
      padding: 10px 0;
      line-height: 16px;
      border-top: solid 1px #FFAEB8;
      font-size: 10px;
      text-align: center;
      color: #8C8C8C;
    }
  }
}
.guide-list-box{
  .guide-list{
    padding: 10px 0;
    border-bottom: solid 1px #DDDDDD;
    &:last-child{
      border: 0 none;
    }
    .title{
      margin-bottom: 5px;
      line-height: 16px;
      font-size: 13px;
      font-weight: 500;
    }
    .content{
      max-height: 28px;
      line-height: 14px;
      font-size: 10px;
      color: #999999;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      transition: max-height .4s;
      &.active{
        max-height: 1000px;
        -webkit-line-clamp: unset;
      }
    }
    .tips{
      line-height: 14px;
      font-size: 10px;
      text-align: right;
      color: @themeColor;
    }
  }
}
</style>
