Commit cda1196e authored by 郭志伟's avatar 郭志伟

fix: http.js添加公共token

parent d8f944f0
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:closeable="true" :closeable="true"
cancel-btn cancel-btn
confirm-btn="确定" confirm-btn="确定"
@confirm="$refs.loginForm.submit()"
> >
<cr-form <cr-form
class="login-form" class="login-form"
...@@ -30,8 +31,8 @@ ...@@ -30,8 +31,8 @@
:rules="validOptions[1]" :rules="validOptions[1]"
> >
<template v-slot:button> <template v-slot:button>
<a href="javascript:;">获取验证码</a> <a href="javascript:;" @click="getCode" v-if="!showCount">获取验证码</a>
<span class="login-form-remain">59s</span> <span class="login-form-remain" v-else>{{ count }}s</span>
</template> </template>
</cr-field> </cr-field>
</cr-form> </cr-form>
...@@ -40,7 +41,7 @@ ...@@ -40,7 +41,7 @@
<script> <script>
import Modal from "@/components/Modal"; import Modal from "@/components/Modal";
import { loginByPhone } from "@/api/user"; import { loginByPhone, getCaptchaSms } from "@/api/user";
import { isPhone } from "@/service/validation"; import { isPhone } from "@/service/validation";
export default { export default {
name: "LoginModal", name: "LoginModal",
...@@ -49,7 +50,10 @@ export default { ...@@ -49,7 +50,10 @@ export default {
}, },
data() { data() {
return { return {
show: false, show: true,
showCount: false,
count: "",
timer: null,
formData: { formData: {
phoneNo: "", phoneNo: "",
verifyCode: "" verifyCode: ""
...@@ -78,6 +82,24 @@ export default { ...@@ -78,6 +82,24 @@ export default {
if (res.code === 0) { if (res.code === 0) {
this.$notify("登录成功"); this.$notify("登录成功");
} }
},
async getCode() {
const TIME_COUNT = 60;
const { phoneNo } = this.formData;
const res = await getCaptchaSms({ phoneNo });
if (res.code === "0" && !this.timer) {
this.count = TIME_COUNT;
this.showCount = true;
this.timer = setInterval(() => {
if (this.count > 0 && this.count <= TIME_COUNT) {
this.count--;
} else {
this.showCount = false;
clearInterval(this.timer);
this.timer = null;
}
}, 1000);
}
} }
} }
}; };
......
...@@ -128,7 +128,8 @@ export default { ...@@ -128,7 +128,8 @@ export default {
url: url, url: url,
params, params,
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json",
"x-auth-token": localStorage.getItem("mongoToken") || null
} }
}) })
.then(res => { .then(res => {
...@@ -147,7 +148,8 @@ export default { ...@@ -147,7 +148,8 @@ export default {
url, url,
data: params, data: params,
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json",
"x-auth-token": localStorage.getItem("mongoToken") || null
} }
}) })
.then(res => { .then(res => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment