<template>
  <div class="empty-box" :style="{ 'margin-top': marginTop }">
    <h2 v-if="type === 'openInfoManage'">
      您还未提交任何资料，请先提交开户资料以继续开通会员账户
    </h2>
    <h2 v-if="type === 'cyAccountManage'">
      您已完成开户，请继续进行账户开通～
    </h2>
    <el-button style="margin-top: 50px" type="primary" @click="btnClick">
      {{ type === 'cyAccountManage' ? '开通长银账户' : '提交开户资料' }}
    </el-button>
    <authorization ref="authorizationRef" :active-info="authActiveInfo" :fresh-page="true" />
  </div>
</template>

<script>
import { addMemberRegister } from '@/api/accountCenter/cyAccountManage'

export default {
  props: {
    type: {
      type: String,
      default: 'openInfoManage' // openInfoManage 开户资料管理  cyAccountManage 长银账户管理
    },
    marginTop: {
      type: String,
      default: '25vh'
    },
    addId: {
      type: Number,
      default: null
    },
    customerName: {
      type: String,
      default: ''
    },
    customerStatus: {
      type: String,
      default: ''
    },
    customerNumber: {
      type: String,
      default: ''
    }
  },
  components: {
    Authorization: () => import('../cyAccountManage/components/Authorization.vue')
  },
  data() {
    return {
      authActiveInfo: []
    }
  },
  methods: {
    btnClick() {
      if (this.type === 'openInfoManage') {
        this.$router.push({
          name: 'OpenInfoManageDetails',
          params: { id: 'add' },
          query: {
            type: 'add'
          }
        })
      } else if (this.type === 'cyAccountManage') {
        // this.$router.push({
        //   name: 'CyAccountaccountAdd',
        //   query: {
        //     type: 'add',
        //     addId: this.addId,
        //     name: this.customerName,
        //     number: this.customerNumber
        //   }
        // })
        this.openActivation(this.addId)
      }
    },
    // 开通长银账户
    async openActivation(addId) {
      const res = await addMemberRegister({ bocomBasicInfoId: addId, Loading: true })

      console.log('addMemberRegister----', res)

      if (res.success && res.data && res.data.authorizationStatus !== 4) {
        this.authActiveInfo = res.data.noticeInfoList
        // 回调触发微信授权
        this.$refs.authorizationRef.openDialog(true)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.empty-box {
  width: 100%;
  text-align: center;
  margin-top: 25vh;
}
</style>
