@@ -0,0 +1,14 @@ | |||||
import request from '@/config/request_java'; | |||||
export const APIOptimize = { | |||||
getExpertList // 获取专家列表 | |||||
}; | |||||
export default APIOptimize; | |||||
// 获取专家列表 | |||||
function getExpertList() { | |||||
return request({ | |||||
url: `/java_api/optimize/getExpertList`, | |||||
method: 'get' | |||||
}); | |||||
} |
@@ -3,6 +3,7 @@ module.exports = { | |||||
title: '健康同学', | title: '健康同学', | ||||
baseUrl: 'https://id.ssjlai.com/webapi', // 项目地址 | baseUrl: 'https://id.ssjlai.com/webapi', // 项目地址 | ||||
baseApi: 'https://id.ssjlai.com/webapi', // 本地api请求地址,注意:如果你使用了代理,请设置成'/' | baseApi: 'https://id.ssjlai.com/webapi', // 本地api请求地址,注意:如果你使用了代理,请设置成'/' | ||||
javaAPI: '/', // Java服务api | |||||
APPID: 'xxx', | APPID: 'xxx', | ||||
APPSECRET: 'xxx' | APPSECRET: 'xxx' | ||||
}; | }; |
@@ -3,6 +3,7 @@ module.exports = { | |||||
title: '健康同学', | title: '健康同学', | ||||
baseUrl: 'https://id.ssjlai.com/webapi', // 正式项目地址 | baseUrl: 'https://id.ssjlai.com/webapi', // 正式项目地址 | ||||
baseApi: 'https://id.ssjlai.com/webapi', // 正式api请求地址 | baseApi: 'https://id.ssjlai.com/webapi', // 正式api请求地址 | ||||
javaAPI: 'https://id.ssjlai.com/healthstudent', // 正式环境-Java服务api | |||||
APPID: 'xxx', | APPID: 'xxx', | ||||
APPSECRET: 'xxx' | APPSECRET: 'xxx' | ||||
}; | }; |
@@ -2,6 +2,7 @@ module.exports = { | |||||
title: '健康同学', | title: '健康同学', | ||||
baseUrl: 'https://id.ssjlai.com/webapi', // 测试项目地址 | baseUrl: 'https://id.ssjlai.com/webapi', // 测试项目地址 | ||||
baseApi: 'https://id.ssjlai.com/webapi', // 测试api请求地址 | baseApi: 'https://id.ssjlai.com/webapi', // 测试api请求地址 | ||||
javaAPI: 'https://id.ssjlai.com/healthstudent', // 测试环境-Java服务api | |||||
APPID: 'xxx', | APPID: 'xxx', | ||||
APPSECRET: 'xxx' | APPSECRET: 'xxx' | ||||
}; | }; |
@@ -0,0 +1,98 @@ | |||||
/* | |||||
* @Author: linwl | |||||
* @Date: 2020-04-13 14:47:59 | |||||
* @LastEditTime: 2023-06-15 10:32:04 | |||||
* @LastEditors: JinxChen | |||||
* @Description: axios请求配置 | |||||
* @FilePath: \ParentWeb\src\config\request.js | |||||
*/ | |||||
import axios from 'axios'; | |||||
import router from '@/router'; | |||||
import { javaAPI } from '@/config'; | |||||
import prefix from '@/store/prefix'; | |||||
const httpProxyPrefix = javaAPI; | |||||
// create an axios instance axios.create创建一个实例 | |||||
const service = axios.create({ | |||||
// baseURL: process.env.VUE_APP_BASE_API, | |||||
baseURL: httpProxyPrefix | |||||
// timeout: 5000 // request timeout | |||||
}); | |||||
const errorHandler = error => { | |||||
// const status = get(error, 'response.status'); | |||||
const status = error.response.status; | |||||
console.log(status); | |||||
switch (status) { | |||||
case 400: | |||||
error.message = '请求错误'; | |||||
break; | |||||
case 401: | |||||
error.message = '未授权,请登录'; | |||||
break; | |||||
case 403: | |||||
error.message = '拒绝访问'; | |||||
break; | |||||
case 404: | |||||
error.message = '请求地址出错'; | |||||
break; | |||||
case 408: | |||||
error.message = '请求超时'; | |||||
break; | |||||
case 500: | |||||
error.message = '服务器内部错误'; | |||||
break; | |||||
case 501: | |||||
error.message = '服务未实现'; | |||||
break; | |||||
case 502: | |||||
error.message = '网关错误'; | |||||
break; | |||||
case 503: | |||||
error.message = '服务器不可用'; | |||||
break; | |||||
case 504: | |||||
error.message = '网关超时'; | |||||
break; | |||||
case 505: | |||||
error.message = 'HTTP版本不受支持'; | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
this.$notify({ message: `您的网络异常(${error.message})`, type: 'warning' }); | |||||
return Promise.reject(error); | |||||
}; | |||||
// 请求拦截器,增加 token interceptors拦截 | |||||
service.interceptors.request.use(request => { | |||||
if (localStorage.getItem(prefix + 'authToken')) { | |||||
request.headers.AuthToken = localStorage.getItem(prefix + 'authToken'); | |||||
} else if ( | |||||
window.location.href.indexOf('login') < 0 && | |||||
window.location.href.indexOf('forgetPassword') < 0 && | |||||
window.location.href.indexOf('verifyInfos') < 0 && | |||||
window.location.href.indexOf('register') < 0 && | |||||
window.location.href.indexOf('verificationLogin') < 0 && | |||||
window.location.href.indexOf('changePassword') < 0 | |||||
) { | |||||
router.push({ name: 'login' }); | |||||
return request; | |||||
} | |||||
// 全局请求统一增加一个 sourcetype: 1的参数跟区分新旧接口 | |||||
if (request.method == 'get') { | |||||
request.params = { | |||||
...request.params, | |||||
sourcetype: 1 | |||||
}; | |||||
} else if (request.method == 'post') { | |||||
request.data = { | |||||
...request.data, | |||||
sourcetype: 1 | |||||
}; | |||||
} | |||||
return request; | |||||
}, errorHandler); | |||||
export default service; |
@@ -133,6 +133,7 @@ | |||||
<script> | <script> | ||||
import Vue from 'vue'; | import Vue from 'vue'; | ||||
import APIOptimize from '@/api/optimize'; | |||||
import TabBar from '@/components/TabBar'; | import TabBar from '@/components/TabBar'; | ||||
import expertImage from '@/assets/optimize/images/3_08.png'; | import expertImage from '@/assets/optimize/images/3_08.png'; | ||||
import { Swipe, SwipeItem, Lazyload } from 'vant'; | import { Swipe, SwipeItem, Lazyload } from 'vant'; | ||||
@@ -161,9 +162,21 @@ export default { | |||||
] | ] | ||||
}; | }; | ||||
}, | }, | ||||
created() {}, | |||||
created() { | |||||
this.init(); | |||||
}, | |||||
mounted() {}, | mounted() {}, | ||||
methods: { | methods: { | ||||
init() { | |||||
// 专家列表 | |||||
APIOptimize.getExpertList() | |||||
.then(res => { | |||||
console.log(res); | |||||
}) | |||||
.catch(e => { | |||||
console.log(e); | |||||
}) | |||||
}, | |||||
goExperts(id) { | goExperts(id) { | ||||
this.$router.push({ | this.$router.push({ | ||||
name: 'experts', | name: 'experts', | ||||
@@ -21,18 +21,27 @@ module.exports = defineConfig({ | |||||
hot: true, //热更新 | hot: true, //热更新 | ||||
client: { | client: { | ||||
overlay: false //报错是否显示遮罩层,不显示 | overlay: false //报错是否显示遮罩层,不显示 | ||||
}, | |||||
proxy: { | |||||
// //配置跨域 | |||||
// '/api': { | |||||
// target: "https://test.xxx.com", | |||||
// // ws:true, | |||||
// changOrigin:true, | |||||
// pathRewrite:{ | |||||
// '^/api':'/' | |||||
// } | |||||
// } | |||||
//配置跨域 | |||||
'/java_api': { | |||||
target: "http://127.0.0.1:8010/", | |||||
// ws:true, | |||||
changOrigin:true, | |||||
pathRewrite:{ | |||||
'^/java_api':'/' | |||||
} | |||||
} | |||||
} | } | ||||
// proxy: { | |||||
// //配置跨域 | |||||
// '/api': { | |||||
// target: "https://test.xxx.com", | |||||
// // ws:true, | |||||
// changOrigin:true, | |||||
// pathRewrite:{ | |||||
// '^/api':'/' | |||||
// } | |||||
// } | |||||
// } | |||||
}, | }, | ||||
css: { | css: { | ||||
extract: true, // 是否将组件中的 CSS 提取至一个独立的 CSS 文件中 (而不是动态注入到 JavaScript 中的 inline 代码)。 | extract: true, // 是否将组件中的 CSS 提取至一个独立的 CSS 文件中 (而不是动态注入到 JavaScript 中的 inline 代码)。 | ||||