<template>
  <div class="club-detail page">
    <div class="page-top"></div>
    <div class="page-content">
      <div class="title">设备认证信息</div>
      <div class="row">
        <div class="col label">设备名称：</div>
        <div class="col content">{{ productInfo.productName }}</div>
      </div>
      <div class="row block">
        <div class="col label">设备图片：</div>
        <div class="col content">
          <el-image
            v-if="productInfo.productImage"
            :src="productInfo.productImage"
            :preview-src-list="[productInfo.productImage]"
          ></el-image>
          <span v-else>暂无图片</span>
        </div>
      </div>
      <div class="row">
        <div class="col label">所属品牌：</div>
        <div class="col content">{{ productInfo.brandName }}</div>
      </div>
      <div class="row">
        <div class="col label">购买渠道：</div>
        <div class="col content">{{ productInfo.purchaseWay || '暂无' }}</div>
      </div>
      <div class="row block">
        <div class="col label">发票：</div>
        <div class="col content">
          <el-image
            v-if="productInfo.invoiceImage"
            :src="productInfo.invoiceImage"
            :preview-src-list="[productInfo.invoiceImage]"
          ></el-image>
          <span v-else>暂无图片</span>
        </div>
      </div>
      <div class="row">
        <div class="col label">设备SN码：</div>
        <div class="col content">{{ productInfo.snCode }}</div>
      </div>
      <div class="row">
        <div class="col label">设备参数：</div>
        <div class="col content params-list">
          <div
            class="param"
            v-for="param in productInfo.paramList"
            :key="param.productName"
          >
            <div class="param-name">{{ param.paramName }}</div>
            <div class="param-content">{{ param.paramContent }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  layout: 'app-ross',
  data() {
    return {
      productInfo: {},
    }
  },
  created() {
    this.initData()
  },
  methods: {
    initData() {
      this.productId = this.$route.query.id
      this.relationId = this.$route.query.relationId
      this.getProductDetails()
    },
    // 获取认证机构信息
    async getProductDetails() {
      try {
        const res = await this.$http.api.getProductDetails({
          productId: this.productId,
          relationId: this.relationId,
        })
        this.productInfo = { ...this.productInfo, ...res.data }
        console.log('res', this.productInfo)
      } catch (error) {
        console.log(error)
      }
    },
  },
}
</script>

<style lang="scss" scoped>
@media screen and (min-width: 768px) {
  .page {
    display: flex;
    justify-content: center;
  }

  .page-content {
    max-width: 760px;
    padding-bottom: 167px;
    .title {
      font-size: 24px;
      color: #282828;
      font-weight: bold;
      text-align: center;
      padding: 60px 0;
    }

    .row {
      display: flex;
      align-items: flex-start;
      margin: 32px 0;

      .col {
        font-size: 16px;
      }
      .label {
        color: #666666;
        min-width: 100px;
      }
      .content {
        color: #282828;

        .el-image {
          width: 106px;
          height: 106px;
          border: 1px solid #dcdcdc;
          margin-right: 4px;

          &:last-child {
            margin-right: 0;
          }
        }

        &.params-list {
          width: 100%;
          margin-top: -10px;
          .param {
            display: table-row;
            width: 100%;
          }

          .param-name,
          .param-content {
            display: table-cell;
            font-size: 16px;
            padding: 12px 0;

            &:nth-child(2n-1) {
              color: #999999;
              white-space: nowrap;
            }

            &:nth-child(2n) {
              color: #282828;
              padding-left: 12px;
            }

            &:nth-child(3) {
              padding-left: 100px;
            }
          }
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .page-content {
    padding: 0 7.2vw;
    .title {
      font-size: 4.6vw;
      color: #282828;
      font-weight: bold;
      text-align: center;
      padding: 8vw 0;
    }

    .row {
      display: flex;
      align-items: flex-start;
      margin-bottom: 5.6vw;

      &.block {
        display: block;
        .label {
          margin-bottom: 2.4vw;
        }
      }

      .col {
        font-size: 3.4vw;
      }
      .label {
        color: #666666;
        min-width: 20.4vw;
      }
      .content {
        color: #282828;

        .el-image {
          width: 26vw;
          height: 26vw;
          border: 0.1vw solid #dcdcdc;
          margin-right: 0.6vw;

          &:last-child {
            margin-right: 0;
          }
        }

        &.params-list {
          width: 100%;
          margin-top: -1vw;
          .param {
            display: table-row;
            width: 100%;
          }

          .param-name,
          .param-content {
            display: table-cell;
            font-size: 3.4vw;
            padding: 1.2vw 0;

            &:nth-child(2n-1) {
              color: #999999;
              white-space: nowrap;
            }

            &:nth-child(2n) {
              color: #282828;
              padding-left: 1.2vw;
            }

            &:nth-child(3) {
              padding-left: 100px;
            }
          }
        }
      }
    }
  }
}
</style>
