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.
 
 
 

55 lines
1.5 KiB

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