import globalFn from '@/util/utils' import { http } from '@/api/APIindex' import nozzle from "@/util/interface" import { setSession, loginTime } from '../../util/item' const common = { namespaced: true, state: { menu:'', }, mutations: { //设置菜单 SET_MENU:(state, menu)=>{ state.menu = menu; } }, actions: { //获取所有部门 getUserMenu({ commit }){ return new Promise((resolve, reject) => { http.post(nozzle.menuGetCurrentUserMenu,{}).then(res =>{ if(res.data.code === 1 || res.data.code === 200) { // 登录状态设置 setSession("logins", "true"); // 用户在线状态计时 loginTime(); // this.$router.push("/welcome"); commit('SET_MENU',res.data.data); sessionStorage.setItem("powerHandle", res.data.data); resolve(res); }else{ reject() // console.log(888); } }).catch(e =>{ reject(e) // console.log(999,e); }) }) } } } export default common