2024-05-06 16:11:42 +08:00
|
|
|
|
import config from "@/config";
|
|
|
|
|
import storage from "@/utils/storage";
|
|
|
|
|
import constant from "@/utils/constant";
|
|
|
|
|
import { getUserInfo } from "@/api/login";
|
|
|
|
|
import { getToken, setToken, removeToken } from "@/utils/auth";
|
|
|
|
|
import defaultAvatar from "@/static/images/profile.jpg";
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
const baseUrl = config.baseUrl;
|
|
|
|
|
|
2024-06-09 15:37:59 +08:00
|
|
|
|
const userInfo = {
|
2024-05-06 16:11:42 +08:00
|
|
|
|
state: {
|
|
|
|
|
birthday: storage.get(constant.birthday) /** 生日 */,
|
|
|
|
|
doingsStatus: storage.get(constant.doingsStatus) /** 活动发布权限(0没有,1有) */,
|
|
|
|
|
infoName: storage.get(constant.infoName) /** 实名信息名字 */,
|
|
|
|
|
infoSchool: storage.get(constant.infoSchool) /** 实名信息学校 */,
|
|
|
|
|
infoDepartment: storage.get(constant.infoDepartment) /** 实名信息系别 */,
|
|
|
|
|
infoGrade: storage.get(constant.infoGrade) /** 实名信息年级 */,
|
|
|
|
|
infoCode: storage.get(constant.infoCode) /** 实名信息学号 */,
|
|
|
|
|
infoDocument: storage.get(constant.infoDocument) /** 实名信息证件图片 */,
|
|
|
|
|
auditInfo: storage.get(constant.auditInfo) /** 审核状态(0已通过学生证,1通过身份证,2都通过,3审核中) */,
|
|
|
|
|
infoRank: storage.get(constant.infoRank) /** 用户等级 */,
|
|
|
|
|
infoCoin: storage.get(constant.infoCoin) /** 虚拟币数量 */,
|
|
|
|
|
infoActive: storage.get(constant.infoActive) /** 活跃度 */,
|
2024-06-09 15:37:59 +08:00
|
|
|
|
infoAssist: storage.get(constant.infoAssist) /** 获赞 */,
|
|
|
|
|
followCount: storage.get(constant.followCount) /** 关注 */,
|
|
|
|
|
fanCount: storage.get(constant.fanCount) /** 粉丝 */,
|
|
|
|
|
remark: storage.get(constant.remark) /** 签名 */,
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mutations: {
|
|
|
|
|
SET_BIRTHDAY: (state, birthday) => {
|
|
|
|
|
state.birthday = birthday;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.birthday, birthday);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_doingsStatus: (state, doingsStatus) => {
|
|
|
|
|
state.doingsStatus = doingsStatus;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.doingsStatus, doingsStatus);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoName: (state, infoName) => {
|
|
|
|
|
state.infoName = infoName;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoName, infoName);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoSchool: (state, infoSchool) => {
|
|
|
|
|
state.infoSchool = infoSchool;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoSchool, infoSchool);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoDepartment: (state, infoDepartment) => {
|
|
|
|
|
state.infoDepartment = infoDepartment;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoDepartment, infoDepartment);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoGrade: (state, infoGrade) => {
|
|
|
|
|
state.infoGrade = infoGrade;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoGrade, infoGrade);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoCode: (state, infoCode) => {
|
|
|
|
|
state.infoCode = infoCode;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoCode, infoCode);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoDocument: (state, infoDocument) => {
|
|
|
|
|
state.infoDocument = infoDocument;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoDocument, infoDocument);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_auditInfo: (state, auditInfo) => {
|
|
|
|
|
state.auditInfo = auditInfo;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.auditInfo, auditInfo);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoRank: (state, infoRank) => {
|
|
|
|
|
state.infoRank = infoRank;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoRank, infoRank);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoCoin: (state, infoCoin) => {
|
|
|
|
|
state.infoCoin = infoCoin;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoCoin, infoCoin);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
SET_infoActive: (state, infoActive) => {
|
|
|
|
|
state.infoActive = infoActive;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.infoActive, infoActive);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
2024-06-09 15:37:59 +08:00
|
|
|
|
|
|
|
|
|
SET_infoAssist: (state, infoAssist) => {
|
|
|
|
|
state.infoAssist = infoAssist;
|
|
|
|
|
storage.set(constant.infoAssist, infoAssist);
|
|
|
|
|
},
|
|
|
|
|
SET_followCount: (state, followCount) => {
|
|
|
|
|
state.followCount = followCount;
|
|
|
|
|
storage.set(constant.followCount, followCount);
|
|
|
|
|
},
|
|
|
|
|
SET_fanCount: (state, fanCount) => {
|
|
|
|
|
state.fanCount = fanCount;
|
|
|
|
|
storage.set(constant.fanCount, fanCount);
|
|
|
|
|
},
|
|
|
|
|
|
2024-05-06 16:11:42 +08:00
|
|
|
|
SET_remark: (state, remark) => {
|
|
|
|
|
state.remark = remark;
|
2024-06-09 15:37:59 +08:00
|
|
|
|
storage.set(constant.remark, remark);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
GetUserInfo({ commit, state }) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
getUserInfo()
|
|
|
|
|
.then((res) => {
|
|
|
|
|
const userInfo = res.data;
|
|
|
|
|
const infoDocument = ref([]);
|
2024-05-07 21:32:21 +08:00
|
|
|
|
infoDocument.value =
|
2024-05-06 16:11:42 +08:00
|
|
|
|
userInfo == null ||
|
|
|
|
|
userInfo.infoDocument == "" ||
|
|
|
|
|
userInfo.infoDocument == null
|
|
|
|
|
? defaultAvatar
|
|
|
|
|
: userInfo.infoDocument;
|
|
|
|
|
if (userInfo) {
|
2024-06-09 15:37:59 +08:00
|
|
|
|
console.log("userInfo:",userInfo);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
commit("SET_BIRTHDAY", userInfo.birthday);
|
|
|
|
|
commit("SET_doingsStatus", userInfo.doingsStatus);
|
|
|
|
|
commit("SET_infoName", userInfo.infoName);
|
|
|
|
|
commit("SET_infoSchool", userInfo.infoSchool);
|
|
|
|
|
commit("SET_infoDepartment", userInfo.infoDepartment);
|
|
|
|
|
commit("SET_infoGrade", userInfo.infoGrade);
|
|
|
|
|
commit("SET_infoCode", userInfo.infoCode);
|
|
|
|
|
commit("SET_infoDocument", userInfo.infoDocument);
|
|
|
|
|
commit("SET_auditInfo", userInfo.auditInfo);
|
|
|
|
|
commit("SET_infoRank", userInfo.infoRank);
|
|
|
|
|
commit("SET_infoCoin", userInfo.infoCoin);
|
|
|
|
|
commit("SET_infoActive", userInfo.infoActive);
|
2024-06-09 15:37:59 +08:00
|
|
|
|
commit("SET_infoAssist", userInfo.infoAssist);
|
|
|
|
|
commit("SET_followCount", userInfo.followCount);
|
|
|
|
|
commit("SET_fanCount", userInfo.fanCount);
|
2024-05-06 16:11:42 +08:00
|
|
|
|
commit("SET_remark", userInfo.remark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolve(res);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
reject(error);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-09 15:37:59 +08:00
|
|
|
|
export default userInfo;
|