SliderVerify.vue 2.6 KB

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