滑块验证优化

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

View File

@ -31,7 +31,7 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
#app{ #app{
min-height: 100%; height: 100%;
@include background_color($light_background_color); @include background_color($light_background_color);
} }
</style> </style>

View File

@ -1,5 +1,5 @@
<template> <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'}"> <div class="imgBox" :style="{width:data.originalWidth+'px',height:data.originalHeight + 'px'}">
<img :src="data.backImage" style="width:100%;height:100%" alt=""> <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=""> <img class="slider" :src="data.slidingImage" :style="{left:distance+'px',top:data.randomY+'px'}" :width="data.sliderWidth" :height="data.sliderHeight" alt="">
@ -38,16 +38,16 @@ export default {
distance: 0, // distance: 0, //
flag: false, // flag: false, //
downX: 0, // downX: 0, //
bgColor: 'aqua', // bgColor: '#04ad11', //
verifyText: '拖动滑块解锁' // verifyText: '拖动滑块解锁' //
}; };
}, },
methods: { methods: {
mouseDown (e) { // mouseDown (e) {
this.downX = e.clientX; this.downX = e.clientX;
this.flag = true; this.flag = true;
}, },
mouseMove (e) { // mouseMove (e) {
if (this.flag) { if (this.flag) {
let offset = e.clientX - this.downX; let offset = e.clientX - this.downX;
@ -60,7 +60,7 @@ export default {
} }
} }
}, },
mouseUp () { // mouseUp () {
if (!this.flag) return false; if (!this.flag) return false;
this.flag = false; this.flag = false;
let params = { let params = {
@ -83,33 +83,31 @@ export default {
} }
}); });
}, },
refresh () { // refresh () { //
this.flag = false; this.flag = false;
this.downX = 0; this.downX = 0;
this.distance = 0; this.distance = 0;
this.bgColor = 'aqua'; this.bgColor = '#04ad11';
this.verifyText = '拖动滑块解锁'; this.verifyText = '拖动滑块解锁';
this.getImg(); this.init();
}, },
getImg () { // init () { //
getVerifyImg(this.type).then(res => { getVerifyImg(this.type).then(res => {
if (res.result) {
this.data = res.result; this.data = res.result;
this.show = true;
} else {
this.$Message.warning('请求失败请重试!')
}
}); });
} }
}, },
created () {
// this.getImg();
},
watch: { watch: {
verifyType: { verifyType: {
immediate: true, immediate: true,
handler: function (v) { handler: function (v) {
this.type = v; this.type = v;
// this.refresh();
} }
},
show (v) {
if (v) this.refresh();
} }
} }
}; };
@ -143,7 +141,7 @@ export default {
} }
} }
.handle { .handle {
border: 1px solid rgb(134, 134, 134); border: 1px solid #e4dede;
margin-top: 5px; margin-top: 5px;
height: 42px; height: 42px;
background: #ddd; background: #ddd;
@ -156,7 +154,7 @@ export default {
width: 40px; width: 40px;
height: 40px; height: 40px;
opacity: 0.5; opacity: 0.5;
background: aqua; background: #04ad11;
} }
.swiper { .swiper {

View File

@ -17,15 +17,15 @@ export default {
* @description api请求基础路径 * @description api请求基础路径
*/ */
api_dev: { api_dev: {
common: 'http://192.168.0.100:8890', // common: 'http://192.168.0.100:8890',
buyer: 'http://192.168.0.100:8888', // buyer: 'http://192.168.0.100:8888',
seller: 'http://192.168.0.100:8889', // seller: 'http://192.168.0.100:8889',
manager: 'http://192.168.0.100:8887' // manager: 'http://192.168.0.100:8887'
// common: 'https://common-api.pickmall.cn', common: 'https://common-api.pickmall.cn',
// buyer: 'https://buyer-api.pickmall.cn', buyer: 'https://buyer-api.pickmall.cn',
// seller: 'https://store-api.pickmall.cn', seller: 'https://store-api.pickmall.cn',
// manager: 'https://admin-api.pickmall.cn' manager: 'https://admin-api.pickmall.cn'
}, },
api_prod: { api_prod: {
common: 'https://common-api.pickmall.cn', common: 'https://common-api.pickmall.cn',

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="login" @keyup.enter="handleSubmit('formInline')"> <div class="login" @keyup.enter="handleSubmit('formInline')">
<!-- 顶部logo --> <!-- 顶部logo -->
<div class="top-content"> <div class="top-content" @click='$refs.verify.show = false'>
<div class="logo-box"> <div class="logo-box">
<img <img
:src="logoImg" :src="logoImg"
@ -15,7 +15,7 @@
<!-- 轮播 --> <!-- 轮播 -->
<Carousel loop :autoplay-speed="5000" class="login-carousel" arrow="never"> <Carousel loop :autoplay-speed="5000" class="login-carousel" arrow="never">
<CarouselItem> <CarouselItem>
<div class="demo-carousel"> <div class="demo-carousel" @click='$refs.verify.show = false'>
<img <img
src="https://wanmi-b2b.oss-cn-shanghai.aliyuncs.com/201811141632252680" src="https://wanmi-b2b.oss-cn-shanghai.aliyuncs.com/201811141632252680"
/> />
@ -23,7 +23,7 @@
</CarouselItem> </CarouselItem>
</Carousel> </Carousel>
<!-- 登录模块 --> <!-- 登录模块 -->
<div class="form-box"> <div class="form-box" @click='$refs.verify.show = false'>
<div class="account-number"> <div class="account-number">
<div class="tab-switch"> <div class="tab-switch">
<span>{{type?'账号登录':'验证码登录'}}</span> <span>{{type?'账号登录':'验证码登录'}}</span>
@ -37,6 +37,7 @@
:model="formData" :model="formData"
:rules="ruleInline" :rules="ruleInline"
v-show="type === true" v-show="type === true"
@click.self='$refs.verify.show = false'
> >
<FormItem prop="username"> <FormItem prop="username">
<i-input <i-input
@ -72,6 +73,7 @@
:model="formSms" :model="formSms"
:rules="ruleInline" :rules="ruleInline"
v-show="type === false" v-show="type === false"
@click.self='$refs.verify.show = false'
> >
<FormItem prop="mobile"> <FormItem prop="mobile">
<i-input <i-input
@ -194,7 +196,7 @@ export default {
this.$refs[name].validate((valid) => { this.$refs[name].validate((valid) => {
if (valid) { if (valid) {
if (this.type) { if (this.type) {
this.$refs.verify.show = true; this.$refs.verify.init();
} else { } else {
let data = JSON.parse(JSON.stringify(this.formSms)); let data = JSON.parse(JSON.stringify(this.formSms));
apiLogin.smsLogin(data).then((res) => { apiLogin.smsLogin(data).then((res) => {
@ -224,6 +226,7 @@ export default {
} }
}); });
}, },
//
sendCode () { sendCode () {
if (this.time === 60) { if (this.time === 60) {
if (this.formSms.mobile === '') { if (this.formSms.mobile === '') {
@ -296,9 +299,10 @@ export default {
this.$refs.verify.show = false; this.$refs.verify.show = false;
} }
}, },
//
verifyBtnClick () { verifyBtnClick () {
if (!this.verifyStatus) { if (!this.verifyStatus) {
this.$refs.verify.show = true; this.$refs.verify.init();
} }
}, },
handleWebLogin (type) { // handleWebLogin (type) { //

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="login"> <div class="login" @click='$refs.verify.show = false'>
<div style="height:50px;"></div> <div style="height:50px;"></div>
<div class="logo-box"> <div class="logo-box">
<img <img
@ -202,7 +202,7 @@ export default {
}, },
verifyBtnClick () { verifyBtnClick () {
if (!this.verifyStatus) { if (!this.verifyStatus) {
this.$refs.verify.show = true; this.$refs.verify.init();
} }
} }
}, },

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="login"> <div class="forget-password" @click='$refs.verify.show = false'>
<div style="height:50px;"></div> <div style="height:50px;"></div>
<!-- 顶部logo --> <!-- 顶部logo -->
<div class="logo-box"> <div class="logo-box">
@ -236,7 +236,7 @@ export default {
}, },
verifyBtnClick () { verifyBtnClick () {
if (!this.verifyStatus) { if (!this.verifyStatus) {
this.$refs.verify.show = true; this.$refs.verify.init();
} }
} }
}, },
@ -248,7 +248,11 @@ export default {
} }
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.forget-password{
height: 100%;
}
.logo-box { .logo-box {
width: 600px; width: 600px;
height: 80px; height: 80px;

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="login"> <div class="login" @click='$refs.verify.show = false'>
<Row @keydown.enter.native="submitLogin" class="flex"> <Row @keydown.enter.native="submitLogin" class="flex">
<Col style="width: 368px"> <Col style="width: 368px">
<Header /> <Header />
@ -111,7 +111,7 @@ export default {
// //
this.$refs.usernameLoginForm.validate((valid) => { this.$refs.usernameLoginForm.validate((valid) => {
if (valid) { if (valid) {
this.$refs.verify.show = true; this.$refs.verify.init();
} }
}); });
}, },
@ -161,7 +161,7 @@ export default {
} }
.verify-con { .verify-con {
position: absolute; position: absolute;
top: 90px; top: 150px;
z-index: 10; z-index: 10;
left: 20px; left: 20px;
} }

View File

@ -1,5 +1,5 @@
<template> <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'}"> <div class="imgBox" :style="{width:data.originalWidth+'px',height:data.originalHeight + 'px'}">
<img :src="data.backImage" style="width:100%;height:100%" alt=""> <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=""> <img class="slider" :src="data.slidingImage" :style="{left:distance+'px',top:data.randomY+'px'}" :width="data.sliderWidth" :height="data.sliderHeight" alt="">
@ -18,7 +18,7 @@
import { getVerifyImg, postVerifyImg } from './verify.js'; import { getVerifyImg, postVerifyImg } from './verify.js';
export default { export default {
props: { props: {
verifyType: { // verifyType: {
defalut: 'LOGIN', defalut: 'LOGIN',
type: String type: String
} }
@ -38,7 +38,7 @@ export default {
distance: 0, // distance: 0, //
flag: false, // flag: false, //
downX: 0, // downX: 0, //
bgColor: 'aqua', // bgColor: '#04ad11', //
verifyText: '拖动滑块解锁' // verifyText: '拖动滑块解锁' //
}; };
}, },
@ -83,17 +83,22 @@ export default {
} }
}); });
}, },
refresh () { refresh () { //
this.flag = false; this.flag = false;
this.downX = 0; this.downX = 0;
this.distance = 0; this.distance = 0;
this.bgColor = 'aqua'; this.bgColor = '#04ad11';
this.verifyText = '拖动滑块解锁'; this.verifyText = '拖动滑块解锁';
this.getImg(); this.init();
}, },
getImg () { init () { //
getVerifyImg(this.type).then(res => { getVerifyImg(this.type).then(res => {
if (res.result) {
this.data = res.result; this.data = res.result;
this.show = true;
} else {
this.$Message.warning('请求失败请重试!')
}
}); });
} }
}, },
@ -102,11 +107,7 @@ export default {
immediate: true, immediate: true,
handler: function (v) { handler: function (v) {
this.type = v; this.type = v;
// this.refresh();
} }
},
show (v) {
if (v) this.refresh();
} }
} }
}; };
@ -140,7 +141,7 @@ export default {
} }
} }
.handle { .handle {
border: 1px solid rgb(134, 134, 134); border: 1px solid #e4dede;
margin-top: 5px; margin-top: 5px;
height: 42px; height: 42px;
background: #ddd; background: #ddd;
@ -153,7 +154,7 @@ export default {
width: 40px; width: 40px;
height: 40px; height: 40px;
opacity: 0.5; opacity: 0.5;
background: aqua; background: #04ad11;
} }
.swiper { .swiper {

View File

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

View File

@ -1,5 +1,5 @@
<template> <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'}"> <div class="imgBox" :style="{width:data.originalWidth+'px',height:data.originalHeight + 'px'}">
<img :src="data.backImage" style="width:100%;height:100%" alt=""> <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=""> <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, // distance: 0, //
flag: false, // flag: false, //
downX: 0, // downX: 0, //
bgColor: 'aqua', // bgColor: '#04ad11', //
verifyText: '拖动滑块解锁' // verifyText: '拖动滑块解锁' //
}; };
}, },
@ -83,34 +83,32 @@ export default {
} }
}); });
}, },
refresh () { refresh () { //
this.flag = false; this.flag = false;
this.downX = 0; this.downX = 0;
this.distance = 0; this.distance = 0;
this.bgColor = 'aqua'; this.bgColor = '#04ad11';
this.verifyText = '拖动滑块解锁'; this.verifyText = '拖动滑块解锁';
this.getImg(); this.init();
}, },
getImg () { init () { //
getVerifyImg(this.type).then(res => { getVerifyImg(this.type).then(res => {
if (res.result) {
this.data = res.result; this.data = res.result;
this.show = true;
} else {
this.$Message.warning('请求失败请重试!')
}
}); });
} }
}, },
created () {
// this.getImg();
},
watch: { watch: {
verifyType: { verifyType: {
immediate: true, immediate: true,
handler: function (v) { handler: function (v) {
this.type = v; this.type = v;
// this.refresh();
} }
}, },
show (v) {
if (v) this.refresh();
}
} }
}; };
</script> </script>
@ -143,7 +141,7 @@ export default {
} }
} }
.handle { .handle {
border: 1px solid rgb(134, 134, 134); border: 1px solid #e4dede;
margin-top: 5px; margin-top: 5px;
height: 42px; height: 42px;
background: #ddd; background: #ddd;
@ -156,7 +154,7 @@ export default {
width: 40px; width: 40px;
height: 40px; height: 40px;
opacity: 0.5; opacity: 0.5;
background: aqua; background: #04ad11;
} }
.swiper { .swiper {