<template>
  <div>
    <div class="rechargeImg"></div>

    <p class="balanceTitle">车牌余额: {{(balance/100).toFixed(2)}}元</p>

    <div style="display: flex;padding: 15px;background: #e6fafa">

      <p style="width: 40%">请输入充值金额</p>
      <input
        class="keep_input"
        v-number-only
        style="width:60%"
        maxlength="5"
        v-model="fileOrder"
        @input="fileOrder = Number($event.target.value.replace(/\D+/, ''))"
      />

    </div>


    <div class="submit-box" @click="toRecharge">
      确定充值
    </div>
  </div>
</template>

<script>
export default {
  name: "recharge",
  data() {
    return {
      balance: "20",
      fileOrder: 100
    };
  },
  directives: {
    numberOnly: {
      bind: function(el) {
        el.handler = function() {
          el.value = Number(el.value.replace(/\D+/, ''))
        }
        el.addEventListener('input', el.handler)
      },
      unbind: function(el) {
        el.removeEventListener('input', el.handler)
      }
    }
  },
};
</script>

<style scoped>
  .rechargeImg{
    width: 80px;
    height: 80px;
    margin: 20px auto;
    background: url("../../assets/images/recharge.png");
  }
  .balanceTitle {
    padding: 15px;
    background: #ccc;
    font-size: 16px;
    /*color: #fff;*/
  }

  .submit-box {
    width: 80%;
    height: 44px;
    line-height: 44px;
    border-radius: 4px;
    font-size: 20px;
    margin: 58px auto 0;
    background: linear-gradient(180deg, #3885D9 0%, #4194EF 100%);
    color: #fff;
    text-align: center;
  }
  .keep_input {
    -webkit-appearance: none;
    background-color: #fff;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #dcdfe6;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #606266;
    display: inline-block;
    font-size: inherit;
    outline: 0;
    padding: 0 15px;
    -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    height: 30px;
    line-height: 30px;
    text-align: left;
  }
  .keep_input:focus {
    border-color: #54a6de;
    outline: 0;
  }
</style>
