<template>
  <div class="account-details">
    <!-- 基础信息 -->
    <base-info ref="baseInfoRef" client-type="B" :page-type="$route.query.type" />
    <!-- 付款方账户信息 | 静默户账户信息 -->
    <payment-account ref="paymentRef" client-type="B" />

    <div class="submit-btn">
      <el-button
        @click="
          () => {
            $router.go(-1)
          }
        "
      >取消</el-button>
      <el-button type="primary" @click="submitClick('submit')">保存</el-button>
    </div>
    <authorization ref="authorizationRef" :active-info="authActiveInfo" :go-list="true" />
  </div>
</template>

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

export default {
  name: 'CyAccountaccountDetails',
  components: {
    BaseInfo: () => import('./components/BaseInfo.vue'),
    Authorization: () => import('./components/Authorization.vue'),
    PaymentAccount: () => import('./components/PaymentAccount.vue')
  },

  data() {
    return {
      authActiveInfo: {}
    }
  },
  methods: {
    async submitClick() {
      const res = await addMemberRegister({
        ...this.$refs.baseInfoRef.ruleForm,
        silentAccountInfoList: this.$refs.paymentRef.tableData,
        Loading: true
      })

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

      if (res.success && res.data && res.data.authorizationStatus !== 4) {
        this.authActiveInfo = {
          name: res.data.authenticator,
          qrcodeUrl: res.data.qrCode,
          effectTime: res.data.qrCodeEffectTime
        }
        // 回调触发微信授权
        this.$refs.authorizationRef.openDialog(true)
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
