master
Yer 2024-03-07 15:48:22 +08:00
parent 3cefb40ccb
commit 82e047c797
1 changed files with 38 additions and 22 deletions

View File

@ -1,4 +1,4 @@
<template> <template>
<div class="login" @click="$refs.verify.show = false"> <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">
@ -9,12 +9,12 @@
<!--账号密码登录--> <!--账号密码登录-->
<Form ref="usernameLoginForm" :model="form" :rules="rules" class="form"> <Form ref="usernameLoginForm" :model="form" :rules="rules" class="form">
<FormItem prop="username"> <FormItem prop="username">
<Input v-model="form.username" prefix="ios-contact" size="large" clearable placeholder="请输入用户名" <Input v-model="form.username" prefix="ios-contact" clearable placeholder="请输入用户名"
autocomplete="off" /> autocomplete="off" />
</FormItem> </FormItem>
<FormItem prop="password"> <FormItem prop="password">
<Input type="password" v-model="form.password" prefix="ios-lock" size="large" password placeholder="请输入密码" <Input type="password" v-model="form.password" prefix="ios-lock" password
autocomplete="off" /> placeholder="请输入密码" autocomplete="off" />
</FormItem> </FormItem>
</Form> </Form>
<div class="register"> <div class="register">
@ -25,21 +25,21 @@
<!-- 验证码登录 --> <!-- 验证码登录 -->
<Form ref="formSms" :model="formSms" :rules="ruleInline" @click.self='$refs.verify.show = false'> <Form ref="formSms" :model="formSms" :rules="ruleInline" @click.self='$refs.verify.show = false'>
<FormItem prop="mobile"> <FormItem prop="mobile">
<i-input type="text" v-model="formSms.mobile" clearable placeholder="手机号"> <i-input type="text" maxlength="11" v-model="formSms.mobile" clearable placeholder="手机号">
<Icon type="md-lock" slot="prepend"></Icon> <Icon type="md-lock" slot="prepend"></Icon>
</i-input> </i-input>
</FormItem> </FormItem>
<FormItem prop="code"> <FormItem prop="code">
<i-input type="text" v-model="formSms.code" placeholder="手机验证码"> <i-input type="text" v-model="formSms.code" placeholder="手机验证码">
<Icon type="ios-text-outline" style="font-weight: bold" slot="prepend" /> <Icon type="ios-text-outline" style="font-weight: bold" slot="prepend" />
<Button slot="append" @click="sendCode">{{ codeMsg }}</Button> <Button slot="append" @click="sendCode" :loading="sendCodeLoading">{{ codeMsg }}</Button>
</i-input> </i-input>
</FormItem> </FormItem>
<FormItem> <FormItem>
<Button @click.stop="verifyBtnClick" long :type="verifyStatus ? 'success' : 'default'">{{ verifyStatus ? <!-- <Button @click.stop="verifyBtnClick" long :type="verifyStatus ? 'success' : 'default'">{{ verifyStatus ?
'验证通过' : '验证通过' :
'点击完成安全验证' }} '点击完成安全验证' }}
</Button> </Button> -->
</FormItem> </FormItem>
</Form> </Form>
</Tab-pane> </Tab-pane>
@ -60,14 +60,13 @@
</template> </template>
<script> <script>
import { getCurrentPermissionList } from "@/api/index";
import { login, userMsg, storeSmsLogin } from "@/api/index";
import { sendSms } from "@/api/common.js"; import { sendSms } from "@/api/common.js";
import Cookies from "js-cookie"; import { login, storeSmsLogin, userMsg } from "@/api/index";
import Header from "@/views/main-components/header";
import Footer from "@/views/main-components/footer";
import util from "@/libs/util.js"; import util from "@/libs/util.js";
import Footer from "@/views/main-components/footer";
import Header from "@/views/main-components/header";
import verify from "@/views/my-components/verify"; import verify from "@/views/my-components/verify";
import Cookies from "js-cookie";
export default { export default {
components: { components: {
Header, Header,
@ -77,6 +76,7 @@ export default {
data() { data() {
return { return {
saveLogin: true, // saveLogin: true, //
sendCodeLoading:false,
loading: false, // loading: false, //
verifyStatus: false, // verifyStatus: false, //
time: 60, // time: 60, //
@ -171,26 +171,30 @@ export default {
}, },
// //
sendCode() { sendCode() {
if (this.formSms.mobile === "") {
this.$Message.warning("请先填写手机号");
return;
}
if (!this.verifyStatus) {
this.$refs.verify.init();
return
}
if (this.time === 60) { if (this.time === 60) {
if (this.formSms.mobile === "") { this.sendCodeLoading = true
this.$Message.warning("请先填写手机号");
return;
}
if (!this.verifyStatus) {
this.$Message.warning("请先完成安全验证");
return;
}
let params = { let params = {
mobile: this.formSms.mobile, mobile: this.formSms.mobile,
verificationEnums: "LOGIN", verificationEnums: "LOGIN",
}; };
sendSms(params).then((res) => { sendSms(params).then((res) => {
if (res.success) { if (res.success) {
this.$Message.success("验证码发送成功"); this.$Message.success("验证码发送成功");
let that = this; let that = this;
this.interval = setInterval(() => { this.interval = setInterval(() => {
// this.sendCodeLoading = false
that.time--; that.time--;
if (that.time === 0) { if (that.time === 0) {
this.sendCodeLoading = false
that.time = 60; that.time = 60;
that.codeMsg = "重新发送"; that.codeMsg = "重新发送";
that.verifyStatus = false; that.verifyStatus = false;
@ -202,6 +206,8 @@ export default {
} else { } else {
this.$Message.warning(res.message); this.$Message.warning(res.message);
} }
}).catch(() => {
this.sendCodeLoading = false
}); });
} }
}, },
@ -216,10 +222,16 @@ export default {
} else if (this.loginType == 'mobileLogin') { } else if (this.loginType == 'mobileLogin') {
this.$refs['formSms'].validate((valid) => { this.$refs['formSms'].validate((valid) => {
if (valid) { if (valid) {
this.loading = true;
storeSmsLogin(this.formSms).then(res => { storeSmsLogin(this.formSms).then(res => {
this.loading = false;
if (res.success) { if (res.success) {
this.afterLogin(res) this.afterLogin(res)
} }
}).catch(() => {
this.loading = false;
}) })
} }
}) })
@ -244,8 +256,12 @@ export default {
.catch(() => { .catch(() => {
this.loading = false; this.loading = false;
}); });
} else {
this.verifyStatus = true;
this.sendCode()
} }
this.verifyStatus = true;
this.$refs.verify.show = false; this.$refs.verify.show = false;
}, },