fix: point exp
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { wxLogin, wxGetUserProfile } from "@/utils/login.js";
|
||||
import { getPlatformProvider } from "@/utils/system";
|
||||
import { getUserInfo } from "@/api/auth.js";
|
||||
import { getUserInfo, getUserAsset } from "@/api/auth.js";
|
||||
|
||||
export const useUserStore = defineStore("user", {
|
||||
state: () => ({
|
||||
@@ -55,6 +55,28 @@ export const useUserStore = defineStore("user", {
|
||||
console.error("fetchUserInfo error", e);
|
||||
}
|
||||
},
|
||||
async fetchUserAssets() {
|
||||
try {
|
||||
const res = await getUserAsset();
|
||||
if (res) {
|
||||
const newInfo = { ...this.userInfo, ...res };
|
||||
if (res.points !== undefined) {
|
||||
newInfo.points = res.points;
|
||||
}
|
||||
|
||||
if (res.exp !== undefined) {
|
||||
newInfo.exp = res.exp;
|
||||
}
|
||||
|
||||
if (res.level !== undefined) {
|
||||
newInfo.level = res.level;
|
||||
}
|
||||
this.setUserInfo(newInfo);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("fetchUserAssets error", e);
|
||||
}
|
||||
},
|
||||
logout() {
|
||||
this.userInfo = {};
|
||||
this.token = "";
|
||||
|
||||
Reference in New Issue
Block a user