<template>
  <div class="club-info 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 class="name mt-2">认证记录</div>
    </div>
    <div class="page-content">
      <div class="page-title">机构认证</div>
      <FormClubInfo ref="formClubInfo" @step="onClubInfoFormStep" />
      <div class="control flex flex-col items-center">
        <div
          class="button submit flex justify-center items-center"
          @click="onSubmit"
        >
          提交
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import SimpleUploadImage from '@/components/SimpleUploadImage'
import SimpleRadio from '@/components/SimpleRadio'
import { mapGetters } from 'vuex'
import FormClubInfo from '../../form/components/form-club-info.vue'
export default {
  layout: 'app-ross',
  components: {
    SimpleUploadImage,
    SimpleRadio,
    FormClubInfo,
  },
  computed: {
    ...mapGetters(['supplierInfo', 'authUserId', 'routePrefix', 'clubUserId']),
  },
  data() {
    return {
      clubInfo: {},
      formData: {},
    }
  },
  created() {
    this.fetchAuthDetail()
  },
  methods: {
    async onSubmit() {
      try {
        await this.$refs.formClubInfo.validate()
        this.formData.authUserId = this.authUserId
        this.formData.source = 2
        this.formData.authId = this.clubInfo.authId
        console.log(this.formData)
        await this.$http.api.authClubSave(this.formData)
        this.$toast('保存成功')
        this.$router.push(`${this.routePrefix}/record/club/detail`)
      } catch (error) {
        console.log(error)
      }
    },

    // 获取认证机构信息
    async fetchAuthDetail() {
      try {
        const result = await this.$http.api.fetchClubAuthInfo({
          clubUserId: this.clubUserId,
        })
        this.formData.authId = result.data.auth.authId
        const res = await this.$http.api.fetchClubAuthInfoData({
          authId: result.data.auth.authId,
        })
        this.clubInfo = res.data
        this.$refs.formClubInfo.init(this.clubInfo)
      } catch (error) {
        console.log(error)
      }
    },

    onClubInfoFormStep(data) {
      this.formData = data
    },
  },
}
</script>

<style lang="scss" scoped>
@media screen and (min-width: 768px) {
  .page {
    background: #fff;
  }
  .page-top {
    height: 360px;
    @include themify($themes) {
      background: themed('pc-banner-record-club');
      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;
    }

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

        cursor: pointer;

        &.submit {
          @include themify($themes) {
            background-color: themed('color');
            color: #fff;
          }
        }
      }
    }
    .normal-row {
      position: relative;
      .label {
        font-size: 14px;
        color: #606266;

        span {
          color: #b2b2b2;
        }
      }
      .postion-btn {
        position: absolute;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        width: 62px;
        height: 28px;
        line-height: 28px;
        font-size: 14px;
        color: #fff;
        background: #1890ff;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        border-radius: 4px;

        &::before {
          content: '';
          display: inline-block;
          width: 16px;
          height: 16px;
          background: url(~assets/theme-images/common/icon-position.png)
            no-repeat center;
          background-size: 16px 16px;
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  ::v-deep {
    .el-form-item__label {
      font-size: 3.4vw;
    }
  }

  .page {
    background: #fff;
  }

  .page-top {
    height: 46vw;
    @include themify($themes) {
      background: themed('h5-banner-record-club');
      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 7vw;

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

    .control {
      .button {
        width: 100%;
        height: 12vw;

        cursor: pointer;

        &.submit {
          @include themify($themes) {
            background-color: themed('color');
            color: #fff;
          }
        }
      }
    }
    .normal-row {
      position: relative;
      .label {
        font-size: 14px;
        color: #606266;

        span {
          color: #b2b2b2;
          font-size: 2.6vw;
        }
      }
      .postion-btn {
        position: absolute;
        top: 50%;
        right: 0;
        transform: translateY(-50%);
        width: 14vw;
        height: 6.8vw;
        line-height: 6.8vw;
        font-size: 3.2vw;
        color: #fff;
        background: #1890ff;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        border-radius: 0.4vw;

        &::before {
          content: '';
          display: inline-block;
          width: 3.58vw;
          height: 3.58vw;
          background: url(~assets/theme-images/common/icon-position.png)
            no-repeat center;
          background-size: 3.58vw;
        }
      }
    }
  }
}
</style>
