mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-07 00:52:57 +08:00
setup
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
:explain="explain"
|
:explain="explain"
|
||||||
:imgSize="imgSize"
|
:imgSize="imgSize"
|
||||||
:blockSize="blockSize"
|
:blockSize="blockSize"
|
||||||
:barSize="barSize"
|
|
||||||
ref="VerifySlideInstance"
|
ref="VerifySlideInstance"
|
||||||
@success="success"
|
@success="success"
|
||||||
@error="error"
|
@error="error"
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
:explain="explain"
|
:explain="explain"
|
||||||
:imgSize="imgSize"
|
:imgSize="imgSize"
|
||||||
:blockSize="blockSize"
|
:blockSize="blockSize"
|
||||||
:barSize="barSize"
|
|
||||||
ref="VerifyPointsInstance"
|
ref="VerifyPointsInstance"
|
||||||
@success="success"
|
@success="success"
|
||||||
@error="error"
|
@error="error"
|
||||||
@@ -55,129 +55,105 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script setup>
|
||||||
/**
|
/**
|
||||||
* Verify 验证码组件
|
* Verify 验证码组件
|
||||||
* @description 分发验证码使用
|
* @description 分发验证码使用
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
import { ref, computed, onMounted } from 'vue';
|
||||||
import VerifySlide from "./verifySlider/verifySlider.vue";
|
import VerifySlide from "./verifySlider/verifySlider.vue";
|
||||||
import VerifyPoint from "./verifyPoint/verifyPoint.vue";
|
import VerifyPoint from "./verifyPoint/verifyPoint.vue";
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
name: "Vue2Verify",
|
|
||||||
components: {
|
|
||||||
VerifySlide,
|
|
||||||
VerifyPoint,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
captchaType: {
|
captchaType: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true
|
||||||
},
|
|
||||||
figure: {
|
|
||||||
type: Number,
|
|
||||||
},
|
|
||||||
arith: {
|
|
||||||
type: Number,
|
|
||||||
},
|
},
|
||||||
|
figure: Number,
|
||||||
|
arith: Number,
|
||||||
mode: {
|
mode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "pop",
|
default: 'pop'
|
||||||
},
|
},
|
||||||
vSpace: {
|
vSpace: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 5,
|
default: 5
|
||||||
},
|
},
|
||||||
explain: {
|
explain: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "向右滑动完成验证",
|
default: '向右滑动完成验证'
|
||||||
},
|
},
|
||||||
imgSize: {
|
imgSize: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {
|
default: () => ({
|
||||||
return {
|
width: 310,
|
||||||
width: "310px",
|
height: 155
|
||||||
height: "155px",
|
})
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
blockSize: {
|
blockSize: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {
|
default: () => ({
|
||||||
return {
|
width: 50,
|
||||||
width: "50px",
|
height: 50
|
||||||
height: "50px",
|
})
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
barSize: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
// showBox:true,
|
|
||||||
clickShow: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
showBox() {
|
|
||||||
if (this.mode == "pop") {
|
|
||||||
return this.clickShow;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 内部类型
|
|
||||||
verifyType() {
|
|
||||||
if (this.captchaType == "blockPuzzle") {
|
|
||||||
return "2";
|
|
||||||
}
|
|
||||||
return "1";
|
|
||||||
},
|
|
||||||
// 所用组件类型
|
|
||||||
componentType() {
|
|
||||||
if (this.captchaType == "blockPuzzle") {
|
|
||||||
return "VerifySlide";
|
|
||||||
} else {
|
|
||||||
return "VerifyPoints";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {},
|
});
|
||||||
methods: {
|
|
||||||
success(e) {
|
|
||||||
this.$emit("success", e);
|
|
||||||
|
|
||||||
if (this.mode == "pop") {
|
const emit = defineEmits(['success', 'error']);
|
||||||
this.clickShow = false;
|
|
||||||
|
const clickShow = ref(false);
|
||||||
|
const showBox = computed(() => {
|
||||||
|
return props.mode === 'pop' ? clickShow.value : true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const verifyType = computed(() => {
|
||||||
|
return props.captchaType === 'blockPuzzle' ? '2' : '1';
|
||||||
|
});
|
||||||
|
|
||||||
|
const componentType = computed(() => {
|
||||||
|
return props.captchaType === 'blockPuzzle' ? 'VerifySlide' : 'VerifyPoints';
|
||||||
|
});
|
||||||
|
|
||||||
|
const VerifySlideInstance = ref(null);
|
||||||
|
const VerifyPointsInstance = ref(null);
|
||||||
|
|
||||||
|
const success = (e) => {
|
||||||
|
emit('success', e);
|
||||||
|
if (props.mode === 'pop') {
|
||||||
|
clickShow.value = false;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
error() {
|
|
||||||
this.$emit("error");
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* refresh
|
|
||||||
* @description 刷新
|
|
||||||
* */
|
|
||||||
refresh() {
|
|
||||||
if (this.captchaType == "blockPuzzle") {
|
|
||||||
this.$refs.VerifySlideInstance?.refresh?.();
|
|
||||||
} else {
|
|
||||||
this.$refs.VerifyPointsInstance?.refresh?.();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
show() {
|
|
||||||
if (this.mode == "pop") {
|
|
||||||
this.clickShow = true;
|
|
||||||
// this.refresh()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const error = () => {
|
||||||
|
emit('error');
|
||||||
|
};
|
||||||
|
|
||||||
|
const refresh = () => {
|
||||||
|
if (props.captchaType === 'blockPuzzle') {
|
||||||
|
VerifySlideInstance.value.refresh();
|
||||||
|
} else {
|
||||||
|
VerifyPointsInstance.value.refresh();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const show = () => {
|
||||||
|
if (props.mode === 'pop') {
|
||||||
|
clickShow.value = true;
|
||||||
|
// refresh();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
defineExpose({
|
||||||
|
refresh,
|
||||||
|
show
|
||||||
|
})
|
||||||
|
onMounted(() => {
|
||||||
|
// 组件挂载后执行的逻辑
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style scoped>
|
||||||
.verifybox {
|
.verifybox {
|
||||||
position: relative;
|
position: relative;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user