Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix(认证): 修复认证状态偶尔获取不到的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jul 11, 2018
1 parent 623cde9 commit 6957eea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import lstore from "@/plugins/lstore/lstore.js";

const userState = vuex.state.USERS;
const resArray = { data: [] };
const noop = () => {};

/**
* 关注 || 取关 操作
Expand Down Expand Up @@ -190,15 +191,17 @@ export function signinByAccount(payload) {
* 刷新用户信息
* @author jsonleex <[email protected]>
* @export
* @param {Function} [callback = noop]
* @returns {Promise<UserObject>}
*/
export function refreshCurrentUserInfo() {
export function refreshCurrentUserInfo(callback = noop) {
return api.get(`/user`).then(
({ data }) => {
// 保存本地
lstore.setData("H5_CUR_USER", data);
// 保存 vuex
vuex.commit("SAVE_CURRENTUSER", data);
callback();
return data;
},
err => {
Expand Down
5 changes: 3 additions & 2 deletions src/page/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ export default {
}
},
mounted() {
refreshCurrentUserInfo();
this.getUserVerifyInfo();
refreshCurrentUserInfo(() => {
this.getUserVerifyInfo();
});
this.$store.dispatch("GET_NEW_UNREAD_COUNT");
},
beforeRouteLeave(to, from, next) {
Expand Down

0 comments on commit 6957eea

Please sign in to comment.