|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="auth-card-body">
|
|
|
<h2 id="auth-card-title">{{ cardTitle }} </h2>
|
|
|
- <el-form id="auth-card-form" :model="cardForm" :rules="cardRuleForm">
|
|
|
+ <el-form id="auth-card-form" :model="cardForm" :rules="cardRuleForm" ref="cardFormRef">
|
|
|
|
|
|
<el-form-item v-if="cardType==='login'" class="auth-card-form-item" prop="phone">
|
|
|
<el-input v-model="cardForm.phone" autofocus clearable oninput="value=value.replace(/[^\d]/g,'')" placeholder="请输入手机号">
|
|
|
@@ -53,7 +53,7 @@
|
|
|
</div>
|
|
|
|
|
|
<el-form-item v-if="cardType==='login'" class="auth-card-form-item">
|
|
|
- <SlideVerifier is-lock @change="handleSlideVerifier"/>
|
|
|
+ <SlideVerifier id="auth-card-slide-verifier" is-lock @change="handleSlideVerifier"/>
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item class="auth-card-form-item">
|
|
|
@@ -74,7 +74,7 @@ import SlideVerifier from "@/views/AuthPage/components/SlideVerifier";
|
|
|
|
|
|
export default {
|
|
|
name: "AuthCard",
|
|
|
- components: { SlideVerifier, Lock, Phone },
|
|
|
+ components: { SlideVerifier, Lock, Phone, },
|
|
|
data() {
|
|
|
return {
|
|
|
cardType: "login",
|
|
|
@@ -157,9 +157,11 @@ export default {
|
|
|
},
|
|
|
|
|
|
toResetType() {
|
|
|
+ this.$refs.cardFormRef.resetFields();
|
|
|
this.cardType = "reset";
|
|
|
},
|
|
|
toOtherType() {
|
|
|
+ this.$refs.cardFormRef.resetFields();
|
|
|
if (this.cardType === "login") {
|
|
|
this.cardType = "register";
|
|
|
} else if (this.cardType === "register") {
|
|
|
@@ -170,21 +172,32 @@ export default {
|
|
|
},
|
|
|
|
|
|
handleLogin() {
|
|
|
- if (this.cardVerified) {
|
|
|
- const params = {
|
|
|
- phone: this.phone,
|
|
|
- password: this.password
|
|
|
- };
|
|
|
- this.$apis.loginAPI(params)
|
|
|
- .then((res) => {
|
|
|
- console.log(res);
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
- console.log(e);
|
|
|
- });
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
+ const thatForm = this.$refs.cardFormRef;
|
|
|
+ thatForm.validateField("phone", v1 => {
|
|
|
+ thatForm.validateField("password", v2 => {
|
|
|
+ if (!v1 && !v2) {
|
|
|
+ if (this.cardVerified) {
|
|
|
+ const params = {
|
|
|
+ phone: this.cardForm.phone,
|
|
|
+ password: this.cardForm.password
|
|
|
+ };
|
|
|
+ this.$apis.loginAPI(params)
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ let elem = document.getElementById("auth-card-slide-verifier");
|
|
|
+ elem.classList.add("shake");
|
|
|
+ setTimeout(() => {
|
|
|
+ elem.classList.remove("shake");
|
|
|
+ }, 800);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
handleRegister() {
|
|
|
|