add logout

master
paulGao 2021-11-11 18:45:53 +08:00
parent 7ac4010910
commit 5614414185
7 changed files with 49 additions and 20 deletions

View File

@ -57,3 +57,12 @@ export function editPwd (params) {
data: params
})
}
// 获取密码状态
export function logout () {
return request({
url: '/buyer/members/logout',
method: Method.POST,
needToken: true
})
}

View File

@ -86,6 +86,7 @@
<script>
import storage from '@/plugins/storage.js';
import { cartGoodsAll } from '@/api/cart.js';
import { logout } from '@/api/account.js';
export default {
name: 'M-Header',
created () {
@ -120,12 +121,14 @@ export default {
window.open(url.href, '_blank');
},
signOutFun () { // 退
storage.removeItem('accessToken');
storage.removeItem('refreshToken');
storage.removeItem('userInfo');
storage.removeItem('cartNum');
this.$store.commit('SET_CARTNUM', 0)
this.$router.push('/login');
logout().then(res => {
storage.removeItem('accessToken');
storage.removeItem('refreshToken');
storage.removeItem('userInfo');
storage.removeItem('cartNum');
this.$store.commit('SET_CARTNUM', 0)
this.$router.push('/login');
});
},
goUserCenter (path) {
//

View File

@ -49,6 +49,12 @@ export const getNoticePage = (params) => {
export const login = (params) => {
return getRequestWithNoToken("/user/login", params);
};
// 登出
export const logout = () => {
return postRequest("/user/logout");
};
// 刷新token
export const handleRefreshToken = (token) => {
return getRequestWithNoToken(`/user/refresh/${token}`);

View File

@ -60,7 +60,7 @@ import messageTip from "./main-components/message-tip.vue";
import circleLoading from "@/views/my-components/lili/circle-loading.vue";
import Cookies from "js-cookie";
import util from "@/libs/util.js";
import { getNoticePage } from "@/api/index";
import { getNoticePage,logout } from "@/api/index";
var client;
export default {
@ -131,11 +131,13 @@ export default {
}
// 退
else if (name === "loginOut") {
this.$store.commit("logout", this);
this.$store.commit('setAdded', false);
this.setStore("accessToken", "");
this.setStore("refreshToken", "");
this.$router.push({ path: "/login" });
logout().then(res => {
this.$store.commit("logout", this);
this.$store.commit('setAdded', false);
this.setStore("accessToken", "");
this.setStore("refreshToken", "");
this.$router.push({ path: "/login" });
})
}
},
//

View File

@ -109,7 +109,7 @@ export default {
modalType: 0, //
modalVisible: false, //
modalTitle: "", //
treeDataDefault:"",
treeDataDefault: [],
searchForm: {
//
pageNumber: 1, //
@ -352,7 +352,7 @@ export default {
}
}
});
this.total = this.data.length;
this.total = this.data?.length;
this.loading = false;
},
//

View File

@ -31,6 +31,12 @@ export const getSellerHomeData = params => {
export const login = params => {
return postRequestWithNoToken("/login/userLogin", params);
};
// 登出
export const logout = () => {
return postRequest("/login/logout");
};
// 获取用户登录信息
export const userInfo = params => {
return getRequest("/user/info", params);

View File

@ -58,6 +58,7 @@ import tagsPageOpened from "./main-components/tags-page-opened.vue";
import circleLoading from "@/views/my-components/lili/circle-loading.vue";
import Cookies from "js-cookie";
import util from "@/libs/util.js";
import { logout } from "@/api/index";
export default {
components: {
@ -120,12 +121,14 @@ export default {
name: "change_pass",
});
} else if (name == "loginOut") {
Cookies.set("accessToken", "");
this.$store.commit("logout", this);
this.$store.commit("clearOpenedSubmenu");
this.setStore("accessToken", "");
this.setStore("refreshToken", "");
this.$router.push({ path: "/login" });
logout().then(res => {
Cookies.set("accessToken", "");
this.$store.commit("logout", this);
this.$store.commit("clearOpenedSubmenu");
this.setStore("accessToken", "");
this.setStore("refreshToken", "");
this.$router.push({ path: "/login" });
})
}
},
//