<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.oldPassWord" type="password" label="原密码" placeholder="请输入原密码" required :rules="[{ required:true }]"/>
      <van-field v-model="form.newPassWord" type="password" label="新密码" placeholder="请输入新密码" required :rules="[{ required:true }]"/>
      <van-field v-model="form.determinePassWord" type="password" 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, passWordUpdate} from "@/api/user/index";
import {Dialog} from "vant";
  import {getInfo} from "@/api/login";
  export default {
    name: "bankInformation",
    data() {
      return {
        height:0,
        tel:'',
        fileList:[],
        form:{
          oldPassWord:'',
          newPassWord:'',
          determinePassWord:'',
          id:'',
        }
      };
    },
    created() {
      this.height = document.body.clientHeight;
      this.getInfo();
    },
    methods: {
      getInfo(){
        getInfo().then(response => {
          getMember(response.user.userId).then(response => {
            this.form.id = response.data.id;
          });
        });
      },
      submitBank(){
        passWordUpdate(this.form.oldPassWord, this.form.newPassWord).then(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>
