Commit 2c8e5fea by maxiaohan

登录接口调整

parent 1bd74a6e
......@@ -16,6 +16,7 @@ const state = {
const mutations = {
SET_TOKEN: (state, token) => {
state.token = token;
console.log(state.token);
},
SET_Logs: (state, content) => {
state.logs.push(content);
......
......@@ -23,7 +23,9 @@
</ul>
</div>
</div>
<div><img src="../../assets/img/Home/exit.svg" alt="" />安全退出</div>
<div style="border: #f6a51a 1px solid" @click="logout">
<img src="../../assets/img/Home/exit.svg" alt="" />安全退出
</div>
</div>
</div>
<!-- 主体 -->
......@@ -95,8 +97,15 @@
</template>
<script>
import qs from "qs";
export default {
name: "Home",
data() {
return {
userInfo: { userName: "admin", passWord: "123456" }
};
},
methods: {
gobdrd() {
this.$router.push("/cxyrd");
......@@ -106,6 +115,15 @@ export default {
},
gozzwcj() {
this.$router.push("/AllPersonnelBaseIndex");
},
logout() {
this.$axios.post("/login/userLogout?").then(res => {
console.info(res);
if (res.data.code === "200") {
this.$message.success("退出成功!");
this.$router.push("/Login1");
}
});
}
}
};
......
......@@ -67,6 +67,7 @@ export default {
methods: {
// 登录
login(userinfo) {
let me = this;
console.info(this.userInfo);
// todo 登录请求
this.$axios
......@@ -74,9 +75,23 @@ export default {
.then(res => {
console.info(res);
if (res.data.code === "200") {
let token = res.data.token;
console.info(token);
me.$store.commit("user/SET_TOKEN", token);
// this.$store.dispatch("login", {});
this.$message.success(userinfo.userName + "登录成功!");
console.info(this.$store);
if (this.$store.state.user.token) {
this.$router.push("/Home/Home");
} else {
this.$router.replace("/login1");
}
}
})
.catch(err => {
// this.$message.error(err.message);
// this.getCaptcha();
console.info(err);
});
// "/myLoginForm?userName=" +
......@@ -111,10 +126,6 @@ export default {
// });
// }
// })
// .catch(err => {
// this.$message.error(err.message);
// this.getCaptcha();
// });
}
},
mounted() {
......
......@@ -101,6 +101,14 @@ module.exports = {
pathRewrite: {
"^/login": ""
}
},
"/logout": {
target: "http://47.92.226.24:3004/", // 登录
ws: true,
changeOrigin: true,
pathRewrite: {
"^/login": "/login"
}
}
// 阿里
// "/api": {
......
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