<template>
  <div class="partner-wrap">
    <div class="partner-info">
      <div class="qrcode-title">
        <div class="left">
          <img
            :src="partnerInfo.partnerHeadImg?partnerInfo.partnerHeadImg:require('../../../static/imgs/public/default-avatar.png')"
            alt="avatar"
          >
        </div>
        <div class="right">
          <span class="partner-name">{{partnerInfo.partnerName||'暂无'}}</span>
          <span class="audit-status">{{partnerInfo.partnerStatusText}}</span>
        </div>
      </div>
    </div>

    <van-button
      v-if="partnerInfo.partnerStatusText === '待审核'"
      type="info"
      @click="submit"
    >去提交认证</van-button>

    <div
      v-if="partnerInfo.partnerStatusText === '审核驳回'"
      class="audit-reject"
    >
      <span>请联系客服,咨询加入合伙人详细事宜</span>
    </div>
  </div>
</template>

<script>
import {
  getPartnerInfo
} from '../../../api/Partner/Partner'
export default {
  data() {
    return {
      partnerInfo: {},
    }
  },
  methods: {
    submit() {
      this.$router.push({
        name: 'PartnerRegister'
      })
    }
  },
  mounted() {
    
    getPartnerInfo()
      .then(({
        data
      }) => {
        if(data.result){
          this.partnerInfo = data.result.partner;
          if (data.result.partner.partnerStatus === 98) {
            this.partnerInfo.partnerStatusText = '审核驳回'
          } else if (data.result.partner.partnerStatus === 99) {
            this.partnerInfo.partnerStatusText = '待审核'
          } else if (data.result.partner.partnerStatus === 1) {
            this.partnerInfo.partnerStatusText = '审核通过'
            this.$router.push({name: "PartnerHome"})
          } else if (data.result.partner.partnerStatus === 2) {
            this.partnerInfo.partnerStatusText = '停用'
          }
      }else{
            this.partnerInfo.partnerStatusText = '待审核'
        }
      }
      )

    
  }
}
</script>

<style lang="less" scoped>
.partner-info {
  width: 100%;
  height: 2.18rem;
  background-color: #5594fc;

  .qrcode-title {
    display: flex;
    align-items: center;
    margin-right: 0.3rem;
    width: 100%;
    min-height: 1.96rem;

    .left {
      width: 20%;

      img {
        width: 0.96rem;
        height: 0.96rem;
        border-radius: 50%;
      }
    }

    .right {
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      align-items: flex-start;
      width: 80%;
      font-size: 0.36rem;

      .partner-name {
        color: #ffffff;
        margin-bottom: 0.2rem;
        letter-spacing: 0.02rem;
      }

      .audit-status {
        color: #fff;
        padding: 0.06rem 0.1rem;
        background-color: #f93232;
        font-size: 0.3rem;
        border-radius: 0.05rem;
      }
    }
  }
}

.van-button {
  margin-top: 1.4rem;
  width: 3.24rem;
  height: 0.8rem;
  background-color: #478bfb;
}

.audit-reject {
  font-size: 0.32rem;
  margin-top: 1rem;
  letter-spacing: 0.02rem;
}
</style>