first commit
This commit is contained in:
80
src/utils/request.js
Normal file
80
src/utils/request.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import axios from 'axios'
|
||||
import { wsuri_config, name_config, name1_config, name3_config, name4_config, readFile_config, readImg_config, upload_config, upload2_config, upload3_config, uploadInvoiceScan_config, uploadInvoiceScan1_config,
|
||||
download_config, uploadPerson_config, uploadOP_config, url_config, ExcelDownLoad_config, ServerIP_config, uploadFileMachine_config,
|
||||
downloadFileMachine_config, MESUploadFile_config, MESDownloadFile_config, request_config, MESUploadFileProduct_config, MESUploadFileProject_config, MESUploadFileProcess_config } from '../../static/config'
|
||||
import Cookies from 'js-cookie'
|
||||
import store from '@/store'
|
||||
|
||||
export const wsuri = wsuri_config
|
||||
export const name = name_config
|
||||
export const name1 = name1_config
|
||||
export const name3 = name3_config
|
||||
export const name4 = name4_config
|
||||
|
||||
export const readFile = readFile_config // invoice
|
||||
export const readImg = readImg_config // delivery/MS/performancebond
|
||||
export const upload = upload_config // ContractInformationManagement
|
||||
export const upload2 = upload2_config // delivery
|
||||
export const upload3 = upload3_config // performancebond
|
||||
export const uploadInvoiceScan = uploadInvoiceScan_config // invoice
|
||||
export const uploadInvoiceScan1 = uploadInvoiceScan1_config // invoice(workshop)
|
||||
export const download = download_config // ContractInformationManagement
|
||||
export const uploadPerson = uploadPerson_config
|
||||
export const uploadOP = uploadOP_config
|
||||
export const url = url_config // 采购件入库、离线件入库
|
||||
export const ExcelDownLoad = ExcelDownLoad_config // 导出excel
|
||||
// 技术中心程序发布时要更改下面所有的IP到0段
|
||||
export const ServerIP = ServerIP_config
|
||||
export const uploadFileMachine = uploadFileMachine_config // 机床总图 发布时改成0.231
|
||||
export const downloadFileMachine = downloadFileMachine_config // 机床总图 发布时改成0.231
|
||||
export const MESUploadFile = MESUploadFile_config
|
||||
export const MESUploadFileProduct = MESUploadFileProduct_config
|
||||
export const MESDownloadFile = MESDownloadFile_config
|
||||
export const MESUploadFileProject = MESUploadFileProject_config
|
||||
export const MESUploadFileProcess = MESUploadFileProcess_config
|
||||
const service = axios.create({
|
||||
baseURL: request_config,
|
||||
timeout: 1500000 // 请求超时时间
|
||||
})
|
||||
|
||||
// && config.data.name !== '菜单系统模块_通知信息_查询数据' && config.data.name !== '菜单系统模块_首页信息_查询数据1' && config.data.name !== '菜单系统模块_首页信息_查询数据2'
|
||||
service.interceptors.request.use(config => {
|
||||
if (config.data.name !== '菜单系统模块_用户名密码_查询数据_new2' && config.data.name !== '菜单系统模块_获取角色模块_查询数据') {
|
||||
const id = Cookies.get('id')
|
||||
if (typeof (id) !== 'undefined') {
|
||||
console.log(id, 123)
|
||||
console.log(typeof (id))
|
||||
} else {
|
||||
console.log(456)
|
||||
store.dispatch('FedLogOut').then(() => {
|
||||
location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||
alert('此账号登录失效,请重新登录')
|
||||
})
|
||||
}
|
||||
}
|
||||
return config
|
||||
}, error => {
|
||||
Promise.reject(error)
|
||||
})
|
||||
|
||||
export default service
|
||||
|
||||
// async function getSession_id() {
|
||||
// const id = Cookies.get('id')
|
||||
// const session_id = Cookies.get('session_id')
|
||||
// const param = {
|
||||
// url: url,
|
||||
// method: 'post',
|
||||
// data: {
|
||||
// type: '1',
|
||||
// name: '菜单系统模块_用户sessionID_查询数据',
|
||||
// param: '人员编号=' + id
|
||||
// }
|
||||
// }
|
||||
// const res = await axios(param)
|
||||
// if (session_id !== res.data[0].session_id) {
|
||||
// return 0
|
||||
// } else {
|
||||
// return 1
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user