<template>
  <div v-loading="loading">
    <div class="white-box">
      <el-tabs v-model="tabActive" style="overflow: auto">
        <el-tab-pane label="登录密码" name="password" style="overflow: auto">
          <el-form ref="form" :model="passwordInfo" label-width="250px" class="form-page">
            <el-form-item label="原登录密码">
              <el-input v-model="passwordInfo.oldPassword" show-password></el-input>
            </el-form-item>
            <el-form-item label="新登录密码">
              <el-input v-model="passwordInfo.password" show-password></el-input>
            </el-form-item>
            <el-form-item label="确认新密码">
              <el-input v-model="passwordInfo.verifyPassword" show-password></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="handlePasswordSubmit" :loading="passwordButtonStat">确认</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="支付密码" name="payPassword" style="overflow: auto">
          <el-form ref="form" :model="payPasswordInfo" label-width="250px" class="form-page">
            <el-form-item label="原支付密码">
              <el-input v-model="payPasswordInfo.oldPassword" show-password></el-input>
            </el-form-item>
            <el-form-item label="新支付密码">
              <el-input v-model="payPasswordInfo.payPassword" show-password></el-input>
            </el-form-item>
            <el-form-item label="确认新密码">
              <el-input v-model="payPasswordInfo.verifyPassword" show-password></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="handlePayPasswordSubmit" :loading="payPasswordButtonStat">确认</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import network from './../../utils/network'
import tool from './../../utils/tool'
import store from '@/utils/vuexStore'

export default {
  name: 'user_password',
  mounted () {
  },
  data () {
    return {
      passwordInfo:{
          oldPassword:'',
          password:'',
          verifyPassword:'',
      },
      payPasswordInfo:{
          oldPassword:'',
          payPassword:'',
          verifyPassword:'',
      },
      tabActive: 'password',
      loading: false,
      passwordButtonStat:false,
      payPasswordButtonStat:false,
    }
  },
  methods: {
    handlePasswordSubmit(){
        this.passwordButtonStat = true
        let path = 'user/password'
        return network.postData(path, this.passwordInfo).then(response => {

            this.$message({
                message: response,
                type: 'success'
            })
            this.passwordButtonStat = false
        }).catch(() => {
            this.passwordButtonStat = false
        })
    },

    handlePayPasswordSubmit(){
        this.payPasswordButtonStat = true
        let path = 'user/pay-password'
        return network.postData(path, this.payPasswordInfo).then(response => {

            this.$message({
                message: response,
                type: 'success'
            })
            this.payPasswordButtonStat = false
        }).catch(() => {
            this.payPasswordButtonStat = false
        })
    },

  }
}

</script>

<style scoped>

</style>