PasswordInputer.vue 2.36 KB
<template>
  <v-card flat id="PasswordInputer">
    <div class="PasswordInputerTitle">请输入交易密码</div>
    <div class="PasswordInputBlock">
      <div class="passwordDisplayer" v-for="(len, index) in 6" :key="index"><span :class="password.length >= len ? '' : 'white'">*</span></div>
    </div>
    <!-- <div class="submitButton" @click="submit">确  定</div> -->
    <PasswordBeyboard :showClose="false" :showTitle="false" @input="passwordInput" @delete="deleteInput"/>
  </v-card>
</template>

<script>
import PasswordBeyboard from '@/components/PasswordBeyboard'
export default {
  data: () => ({
    password: '',
  }),
  components: {
    PasswordBeyboard
  },
  props: {
    display: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    display: function (val, oldVal) {
      if (val) {
        // this.reset()
        // this.$refs['0'].focus()
      }
    },
  },
  methods: {
    reset() {
      this.password = ''
    },
    passwordInput(e) {
      if (this.password.length < 6) {
        this.password += e
      }
      if (this.password.length === 6) {
        this.submit()
      }
    },
    deleteInput(e) {
      this.password = this.password.slice(0, this.password.length - 1)
    },
    submit() {
      if (this.password.length !== 6) return
      this.$emit('passwordSubmit', this.password)
    }
  }
}
</script>

<style lang="scss" scoped>
  #PasswordInputer {
    background-color: $background-black;
    color: $light-gold;

    .PasswordInputerTitle {
      height: 3rem;
      line-height: 3rem;
      text-align: center;
      position: relative;
      font-size: 1.5rem;
    }

    .PasswordInputBlock {
			height: 3.5rem;
			margin: 0 0  2rem 0;
			text-align: center;
			vertical-align: bottom;

			.passwordDisplayer {
				width: 3.5rem;
        height: 3.5rem;
        color: #000;
				background-color: #fff;
				border: 1px solid $gold;
				border-left: none; 
				text-align: center;
				font-size: 2.5rem;
				display: inline-block;

				.white {
					color: #fff;
				}

				&:nth-child(1) {
					border-left: 1px solid $gold;
					border-radius: 5px 0 0 5px;
				}

				&:nth-child(6) {
					border-radius: 0 5px 5px 0;
				}

			}
		}

    
    .submitButton {
      height: 3.5rem;
      font-size: 1.2rem;
      line-height: 3.5rem;
      border-top: 1px solid #ccc;
      border-bottom: 1px solid #ccc;
      margin-top: 3rem;
    }
  }
</style>