diff --git a/package-lock.json b/package-lock.json index 1303ded..8f42282 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2366,8 +2366,8 @@ }, "axios": { "version": "0.18.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz", - "integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==", + "resolved": "https://registry.npmmirror.com/axios/download/axios-0.18.1.tgz?cache=0&sync_timestamp=1634053173003&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Faxios%2Fdownload%2Faxios-0.18.1.tgz", + "integrity": "sha1-/z8N4ue10YDnV62YAA8Qgbh7zqM=", "requires": { "follow-redirects": "1.5.10", "is-buffer": "^2.0.2" @@ -7621,9 +7621,9 @@ } }, "is-buffer": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", - "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" + "version": "2.0.5", + "resolved": "https://registry.npm.taobao.org/is-buffer/download/is-buffer-2.0.5.tgz?cache=0&sync_timestamp=1604429452232&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-buffer%2Fdownload%2Fis-buffer-2.0.5.tgz", + "integrity": "sha1-68JS5ADSL/jXf6CYiIIaJKZYwZE=" }, "is-callable": { "version": "1.1.4", @@ -13754,11 +13754,6 @@ "integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==", "dev": true }, - "vue-i18n": { - "version": "8.15.1", - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.15.1.tgz", - "integrity": "sha512-GBbz8qYCu0U2LNu4IcuFLZiuyninG4k26knvhL7GZG5Ncp4RR2VKDEH6g8gQ6I+UUBCvH2MBQVPSdxWe4DBkPw==" - }, "vue-loader": { "version": "15.7.2", "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-15.7.2.tgz", diff --git a/package.json b/package.json index 04abbf1..da1af5f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dependencies": { "@tailwindcss/postcss7-compat": "^2.2.7", "autoprefixer": "^9.8.6", - "axios": "^0.18.0", + "axios": "^0.18.1", "babel-polyfill": "^6.26.0", "echarts": "^4.8.0", "element-theme": "^2.0.1", diff --git a/src/api/api.js b/src/api/api.js new file mode 100644 index 0000000..5cd8341 --- /dev/null +++ b/src/api/api.js @@ -0,0 +1,87 @@ +import axios from 'axios'; +import router from '../router'; +// 创建axios实例 +const service = axios.create({ + baseURL: 'http://192.168.31.125:9000', + timeout: 30000 // 请求超时时间 +}) +// 添加request拦截器 +service.interceptors.request.use(config => { + return config +}, error => { + Promise.reject(error) +}) +// 添加respone拦截器 +service.interceptors.response.use( + response => { + let res={}; + res.status=response.status + res.data=response.data; + return res; + }, + error => { + if(error.response && error.response.status == 404){ + router.push('/blank.vue') + } + + + return Promise.reject(error.response) + } +) + +export function get(url, params = {}) { + // params.t = new Date().getTime(); //get方法加一个时间参数,解决ie下可能缓存问题. + return service({ + url: url, + method: 'get', + headers: { + token:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjM1MjEyMTYyLCJleHAiOjE2MzUyNTUzNjIsImFjY291bnRJZCI6IjIifQ.KjuoWp27gQwILUl0KsfxiyOwO45lADTS6ODO-x2KdJI' + }, + params + }) +} + + +//封装post请求 +export function post(url, data = {}) { + //默认配置 + let sendObject={ + url: url, + method: 'post', + headers: { + 'Content-Type':'application/json;charset=UTF-8', + token:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjM1MjEyMTYyLCJleHAiOjE2MzUyNTUzNjIsImFjY291bnRJZCI6IjIifQ.KjuoWp27gQwILUl0KsfxiyOwO45lADTS6ODO-x2KdJI' + }, + data:data + }; + sendObject.data=JSON.stringify(data); + return service(sendObject) +} + +//封装put方法 (resfulAPI常用) +export function put(url,data = {}){ + return service({ + url: url, + method: 'put', + headers: { + 'Content-Type':'application/json;charset=UTF-8', + token:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjM1MjEyMTYyLCJleHAiOjE2MzUyNTUzNjIsImFjY291bnRJZCI6IjIifQ.KjuoWp27gQwILUl0KsfxiyOwO45lADTS6ODO-x2KdJI' + }, + data:JSON.stringify(data) + }) +} +//删除方法(resfulAPI常用) +export function deletes(url){ + return service({ + url: url, + method: 'delete', + headers: { + token:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjM1MjEyMTYyLCJleHAiOjE2MzUyNTUzNjIsImFjY291bnRJZCI6IjIifQ.KjuoWp27gQwILUl0KsfxiyOwO45lADTS6ODO-x2KdJI' + } + }) +} + +//不要忘记export +export { + service +} \ No newline at end of file diff --git a/src/api/http.js b/src/api/http.js new file mode 100644 index 0000000..ac206f8 --- /dev/null +++ b/src/api/http.js @@ -0,0 +1,14 @@ +// 引入封装好的axios +// ps:如果没有封装,正常引入axios即可 +import {get, post,deletes,put} from './api.js' +// import axios from "./"; +// /api为配置跨域的路径变量 +export const getProjectBySystemId= (params) => { + return get( '/occupationlab/projectManage/getProjectBySystemId',params) +} +export const getProjectDetail= (params) => { + return get( '/occupationlab/projectManage/getProjectDetail',params) +} +export const submit= (params) => { + return post( '/bank/bank/submit',params) +} \ No newline at end of file diff --git a/src/components/case/index.vue b/src/components/case/index.vue index 31b81fb..1288a59 100644 --- a/src/components/case/index.vue +++ b/src/components/case/index.vue @@ -7,7 +7,7 @@
实训项目