<template>
  <div class="com">
    <div class="title">
      <!-- 汇款凭证 -->
      {{ $t('fund.l81') }}
    </div>
    <el-upload class="avatar-uploader" :action="$uploadUrl" :show-file-list="false" :on-success="handleAvatarSuccess">
      <van-image width="88px" height="88px" fit="contain" :src="file">
        <template v-slot:error>
          <van-icon name="plus" />
        </template>
      </van-image>
    </el-upload>
    <div class="label">
      <!-- 付款人钱包地址 -->
      {{ $t('fund.l89') }}
    </div>
    <!-- 请输入 -->
    <el-input v-model="address" :placeholder="$t('common.l48')"></el-input>
    <!-- 区块链交易ID -->
    <div class="label">{{ $t('fund.l90') }}(Hash)</div>
    <!-- 请输入 -->
    <el-input v-model="hash" :placeholder="$t('common.l48')"></el-input>
  </div>
</template>
<script>
export default {
  data () {
    return {
      file: '',
      address: '',
      hash: '',
    }
  },
  methods: {
    submit() {
      if (!this.file) {
        // this.$toast('请上传汇款凭证');
        this.$toast(this.$t('fund.l82'));
        return false
      }
      if (!this.address.trim()) {
        // this.$toast('请输入钱包地址');
        this.$toast(this.$t('fund.l91'));
        return false
      }
      if (!this.hash.trim()) {
        // this.$toast('请输入交易ID');
        this.$toast(this.$t('fund.l92'));
        return false
      }
      return JSON.stringify({
        file: this.file,
        address: this.address,
        hash: this.hash,
      })
    },
    handleAvatarSuccess(data) {
      if (data.msg != 'ok') {
        // 上传失败
        this.$toast(data.msg || this.$t('fund.l83'));
        return
      }
      this.file = data.data
    },
  }
}
</script>
<style lang="less" scoped>
.com {
  padding-bottom: 22px;
}
.title {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-1-);
  margin-bottom: 20px;
}
.label {
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--color-1-);
}
::v-deep {
  .el-input__inner {
    border: none;
    background-color: #F4F8F9;
    border-radius: 6px;
    height: 38px;
    line-height: 38px;
    padding: 0 12px;
  }
}
</style>