|
- const baseUrl = 'http://121.42.63.138:9091/autoSR/api';// 测试站
- // const baseUrl = 'http://192.168.31.163:8080/autoSR/api'; // 长龙
- // const baseUrl = 'http://192.168.31.130:8080/autoSR/api'; // 佳豪
- // const baseUrl = 'http://10.2.1.104:8081/autoSR/api'; // 刘敏
- // const baseUrl = 'https://zkgj.quhouse.com/api'; // 质控正式
- // const baseUrl = 'https://hfju.com/api'; // 数智正式
-
- const install = (Vue, vm) => {
- Vue.prototype.$u.http.setConfig({
- baseUrl,
- loadingText: '加载中~',
- loadingTime: 800,
- });
- // 请求拦截,如果有token,携带token
- Vue.prototype.$u.http.interceptor.request = (config) => {
- const token = uni.getStorageSync('weapp_session_login_data');
- if(token){
- config.header['Access-Token'] = token.token;
- }
- return config
- }
- // 响应拦截,公共错误处理
- Vue.prototype.$u.http.interceptor.response = (res) => {
- if(res.code == 10000) {
- return res.data;
- }else if(res.code == 10003 || res.code == 20006){
- uni.hideToast();
- uni.showToast({
- icon:"none",
- title:"您的登录已失效,请重新登录",
- duration: 2000
- })
- uni.clearStorageSync();
- setTimeout(function () {
- uni.reLaunch({
- url: '/pages/login/index'
- });
- },2000);
- return false;
- }else{
- uni.hideLoading();
- uni.showToast({
- icon:"none",
- title:res.message,
- duration: 3000
- })
- return false;
- }
- }
- }
-
- export default {
- install
- }
|