From dc6f9b1563d03bee916282355ad58a3b08420469 Mon Sep 17 00:00:00 2001 From: e <2432808546@qq.com> Date: Tue, 26 Oct 2021 18:02:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85axios=E5=92=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=96=E9=A1=B9=E7=9B=AE=E9=80=89=E6=8B=A9=E4=B8=8E=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=AF=A6=E6=83=85=E5=BC=80=E5=A7=8B=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=E7=AD=89,=E4=B8=AA=E4=BA=BA=E4=B8=9A=E5=8A=A1=E6=B4=BB?= =?UTF-8?q?=E6=9C=9F=E5=BC=80=E6=88=B7=E4=B8=9A=E5=8A=A1=E6=8F=90=E4=BA=A4?= =?UTF-8?q?,=E4=B8=AA=E4=BA=BA=E5=AE=A2=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=BB=BA=E7=AB=8B=E6=8F=90=E4=BA=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 15 +- package.json | 2 +- src/api/api.js | 87 +++++ src/api/http.js | 14 + src/components/case/index.vue | 331 ++++++++++-------- src/main.js | 2 + src/pages/counter/list/index.vue | 12 +- src/pages/index/list/index.vue | 4 +- .../manage/list/client/consumerClient.vue | 79 ++++- .../personal/currentAccount/openAccount.vue | 174 ++++++--- src/pages/manage/navbar/index.vue | 2 +- vue.config.js | 22 +- 12 files changed, 520 insertions(+), 224 deletions(-) create mode 100644 src/api/api.js create mode 100644 src/api/http.js 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 @@

实训项目

-
+
+
@@ -63,9 +64,10 @@ - + - + +