滑块验证优化

This commit is contained in:
mabo
2021-06-29 14:58:07 +08:00
parent 0575503687
commit 18bfa0edef
10 changed files with 77 additions and 72 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div class="login">
<div class="login" @click="$refs.verify.show = false">
<Row type="flex" @keydown.enter.native="submitLogin">
<Col style="width: 368px">
<Header />
@@ -128,7 +128,7 @@ export default {
// 登录提交
this.$refs.usernameLoginForm.validate((valid) => {
if (valid) {
this.$refs.verify.show = true;
this.$refs.verify.init();
}
});
},

View File

@@ -1,5 +1,5 @@
<template>
<div class="verify-content" v-if="show" @mousemove="mouseMove" @mouseup="mouseUp">
<div class="verify-content" v-if="show" @mousemove="mouseMove" @mouseup="mouseUp" @click.stop>
<div class="imgBox" :style="{width:data.originalWidth+'px',height:data.originalHeight + 'px'}">
<img :src="data.backImage" style="width:100%;height:100%" alt="">
<img class="slider" :src="data.slidingImage" :style="{left:distance+'px',top:data.randomY+'px'}" :width="data.sliderWidth" :height="data.sliderHeight" alt="">
@@ -38,7 +38,7 @@ export default {
distance: 0, // 拼图移动距离
flag: false, // 判断滑块是否按下
downX: 0, // 鼠标按下位置
bgColor: 'aqua', // 滑动背景颜色
bgColor: '#04ad11', // 滑动背景颜色
verifyText: '拖动滑块解锁' // 文字提示
};
},
@@ -83,34 +83,32 @@ export default {
}
});
},
refresh () {
refresh () { // 刷新滑块
this.flag = false;
this.downX = 0;
this.distance = 0;
this.bgColor = 'aqua';
this.bgColor = '#04ad11';
this.verifyText = '拖动滑块解锁';
this.getImg();
this.init();
},
getImg () {
init () { // 初始化数据
getVerifyImg(this.type).then(res => {
this.data = res.result;
if (res.result) {
this.data = res.result;
this.show = true;
} else {
this.$Message.warning('请求失败请重试!')
}
});
}
},
created () {
// this.getImg();
},
watch: {
verifyType: {
immediate: true,
handler: function (v) {
this.type = v;
// this.refresh();
}
},
show (v) {
if (v) this.refresh();
}
}
};
</script>
@@ -143,7 +141,7 @@ export default {
}
}
.handle {
border: 1px solid rgb(134, 134, 134);
border: 1px solid #e4dede;
margin-top: 5px;
height: 42px;
background: #ddd;
@@ -156,7 +154,7 @@ export default {
width: 40px;
height: 40px;
opacity: 0.5;
background: aqua;
background: #04ad11;
}
.swiper {