<template>
  <div class="page">
    <div class="header">
      <div class="back">
        <backIcon/>
      </div>
      <!-- 添加收款账户 -->
      {{ $t('fund.l16') }}
    </div>
    <!-- 收款人账户类别 -->
    <van-field @click="payMethodPopup = true" class="type" :border="false" :label="$t('fund.l14')" input-align="right">
      <template #input>
        <div class="select-box flex">
          <div v-if="type">{{ payName[type] }}</div>
          <div v-else>
            <!-- 未选择 -->
            {{ $t('fund.l11') }}
          </div>
          <i class="el-icon-arrow-right"></i>
        </div>
      </template>
    </van-field>
    <bankForm ref="form1" v-if="type == 1"/>
    <bankInterForm ref="form2" v-if="type == 2"/>
    <currencyForm ref="form3" v-if="type == 3"/>
    <van-popup v-model="payMethodPopup" round position="bottom">
      <!-- 收款人账户类别 -->
      <payMethod :title="$t('fund.l14')" :type="type" @success="payBack" @cancel="payMethodPopup = false"/>
    </van-popup>
    <div class="fixed">
      <div class="btn" @click="submit">
        <!-- 保存 -->
        {{ $t('common.l47') }}
      </div>
    </div>
  </div>
</template>
<script>
import bankForm from "./components/bankForm.vue";
import bankInterForm from "./components/bankInterForm.vue";
import currencyForm from "./components/currencyForm.vue";
import payMethod from "@/components/payMethod";
export default {
  components: {
    bankForm,
    bankInterForm,
    currencyForm,
    payMethod
  },
  data () {
    return {
      type: 0,
      payMethodPopup: false
    }
  },
  computed: {
    payName() {
      return {
        // '1': '本地银行取款',
        // '2': '国际电汇',
        // '3': '数字货币',
        '1': this.$t('fund.l15'),
        '2': this.$t('account.l32'),
        '3': this.$t('account.l33'),
      }
    }
  },
  methods: {
    submit() {
      if (!this.type) {
        return
      }
      this.$refs['form' + this.type].validate()
    },
    payBack(type) {
      this.type = type
      this.payMethodPopup = false
    }
  }
}
</script>
<style lang="less" scoped>
.page {
  background-color: #F7F8FA;
  min-height: 100vh;
  padding-bottom: 90px;
}
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  text-align: center;
  padding-top: 15px;
  padding-bottom: 17px;
  font-size: 18px;
  font-weight: 600;
  background-color: var(--bg-);
  .back {
    position: absolute;
    left: 9px;
    top: 11px;
  }
}
.type {
  margin-bottom: 12px;
}
.select-box {
  column-gap: 3px;
  cursor: pointer;
  .el-icon-arrow-right {
    color: #C3C3C3;
    font-weight: 600;
  }
}
.fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #F7F8FA;
  padding: 10px 18px 29px;
  .btn {
    cursor: pointer;
    line-height: 44px;
    text-align: center;
    background: #000000;
    color: #FEFFFF;
    font-weight: 600;
    border-radius: 6px;
    font-size: 16px;
  }
}
::v-deep {
  .van-field {
    padding: 19px 18px;
    font-size: 16px;
  }
  .van-field__control {
    color: #808080;
    &::placeholder {
      color: #808080;
    }
  }
  .van-field__label {
    width: auto;
    font-size: 18px;
    font-weight: 500;
    color: var(--color-1-);
  }
}
</style>