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

fix: http.js添加公共token

parent d8f944f0
......@@ -5,6 +5,7 @@
:closeable="true"
cancel-btn
confirm-btn="确定"
@confirm="$refs.loginForm.submit()"
>
<cr-form
class="login-form"
......@@ -30,8 +31,8 @@
:rules="validOptions[1]"
>
<template v-slot:button>
<a href="javascript:;">获取验证码</a>
<span class="login-form-remain">59s</span>
<a href="javascript:;" @click="getCode" v-if="!showCount">获取验证码</a>
<span class="login-form-remain" v-else>{{ count }}s</span>
</template>
</cr-field>
</cr-form>
......@@ -40,7 +41,7 @@
<script>
import Modal from "@/components/Modal";
import { loginByPhone } from "@/api/user";
import { loginByPhone, getCaptchaSms } from "@/api/user";
import { isPhone } from "@/service/validation";
export default {
name: "LoginModal",
......@@ -49,7 +50,10 @@ export default {
},
data() {
return {
show: false,
show: true,
showCount: false,
count: "",
timer: null,
formData: {
phoneNo: "",
verifyCode: ""
......@@ -78,6 +82,24 @@ export default {
if (res.code === 0) {
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 {
url: url,
params,
headers: {
"Content-Type": "application/json"
"Content-Type": "application/json",
"x-auth-token": localStorage.getItem("mongoToken") || null
}
})
.then(res => {
......@@ -147,7 +148,8 @@ export default {
url,
data: params,
headers: {
"Content-Type": "application/json"
"Content-Type": "application/json",
"x-auth-token": localStorage.getItem("mongoToken") || null
}
})
.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