app-preset-auth.vue 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
<template>
  <div class="app-preset-auth">
    <auth-puzzle-vcode :show="show" @success="onSuccess" @fail="onFail" />
    <i-button ghost @click="executeOpen" long class="app-preset-auth-button"
      >验证</i-button
    >
  </div>
</template>

<script lang="ts">
import { Vue, Component, Prop, Model } from "vue-property-decorator";
import AuthPuzzleVcode from "./vue-puzzle-code/vue-puzzle-code.vue";
@Component({
  components: {
    "auth-puzzle-vcode": AuthPuzzleVcode,
  },
})
export default class AppPreSetAuth extends Vue {
  /**
   * 输入值
   *
   * @type {*}
   * @memberof AppPreSetAuth
   */
  @Prop() public value!: any;

  /**
   * 名称
   *
   * @type {string}
   * @memberof AppPreSetAuth
   */
  @Prop() public name!: string;

  /**
   * 类型
   *
   * @type {string}
   * @memberof AppPreSetAuth
   */
  @Prop() public type?: string;

  /**
   * 是否显示
   */
  public show: boolean = false;

  /**
   * 组件创建时触发
   *
   * @type {*}
   * @memberof AppPreSetAuth
   */
  public created() {
    this.$emit("valueChange", { name: this.name, value: false });
  }

  /**
   * 打开
   */
  public executeOpen() {
    this.show = true;
  }

  /**
   * 成功
   */
  public onSuccess() {
    this.show = false;
    this.$emit("valueChange", { name: this.name, value: true });
  }

  /**
   * 成功
   */
  public onFail() {
    this.$emit("valueChange", { name: this.name, value: false });
  }
}
</script>

<style lang='less'>
.app-preset-auth {
  .app-preset-auth-button {
    border: 1px solid #dcdee2;
    border-radius: 4px;
    color: #515a6e;
    &:hover{
      border: 1px solid #dcdee2;
      color: #515a6e;
    }
  }
}
</style>