<template>
  <div class="page">
    <div class="page-title">专业美容培训师</div>
    <div class="page-top">
      <div class="swiper">
        <SimpleSwiper :imageList="doctorInfo.bannerList"></SimpleSwiper>
      </div>
    </div>
    <div class="page-content">
      <div class="doctor-info">
        <div class="name">{{ doctorInfo.doctorName }}</div>
        <div class="tag">{{ doctorInfo.tagList.join(' | ') }}</div>
      </div>
      <div class="param-list">
        <div
          class="param"
          v-for="(param, index) in doctorInfo.paramList"
          :key="index"
        >
          <div class="name" v-text="param.name"></div>
          <div class="content" v-text="param.content"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  layout: 'app-ldm',
  data() {
    return {
      doctorInfo: {
        tagList: [],
        paramList: [],
      },
    }
  },
  mounted() {
    this.initData()
  },
  methods: {
    initData() {
      const doctorInfo = localStorage.getItem('doctorInfo')
      if (doctorInfo) {
        this.doctorInfo = JSON.parse(doctorInfo)
        this.fetchDetail()
      }
    },
    async fetchDetail() {
      try {
        const res = await this.$http.api.fetchDoctorDetail({
          doctorId: this.doctorInfo.doctorId,
        })
        this.doctorInfo = { ...this.clubInfo, ...res.data }
      } catch (error) {
        console.log(error)
      }
      if (this.doctorInfo.bannerList.length <= 0) {
        this.doctorInfo.bannerList.push('/placeholder.png')
      }
    },
  },
}
</script>

<style scoped lang="scss">
@media screen and (min-width: 768px) {
  .page {
    position: relative;
    display: flex;
    justify-content: space-between;
    width: 1016px;
    margin: 0 auto;
    padding-top: 117px;
  }

  .page-title {
    position: absolute;
    left: 0;
    top: 60px;
    font-size: 26px;
    color: #221815;
  }
  .page-top {
    .swiper {
      width: 452px;
      height: 452px;
      background-color: pink;
    }
  }

  .page-content {
    width: 503px;
    .doctor-info {
      padding-bottom: 35px;
      .name {
        font-size: 35px;
        font-weight: bold;
        color: #000;
        margin-bottom: 22px;

        &::after {
          content: '';
          display: inline-block;
          margin-left: 12px;
          width: 36px;
          height: 42px;
          background: url(https://static.caimei365.com/www/authentic/pc/ldm-icon-badge.png)
            no-repeat center;
          background-size: 36px 42px;
          vertical-align: -8px;
        }
      }
      .tag {
        font-size: 16px;
        color: #221815;
      }
    }

    .param-list {
      .param {
        padding: 32px 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.3);

        &:first-child {
          border-top: 1px solid rgba(0, 0, 0, 0.3);
        }

        .name {
          font-size: 18px;
          font-weight: bold;
          color: #000;
        }
        .content {
          font-size: 16px;
          color: #9c9c9c;
          margin-top: 12px;
          text-align: justify;
          line-height: 1.7;
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .page-title {
    display: none;
  }

  .page-top {
    .swiper {
      width: 100vw;
      height: 100vw;
      background-color: pink;
    }
  }

  .page-content {
    padding: 4.7vw 6.2vw;
    .doctor-info {
      padding-bottom: 6vw;
      .name {
        font-size: 6.2vw;
        font-weight: bold;
        color: #000;
        margin-bottom: 3.2vw;

        &::after {
          content: '';
          display: inline-block;
          margin-left: 1.8vw;
          width: 6.5vw;
          height: 7.6vw;
          background: url(https://static.caimei365.com/www/authentic/h5/ldm-icon-badge.png)
            no-repeat center;
          background-size: 6.4vw 7.6vw;
          vertical-align: -1.4vw;
        }
      }
      .tag {
        font-size: 3vw;
        color: #221815;
      }
    }

    .param-list {
      .param {
        padding: 6vw 0;
        border-bottom: 0.1vw solid rgba(0, 0, 0, 0.3);

        &:first-child {
          border-top: 0.1vw solid rgba(0, 0, 0, 0.3);
        }

        .name {
          font-size: 3.2vw;
          font-weight: bold;
          color: #000;
        }
        .content {
          font-size: 3vw;
          color: #9c9c9c;
          margin-top: 1.6vw;
          text-align: justify;
          line-height: 1.7;
        }
      }
    }
  }
}
</style>
