<template>
  <div class="app-container" :style="{height:height+'px'}">
    <van-nav-bar
      title="银行账户修改"
      left-arrow
      fixed
      placeholder
      @click-left="onClickLeft"
    />
    <van-form @submit="submitBank">
      <van-field v-model="form.bankAddress" label="开户银行" placeholder="请输入开户银行" required :rules="[{ required:true }]"/>
      <van-field v-model="form.bankCardName" label="开户姓名" placeholder="请输入姓名" required :rules="[{ required:true }]"/>
      <van-field v-model="form.bankCardNum" label="开户账号" placeholder="请输入开户账号" required :rules="[{ required:true }]"/>
      <div class="submit">
        <van-button round block type="info" color="#007E72" native-type="submit">保存</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import { getMember , userUpdate } from "@/api/user/index";
import { getInfo } from "@/api/login/index";
import {Dialog} from "vant";
  export default {
    name: "bankInformation",
    data() {
      return {
        height:0,
        tel:'',
        fileList:[],
        form:{
          bankCardName:'',
          bankCardNum:'',
          bankAddress:'',
          id:'',
        }
      };
    },
    created() {
      this.height = document.body.clientHeight;
      this.getInfo();
    },
    methods: {
      getInfo(){
        getInfo().then(response => {
          getMember(response.user.userId).then(response => {
            console.log(response)
            this.form.bankCardName = response.data.bankCardName;
            this.form.bankCardNum = response.data.bankCardNum;
            this.form.bankAddress = response.data.bankAddress;
            this.form.id = response.data.id;
          });
        });
      },
      submitBank(){
        userUpdate(this.form).then(response => {
          console.log(response)
          if (response.code == 200){
            Dialog.confirm({
              title: '系统提示',
              message: '修改成功',
              confirmButtonText: '确定',
            })
          }
        });
      }
    },
  };
</script>

<style scoped lang="scss">
  .app-container {
    background-color: #FFF;
  }
  .submit{
    position: absolute;
    bottom: 5%;
    width: 90%;
    left: 5%;
    p{
      text-align: center;
      margin-bottom: 0.2rem;
      span{
        color: #007E72;
      }
    }
  }
</style>
