<template>
  <div class="page md:flex md:justify-between">
    <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 px-4 pt-4 md:pt-0">
        <div class="name pb-4">{{ doctorInfo.doctorName }}</div>
        <div class="tag pb-1">{{ doctorInfo.tagList.join(' | ') }}</div>
        <div class="code pb-1">
          从业资格证编号：{{ doctorInfo.certificateNo }}
        </div>
        <div class="club-name">所在机构：{{ doctorInfo.clubName }}</div>
      </div>
      <div class="section param-list pb-4">
        <div
          class="param px-4 pt-4"
          v-for="(param, index) in doctorInfo.paramList"
          :key="index"
        >
          <div class="name py-2" v-text="param.name"></div>
          <div class="content" v-text="param.content"></div>
        </div>
      </div>
      <div class="divider"></div>
      <div class="device-list p-4">
        <div class="title">具备操作资格设备</div>
        <div class="list">
          <div
            class="device flex items-center py-4"
            v-for="item in doctorInfo.equipmentList"
            :key="item.productId"
          >
            <img class="cover" :src="item.image" />
            <div class="info">
              <div class="name" v-text="item.equipmentName"></div>
              <div class="brand mt-2">品牌：{{ item.brand }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  layout: 'app',
  data() {
    return {
      doctorId: '',
      doctorInfo: {
        tagList: [],
        paramList: [],
      },
    }
  },
  mounted() {
    this.initData()
  },
  methods: {
    initData() {
      this.doctorId = parseInt(this.$route.query.id)
      this.fetchDetail()
    },
    async fetchDetail() {
      try {
        const res = await this.$http.api.fetchDoctorDetail({
          doctorId: this.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">
// pc 端
@media screen and (min-width: 768px) {
  .page {
    position: relative;
    width: 1200px;
    height: 612px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 80px;
    background-color: #fff;
    box-sizing: border-box;
    padding: 16px;
    padding-right: 0;
  }

  .page-title {
    position: absolute;
    font-size: 24px;
    color: #333;
    top: -50px;
    left: 0;
  }

  .page-top {
    .swiper {
      width: 580px;
      height: 580px;

      background: #f7f7f7;
      ::v-deep {
        img {
          width: 580px;
          height: 580px;
        }
      }
    }
  }
  .page-content {
    width: 580px;
    padding: 0 24px;
    overflow-y: auto;
    .doctor-info {
      line-height: 1.6;
      .name {
        font-size: 24px;
        color: #101010;
        font-weight: bold;

        &::after {
          content: '';
          display: inline-block;
          width: 76px;
          height: 28px;
          @include themify($themes) {
            background: themed('icon-doctor-level-pc') no-repeat;
          }
          background-size: 76px 28px;
          vertical-align: -5px;
          margin-left: 8px;
        }
      }
      .tag {
        font-size: 14px;
        color: #909399;
      }
      .code,
      .club-name {
        font-size: 14px;
        color: #404040;
      }
    }

    .param-list {
      .param {
        .name {
          font-size: 18px;
          color: #101010;
          font-weight: bold;
        }
        .content {
          font-size: 14px;
          color: #404040;
          line-height: 1.6;
          text-align: justify;
        }
      }
    }

    .device-list {
      .title {
        padding: 16px;
        font-size: 20px;
        font-weight: bold;
        color: #404040;
        background-color: #f3f5f6;
      }
      .list {
        display: flex;
        align-items: center;
        flex-direction: column;
        .device {
          width: 100%;
          box-sizing: border-box;
          border-bottom: 1px solid #d8d8d8;
          .cover {
            width: 84px;
            height: 84px;
            display: block;
          }
          .info {
            margin-left: 16px;
            width: 300px;
            .name {
              font-size: 18px;
              color: #101010;
              text-overflow: ellipsis;
              overflow: hidden;
              white-space: nowrap;
            }
            .brand {
              font-size: 14px;
              color: #666666;
              text-overflow: ellipsis;
              overflow: hidden;
              white-space: nowrap;
            }
          }
        }
      }
    }
  }
}

// 移动 端
@media screen and (max-width: 768px) {
  .page-title {
    display: none;
  }
  .page-top {
    .swiper {
      height: 100vw;

      background: #f7f7f7;
      ::v-deep {
        img {
          height: 100vw;
        }
      }
    }
  }
  .page-content {
    .divider {
      height: 3.2vw;
      background-color: #f7f7f7;
    }
    .doctor-info {
      line-height: 1.6;
      .name {
        font-size: 5vw;
        color: #101010;
        font-weight: bold;

        &::after {
          content: '';
          display: inline-block;
          width: 13.6vw;
          height: 5vw;
          @include themify($themes) {
            background: themed('icon-doctor-level-h5') no-repeat;
          }
          background-size: 13.6vw 5vw;
          vertical-align: -0.8vw;
          margin-left: 1.2vw;
        }
      }
      .tag {
        font-size: 3vw;
        color: #909399;
      }
      .code,
      .club-name {
        font-size: 3.2vw;
        color: #404040;
      }
    }

    .param-list {
      .param {
        .name {
          font-size: 3.8vw;
          color: #101010;
          font-weight: bold;
        }
        .content {
          font-size: 3.2vw;
          color: #404040;
          line-height: 1.6;
          text-align: justify;
        }
      }
    }

    .device-list {
      .title {
        font-size: 4vw;
        color: #101010;
        font-weight: bold;
      }
      .list {
        display: flex;
        align-items: center;
        flex-direction: column;
        .device {
          width: 100%;
          box-sizing: border-box;
          border-bottom: 0.1vw solid #d8d8d8;
          .cover {
            width: 19.6vw;
            height: 19.6vw;
            display: block;
          }
          .info {
            margin-left: 3.2vw;
            width: 66vw;
            .name {
              font-size: 3.6vw;
              color: #101010;
              text-overflow: ellipsis;
              overflow: hidden;
              white-space: nowrap;
            }
            .brand {
              font-size: 3vw;
              color: #666666;
              text-overflow: ellipsis;
              overflow: hidden;
              white-space: nowrap;
            }
          }
        }
      }
    }
  }
}
</style>
