feat:联调用户接口
This commit is contained in:
parent
a86436fd85
commit
857f2d377c
|
|
@ -5,10 +5,16 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed } from "vue";
|
||||
import {defineComponent, computed, onBeforeMount} from "vue";
|
||||
import store from "@/store";
|
||||
export default defineComponent({
|
||||
name: "App",
|
||||
setup() {
|
||||
onBeforeMount(()=>{
|
||||
if(store.state.user.info){
|
||||
store.dispatch("user/getInfo", { user_info:store.state.user.info.id});
|
||||
}
|
||||
})
|
||||
return {
|
||||
};
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,11 +2,25 @@ import {loginApi, getInfoApi, loginOutApi, login} from "@/api/user";
|
|||
import { ActionContext } from "vuex";
|
||||
import {logout, userInfo} from "@/api/work";
|
||||
|
||||
export interface Info{
|
||||
abandon_flag:number,
|
||||
active:number,
|
||||
admin:number,
|
||||
created_at:Date,
|
||||
email:string,
|
||||
email_auth:number,
|
||||
id:number,
|
||||
name:string,
|
||||
nickname:string,
|
||||
phone:string,
|
||||
phone_auth:number,
|
||||
updated_at:Date
|
||||
}
|
||||
export interface userState {
|
||||
token: string;
|
||||
info: object;
|
||||
info: Info;
|
||||
}
|
||||
const state = (): userState => ({
|
||||
const state = (): userState => <userState>({
|
||||
token: "", // 登录token
|
||||
info: {}, // 用户信息
|
||||
});
|
||||
|
|
@ -24,7 +38,7 @@ const mutations = {
|
|||
tokenChange(state: userState, token: string) {
|
||||
state.token = token;
|
||||
},
|
||||
infoChange(state: userState, info: object) {
|
||||
infoChange(state: userState, info: Info) {
|
||||
state.info = info;
|
||||
},
|
||||
};
|
||||
|
|
@ -55,8 +69,8 @@ const actions = {
|
|||
getInfo({ commit,state }: ActionContext<userState, userState>, params: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
userInfo(params.user_info).then((res) => {
|
||||
commit("infoChange", res.data.info);
|
||||
resolve(res.data.info);
|
||||
commit("infoChange", res.data);
|
||||
resolve(res.data);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
@ -72,7 +86,6 @@ const actions = {
|
|||
sessionStorage.removeItem("vuex");
|
||||
location.reload();
|
||||
});
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue