<template>
  <div class="page">
    <div class="page-top flex flex-col justify-center items-center">
      <img class="logo" :src="supplierInfo.logo" />
      <div class="name mt-2" v-text="supplierInfo.shopName + '认证记录'"></div>
    </div>
    <div class="page-content">
      <template v-if="true">
        <div class="page-title">机构认证</div>
        <div class="row">
          <div class="col">机构名称：</div>
          <div class="col">{{ clubInfo.authParty }}</div>
        </div>
        <div class="row">
          <div class="col">联系电话：</div>
          <div class="col">{{ clubInfo.mobile }}</div>
        </div>
        <div class="row">
          <div class="col">所在地区：</div>
          <div class="col">{{ clubInfo.area }}</div>
        </div>
        <div class="row">
          <div class="col">所在位置：</div>
          <div class="col">{{ clubInfo.address }}</div>
        </div>
        <div class="row">
          <div class="col max-width">logo：</div>
          <div class="col">
            <el-image
              :src="clubInfo.logo"
              :preview-src-list="[clubInfo.logo]"
            ></el-image>
          </div>
        </div>
        <div class="row">
          <div class="col max-width">门头照：</div>
          <div class="col">
            <template v-for="(image, index) in clubInfo.bannerList">
              <el-image
                :key="index"
                :src="image"
                :preview-src-list="clubInfo.bannerList"
              />
            </template>
          </div>
        </div>
        <div class="row">
          <div class="col">机构类型：</div>
          <div class="col">
            {{
              ['医美', '生美', '项目公司', '个人', '其他'][
                clubInfo.firstClubType - 1
              ]
            }}
          </div>
        </div>
        <div
          class="row"
          v-if="clubInfo.firstClubType === 1 || clubInfo.firstClubType === 2"
        >
          <div class="col">医美类型：</div>
          <div class="col">
            {{
              ['诊所', '门诊', '医院', '其他', '美容院', '养生馆', '其他'][
                clubInfo.secondClubType - 1
              ]
            }}
          </div>
        </div>
        <div class="row">
          <div class="col">员工人数：</div>
          <div class="col">{{ clubInfo.empNum }}</div>
        </div>
        <div class="row">
          <div class="col">状态：</div>
          <div class="col">
            <div>
              <span v-if="clubInfo.auditStatus === 1">认证成功</span>
              <span v-else-if="clubInfo.auditStatus === 2">认证中</span>
              <span v-else>认证失败</span>
            </div>
          </div>
        </div>

        <div class="control flex flex-col items-center">
          <div
            class="button edit flex justify-center items-center mb-2"
            @click="onEdit"
          >
            编辑
          </div>
          <div
            class="button search flex justify-center items-center"
            @click="onToDeviceList"
          >
            查看认证设备
          </div>
        </div>
      </template>
      <template v-else>
        <SimpleEmpty name="icon-club-empty.png" description="暂无机构认证~" />
      </template>
    </div>
  </div>
</template>

<script>
import SimpleEmpty from '@/components/SimpleEmpty'
import { mapGetters } from 'vuex'
export default {
  layout: 'app',
  components: {
    SimpleEmpty,
  },
  data() {
    return {
      clubInfo: {},
    }
  },
  computed: {
    ...mapGetters(['supplierInfo', 'routePrefix', 'clubUserId']),
  },
  created() {
    this.fetchAuthDetail()
  },
  methods: {
    // 获取认证机构信息
    async fetchAuthDetail() {
      try {
        const result = await this.$http.api.fetchClubAuthInfo({
          clubUserId: this.clubUserId,
        })
        const res = await this.$http.api.fetchClubAuthInfoData({
          authId: result.data.auth.authId,
        })
        this.clubInfo = res.data
        console.log(res)
      } catch (error) {}
    },

    onToDeviceList() {
      this.$router.push(`${this.routePrefix}/record/device`)
    },
    onEdit() {
      this.$router.push(`${this.routePrefix}/record/club/edit`)
    },
  },
}
</script>

<style lang="scss" scoped>
@media screen and (min-width: 768px) {
  .page {
    background: #fff;
  }

  .page-top {
    height: 360px;
    @include themify($themes) {
      background: themed('banner-club-register');
      background-size: auto 360px;
    }
    .logo {
      display: block;
      width: 120px;
      height: 120px;
      border-radius: 50%;
      background: #fff;
    }
    .name {
      font-size: 30px;
      color: #fff;
    }
  }
  .page-content {
    width: 700px;
    margin: 0 auto;
    overflow: hidden;
    min-height: calc(100vh - 80px - 80px - 360px);
    box-sizing: border-box;
    padding-bottom: 40px;

    .page-title {
      font-size: 24px;
      font-weight: bold;
      text-align: center;
      padding: 40px 0;
    }

    .row {
      display: flex;
      justify-content: flex-start;
      align-items: flex-start;
      font-size: 18px;
      margin: 24px 0;

      .col {
        &:first-child {
          width: 90px;
          color: #666;
        }

        &:last-child {
          color: #282828;
        }
      }

      .el-image {
        width: 120px;
        height: 120px;
        margin-right: 12px;
      }
    }

    .control {
      margin-top: 62px;
      .button {
        width: 295px;
        height: 50px;

        cursor: pointer;

        &.edit {
          @include themify($themes) {
            border: 1px solid themed('color');
            color: themed('color');
          }
        }

        &.search {
          @include themify($themes) {
            background-color: themed('color');
            color: #fff;
          }
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .page {
    background: #fff;
  }

  .page-top {
    height: 46vw;
    @include themify($themes) {
      background: themed('banner-home-h5');
      background-size: auto 46vw;
    }
    .logo {
      display: block;
      width: 14.8vw;
      height: 14.8vw;
      border-radius: 50%;
      background: #fff;
    }
    .name {
      font-size: 4vw;
      color: #fff;
    }
  }

  .page-content {
    box-sizing: border-box;
    padding: 8vw 7.2vw;

    .page-title {
      font-size: 4.2vw;
      font-weight: bold;
      text-align: center;
      margin-bottom: 8vw;
      color: #282828;
    }

    .row {
      display: flex;
      justify-content: flex-start;
      align-items: flex-start;
      font-size: 3.4vw;
      margin-bottom: 5.6vw;
      flex-wrap: wrap;

      .col {
        &:first-child {
          width: 17vw;
          color: #666;

          &.max-width {
            width: 100% !important;
            margin-bottom: 2.6vw;
          }
        }

        &:last-child {
          color: #282828;
        }
      }

      .el-image {
        width: 25.6vw;
        height: 25.6vw;
      }
    }

    .control {
      margin-top: 22.8vw;
      .button {
        width: 100%;
        height: 12vw;

        cursor: pointer;

        &.edit {
          @include themify($themes) {
            border: 1px solid themed('color');
            color: themed('color');
          }
        }

        &.search {
          @include themify($themes) {
            background-color: themed('color');
            color: #fff;
          }
        }
      }
    }
  }
}
</style>
