<template>
  <div class="wrap">
    <form action method onsubmit="return false" enctype="multipart/form-data">
      <div class="box">
        <label for>请输入原密码:</label>
        <input class="input" type="password"  v-model="passowrd_old" />
      </div>
      <div class="box">
        <label for>请输入新密码:</label>
        <input class="input" type="password"  v-model="passowrd_new" />
      </div>
      <div class="box">
        <label for>请再次输入新密码:</label>
        <input class="input" type="password"  v-model="passowrd_re" />
      </div>
      <div class="btn" @click="oBtn()">
        <input type="submit"  value="保存" />
      </div>
    </form>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data () {
    return {
      num: 654,
      passowrd_old: '',
      passowrd_new: '',
      passowrd_re: '',
      id: null
    }
  },
  computed: {},
  watch: {},
  methods: {
    oBtn () {
      let _this = this
      this.$http({
        method: 'post',
        url: 'v1/login/update-pwd',
        data: {
          id: _this.id,
          passowrd_old: _this.passowrd_old,
          passowrd_new: _this.passowrd_new,
          passowrd_re: _this.passowrd_re
        }
      }).then(res => {
        console.log(res)

        // alert(res.data.data.data.msg)
      })
        // eslint-disable-next-line handle-callback-err
        .catch(err => {
          console.log(err)
        })
    },
    sendMsgToParent () {
      this.$emit('listenToChildExen', this.num)
    }
  },
  created () {
    this.id = localStorage.token
  },
  mounted () {
    this.sendMsgToParent()
  }
}
</script>

<style lang='scss' scoped>
.wrap {
  width: 934px;
  height: 654px;
  background-color: #ffffff;
  padding-top: 36px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: flex-start;

  form {
    .box {
      width: 100%;
      margin-bottom: 30px;
      label {
        font-family: "MicrosoftYaHei";
        font-size: 16px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 40px;
        letter-spacing: 0px;
        color: #333333;
        width: 133px;
        height: 40px;
        text-align: right;
        display: inline-block;
      }

      .input {
        width: 400px;
        height: 40px;
        background-color: #ffffff;
        border-radius: 5px;
        border: solid 1px #dbdbda;
        outline: none;
        margin-left: 30px;
      }
    }

    .btn {
      display: flex;
      justify-content: center;
      margin-top: 60px;

      input[type="submit"] {
        width: 230px;
        height: 63px;
        background-color: #e60012;
        border-radius: 5px;
        font-family: "MicrosoftYaHei";
        font-size: 26px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 63px;
        text-align: center;
        letter-spacing: 0px;
        color: #ffffff;
        outline: none;
      }
    }
  }
}
</style>
