|
@@ -145,24 +145,36 @@ const actions = {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
getInfo({ commit, state }) {
|
|
getInfo({ commit, state }) {
|
|
|
|
+ // 修复:Promise executor 不应为 async,且移除未使用变量
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
- // getToken()
|
|
|
|
commit("SET_ID", state.token);
|
|
commit("SET_ID", state.token);
|
|
-
|
|
|
|
- getUser({ userid: state.token})
|
|
|
|
- .then((response) => {
|
|
|
|
- console.log(response);
|
|
|
|
- // const { data } = response
|
|
|
|
- const data = response.data[0][0];
|
|
|
|
- if (!data) {
|
|
|
|
- reject("验证失败,请重新登录。");
|
|
|
|
|
|
+ eduGet()
|
|
|
|
+ .then(response => {
|
|
|
|
+ // 此处如需使用 _token 可解开注释
|
|
|
|
+ var _token = response.data[0][0].userid;
|
|
|
|
+ if(_token != state.token){
|
|
|
|
+ commit("SET_ID", _token);
|
|
|
|
+ commit("SET_TOKEN", _token);
|
|
|
|
+ setToken(_token);
|
|
}
|
|
}
|
|
- // console.log(response)
|
|
|
|
- commit("SET_USERINFO", data);
|
|
|
|
- resolve(data);
|
|
|
|
- // resolve()
|
|
|
|
|
|
+ getUser({ userid: _token })
|
|
|
|
+ .then((response) => {
|
|
|
|
+ console.log(response);
|
|
|
|
+ // const { data } = response
|
|
|
|
+ const data = response.data[0][0];
|
|
|
|
+ if (!data) {
|
|
|
|
+ reject("验证失败,请重新登录。");
|
|
|
|
+ }
|
|
|
|
+ // console.log(response)
|
|
|
|
+ commit("SET_USERINFO", data);
|
|
|
|
+ resolve(data);
|
|
|
|
+ // resolve()
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {
|
|
|
|
+ reject(error);
|
|
|
|
+ });
|
|
})
|
|
})
|
|
- .catch((error) => {
|
|
|
|
|
|
+ .catch(error => {
|
|
reject(error);
|
|
reject(error);
|
|
});
|
|
});
|
|
});
|
|
});
|