SliderVerify.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="verify-content">
  3. <slide-verify
  4. ref="block"
  5. v-bind="props.slideVerifyOptions"
  6. :slider-text="sliderText"
  7. @again="onAgain"
  8. @success="onSuccess"
  9. @fail="onFail"
  10. ></slide-verify>
  11. <div class="verify-content-action">
  12. <span class="verify-content-action__refresh" @click="refresh">
  13. <img src="/refresh.png" />
  14. <span>{{ L["humanMachineVerify"]["刷新"] }}</span>
  15. </span>
  16. </div>
  17. </div>
  18. </template>
  19. <script lang="ts" setup>
  20. import { ref, computed } from "vue";
  21. import SlideVerify from "vue3-slide-verify";
  22. import type { SlideVerifyInstance } from "vue3-slide-verify";
  23. import { getCurLanguage } from "@/composables/common.js";
  24. import "vue3-slide-verify/dist/style.css";
  25. const props = defineProps({
  26. slideVerifyOptions: {
  27. type: Object,
  28. default: () => {},
  29. },
  30. });
  31. const emits = defineEmits(["onSuccess", "onFail"]);
  32. const block = ref<SlideVerifyInstance>();
  33. const L = getCurLanguage();
  34. const sliderText = computed(
  35. () => L["humanMachineVerify"]["拖动滑块来填充拼图"]
  36. );
  37. const onSuccess = () => {
  38. emits("onSuccess");
  39. };
  40. const refresh = () => {
  41. block.value?.refresh();
  42. };
  43. const onFail = () => {
  44. emits("onFail");
  45. };
  46. const onAgain = () => {
  47. // 刷新
  48. block.value?.refresh();
  49. };
  50. </script>
  51. <style lang="scss" scoped>
  52. .verify-content {
  53. position: relative;
  54. height: 100%;
  55. :deep(.slide-verify) {
  56. canvas {
  57. border-radius: 20px;
  58. }
  59. .slide-verify-slider {
  60. border-radius: 25px;
  61. height: 50px;
  62. line-height: 50px;
  63. box-sizing: content-box;
  64. }
  65. .slide-verify-slider-mask {
  66. width: 50px;
  67. height: 50px;
  68. border-radius: 25px;
  69. background-color: $colorMain;
  70. border-color: transparent;
  71. }
  72. .slide-verify-slider-mask-item {
  73. width: 50px;
  74. height: 50px;
  75. border-radius: 100%;
  76. &:hover {
  77. background: #fff;
  78. .iconfont {
  79. color: #303030;
  80. }
  81. }
  82. }
  83. .slide-verify-slider-text {
  84. color: #666;
  85. }
  86. .container-success {
  87. .slide-verify-slider-mask-item {
  88. background-color: $colorMain !important;
  89. .iconfont {
  90. color: #fff;
  91. }
  92. }
  93. }
  94. }
  95. &-action {
  96. height: 30px;
  97. margin-top: 20px;
  98. &__refresh {
  99. display: flex;
  100. // justify-content: center;
  101. align-items: center;
  102. cursor: pointer;
  103. img {
  104. width: 20px;
  105. margin-right: 5px;
  106. }
  107. span {
  108. font-weight: bold;
  109. }
  110. }
  111. }
  112. }
  113. </style>