You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.5 KiB

  1. // const baseUrl = 'http://121.42.63.138:9091/autoSR/api';// 测试站
  2. // const baseUrl= 'http://39.97.167.65/autoSR/api';
  3. // const baseUrl = 'http://192.168.31.169:8080/autoSR/api'; // 长龙
  4. const baseUrl = 'http://192.168.31.134:9999/autoSR/api'; // 佳豪
  5. // const baseUrl = 'http://10.2.1.104:8081/autoSR/api'; // 刘敏
  6. // const baseUrl = 'https://zkgj.quhouse.com/api'; // 质控正式
  7. // const baseUrl = 'https://hfju.com/api'; // 数智正式
  8. const install = (Vue, vm) => {
  9. Vue.prototype.$u.http.setConfig({
  10. baseUrl,
  11. loadingText: '加载中~',
  12. loadingTime: 800,
  13. });
  14. // 请求拦截,如果有token,携带token
  15. Vue.prototype.$u.http.interceptor.request = (config) => {
  16. const token = uni.getStorageSync('weapp_session_login_data');
  17. if(token){
  18. config.header['Access-Token'] = token.token;
  19. }
  20. return config
  21. }
  22. // 响应拦截,公共错误处理
  23. Vue.prototype.$u.http.interceptor.response = (res) => {
  24. if(res.code == 10000) {
  25. return res.data;
  26. }else if(res.code == 10003 || res.code == 20006){
  27. uni.hideToast();
  28. uni.showToast({
  29. icon:"none",
  30. title:"您的登录已失效,请重新登录",
  31. duration: 2000
  32. })
  33. uni.clearStorageSync();
  34. setTimeout(function () {
  35. uni.reLaunch({
  36. url: '/pages/login/index'
  37. });
  38. },2000);
  39. return false;
  40. }else{
  41. uni.hideLoading();
  42. uni.showToast({
  43. icon:"none",
  44. title:res.message,
  45. duration: 3000
  46. })
  47. return false;
  48. }
  49. }
  50. }
  51. export default {
  52. install
  53. }