| | |
| | | import axios from 'axios' |
| | | import qs from 'qs' |
| | | |
| | | axios.defaults.crossDomain = true |
| | | axios.defaults.headers.common['token'] = 'token' |
| | | // axios.defaults.headers.common['token'] = 'token' |
| | | axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8' |
| | | axios.defaults.withCredentials = true |
| | | |
| | | axios.interceptors.request.use((config) => { |
| | | config.url = config.url || '/dostar' |
| | | config.method = 'post' |
| | | config.data = config.data || {} |
| | | if (config.url !== '/login') { |
| | | config.data.userid = sessionStorage.getItem('UserID') || '' |
| | | } |
| | | config.headers.token = sessionStorage.getItem('TOKEN') || '' |
| | | if (config.url.includes('LoginAndRedirect')) { |
| | | config.data = qs.stringify(config.data) |
| | | } else { |
| | | config.data = JSON.stringify(config.data) |
| | | } |
| | | |
| | | return config |
| | | }, (error) => { |
| | | return Promise.reject(error) |
| | |
| | | class Api { |
| | | constructor() { |
| | | if (process.env.NODE_ENV === 'production') { |
| | | axios.defaults.baseURL = document.location.origin + '/' + window.Glob.Service |
| | | axios.defaults.baseURL = document.location.origin + '/MKWMS' |
| | | } else { |
| | | axios.defaults.baseURL = 'http://127.0.0.1:8888' |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 系统授权 |
| | | */ |
| | | systemauth (appId, timestamp) { |
| | | return axios({ |
| | | // url: 'http://minkesoft.com/mksepc/webapi/dostar', |
| | | url: '/mksepc', |
| | | data: { |
| | | func: 'sEmpowerCloud_Get_LinkUrl', |
| | | userid: '', |
| | | AppID: appId, |
| | | TimeStamp: timestamp |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // /** |
| | | // * @description 登录系统 |
| | | // */ |
| | | // loginsystem (username, password) { |
| | | // return axios({ |
| | | // url: 'http://qingqiumarket.cn/MKWMS/zh-CN/Home/LoginAndRedirect', |
| | | // data: { |
| | | // Username: username, |
| | | // Password: password |
| | | // } |
| | | // }) |
| | | // } |
| | | |
| | | /** |
| | | * @description 登录系统 |
| | |
| | | return axios({ |
| | | url: '/dostar', |
| | | data: { |
| | | func: 'logout' |
| | | func: 'logout', |
| | | userid: sessionStorage.getItem('UserID') |
| | | } |
| | | }) |
| | | } |
| | |
| | | url: '/dostar', |
| | | data: { |
| | | func: 'ResetPassword', |
| | | userid: sessionStorage.getItem('UserID'), |
| | | OriginPwd: originpwd, |
| | | NewPwd: newpwd |
| | | } |
| | |
| | | return axios({ |
| | | url: '/dostar', |
| | | data: { |
| | | func: 'GetTopMenus' |
| | | func: 'GetTopMenus', |
| | | userid: sessionStorage.getItem('UserID') |
| | | } |
| | | }) |
| | | } |
| | |
| | | url: '/dostar', |
| | | data: { |
| | | func: 'GetSubMenus', |
| | | userid: sessionStorage.getItem('UserID'), |
| | | ParentID: menuId |
| | | } |
| | | }) |
| | |
| | | url: '/dostar', |
| | | data: { |
| | | func: 'GetMainConfigs', |
| | | userid: sessionStorage.getItem('UserID'), |
| | | MenuNo: MenuNo |
| | | } |
| | | }) |
| | |
| | | url: '/dostar', |
| | | data: { |
| | | func: 'GetMainData', |
| | | userid: sessionStorage.getItem('UserID'), |
| | | MenuNo: MenuNo, |
| | | PageIndex: pageIndex, |
| | | PageSize: pageSize, |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取页面列表数据 |
| | | * @param {String} param 提交参数 |
| | | */ |
| | | setActionSubmit (param) { |
| | | param.userid = sessionStorage.getItem('UserID') |
| | | return axios({ |
| | | url: '/dostar', |
| | | data: param |
| | | }) |
| | | } |
| | | } |
| | | |
| | | export default new Api() |