diff --git a/src/components/Menu.vue b/src/components/Menu.vue index d7ae812c800e6c7beba6d779a2a9d3985e141159..0700a86ade4de16592f4ce0154e986a284daf092 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -1,99 +1,50 @@ + \ No newline at end of file diff --git a/src/utils/menu.js b/src/utils/menu.js new file mode 100644 index 0000000000000000000000000000000000000000..f306451961dcdee9dd087aa22a0e9e48ff433835 --- /dev/null +++ b/src/utils/menu.js @@ -0,0 +1,4 @@ +// import axios from 'axios'; +import { req ,up} from './request'; +//获取个人菜单 +export const getMyMenu = (params) => { return req("post", "/api/menu/queryUserPowerMenu", params) }; \ No newline at end of file diff --git a/src/utils/payMG.js b/src/utils/payMG.js new file mode 100644 index 0000000000000000000000000000000000000000..ba0808261e1ea828337dc03bfa3361de29aa3071 --- /dev/null +++ b/src/utils/payMG.js @@ -0,0 +1,7 @@ +// import axios from 'axios'; +import { req ,up} from './request'; + +export const login = (params) => { return req("post", "/api/log/login", params) }; + +//分页获取个人课程列表 +export const saveRoom = (params) => { return req("post", "/api/room/save", params)}; \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js index 4f2c92c0fc1575e94d4d688c09ba9e12af034820..26acba98251d52039f893e1731298a32ae3bfd52 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,138 +1,35 @@ import axios from 'axios'; -import { - Message,Loading -} from 'element-ui'; -import store from '@/store' -import router from '@/router/index.js' - -import { MyLoading } from "@/components/loading"; - - - -//给axios添加拦截器 请求拦截器、响应拦截 -//给axios请求前设置下信息 -let loadId = null; -// Add a request interceptor -axios.interceptors.request.use(function(config) { - // Do something before request is sent - //console.log("config",config) - //从store对象中获取 token - //console.log("store.getters.getToken",store.getters.getToken) - if (store.getters.getToken) { - config.headers["token"] = store.getters.getToken - } - - //请求网络 打开loading - // loadId = Loading.service( - // { fullscreen: true } - // ); - - MyLoading.service() - return config; -}); - - -axios.interceptors.response.use( - response => { - //关闭loading - // loadId.close(); - MyLoading.close() - return response - }, - //接口错误状态处理,也就是说无响应时的处理 - error => { - return Promise.reject(error.response.status) // 返回接口返回的错误信息 - } -); - -let http = { - post(url, callback, params = {}) { - // console.log("params:",params) - let urlSeachParames = new URLSearchParams(); - for (let key in params) { - - // console.log("key:", key) - urlSeachParames.append(key, params[key]) - } - - axios.post(url, urlSeachParames). - then((ret) => { - //axios的状态 - if (ret.status == 200) { //网络请求是通的,axios的状态 - let response = ret.data; //响应结果 - let { - code, - message, - obj - } = response; - if (code == 200) { - callback(obj) - }else if(code==401){ - Message.error({ - message: "登录超时,请重新登录", - duration: 2000, - offset: 200 - }) - router.push({path:'/login'}) - }else if(code==404){ - Message.error({ - message: message||"请求的路径不正确", - duration: 2000, - offset: 200 - }) - } else { - - alert("出错了:11111" + message) - } - }else{ - - } - - }) - }, - get(url, callback, params = {}) { - //'/api/channel?_type=queryById&id='+this.id - axios.get(url, { - params: params - }). - then((ret) => { - // console.log("ret", ret); - if (ret.status == 200) { //网络请求是通的,axios的状态 - let response = ret.data; //响应结果 CommonResult - // console.log("response", response) - let { - code, - message, - obj - } = response; - if (code == 200) { //Controller返回的请求状态是200 - // console.log("obj", obj) - callback(obj); - } else if(code==401){ - Message.error({ - message: "登录超时,请重新登录", - duration: 2000, - offset: 200 - }) - router.push({path:'/login'}) - }else if(code==404){ - Message.error({ - message: message||"请求的路径不正确", - duration: 2000, - offset: 200 - }) - }else { //401 404 - // alert("出错了:"+msg) - Message.error({ - message: message, - duration: 2000, - offset: 200 - }) - } - } - - }) - } -} - -export default http +import store from "../store"; +// 通用方法 +const req = (method, url, params) => { + return axios({ + method: method, + url: url, + headers: { + 'Content-Type': 'application/json;charset=utf-8', + token:store.getters.getToken + }, + data: params, + traditional: true, + }) +}; + +// 通用方法 +const up = (method, url, params) => { + return axios({ + method: method, + url: url, + headers: { + // 'Content-Type': 'multipart/form-data', + token:localStorage.getItem("mytoken") + }, + data: params, + traditional: true, + }) +}; + + +export { + up, + req +} \ No newline at end of file diff --git a/src/views/login.vue b/src/views/login.vue index e603f1021b5ffc3755fd908f96f57ce467ddacd5..c057e808f2dca1e83a0510a1e8eebd565247a418 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -1,125 +1,109 @@ + +``` \ No newline at end of file diff --git a/src/views/menu/index.vue b/src/views/menu/index.vue index ec3b6f2dcd94dc55ca24a00390f361cbd547be58..ea1c03af17d5c8b9b50670b3b6ae78012b2c07e0 100644 --- a/src/views/menu/index.vue +++ b/src/views/menu/index.vue @@ -1,152 +1,153 @@ - - - - - \ No newline at end of file + \ No newline at end of file