Commit 2c8e5fea by maxiaohan

登录接口调整

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