wankeda
2025-06-24 6cc35000a6e138cfad96e7b02f8aeddcdb4ba6bf
´úÂë¹ÜÀí/NEWCode/WIDESEAWCS_PDA/common/http.interceptor.js
@@ -1,9 +1,10 @@
let baseUrl = 'http://127.0.0.1:9291'
let baseUrl = ''
const value = uni.getStorageSync('storage_key_ipAddress');
const install = (Vue, vm) => {
   let resolvedBaseUrl = baseUrl === '' ? (value && value.WCSIP ? value.WCSIP : "") : baseUrl;
   // æ­¤ä¸ºè‡ªå®šä¹‰é…ç½®å‚数,具体参数见上方说明
   Vue.prototype.$u.http.setConfig({
      baseUrl: baseUrl,
      baseUrl: resolvedBaseUrl,
      loadingText: '努力加载中~',
      loadingTime: 5000,
      originalData: true,
@@ -13,10 +14,35 @@
   // è¯·æ±‚拦截,配置Token等参数
   Vue.prototype.$u.http.interceptor.request = (config) => {
      // åˆ¤æ–­æ˜¯å¦ä¸ºå®Œæ•´ URL,如果是则不使用 baseUrl
      if (config.url.includes('http://') || config.url.includes('https://')) {
         config.baseURL = '';
      if (resolvedBaseUrl === '') {
         if (config.url.includes('http://') || config.url.includes('https://')) {
            config.baseURL = '';
            resolve(config);
         } else {
            const storedValue = uni.getStorageSync('storage_key_ipAddress');
            if (storedValue && storedValue.WCSIP) {
               config.baseURL = storedValue.WCSIP;
               baseUrl = storedValue.WCSIP;
            } else {
               vm.$u.toast('请先添加后台IP地址');
               return false; // å–消本次请求
            }
            // uni.getStorage({
            //    key: 'storage_key_ipAddress',
            //    success: (res) => {
            //       debugger;
            //       console.log(res.data.WCSIP);
            //       config.baseURL = res.data.WCSIP;
            //       baseUrl = res.data.WCSIP
            //    },
            //    fail: (err) => {
            //       debugger;
            //       vm.$u.toast('请先添加后台IP地址');
            //    },
            // });
         }
      } else {
         config.baseURL = baseUrl;
            config.baseURL = resolvedBaseUrl;
      }
      config.header.Token = 'xxxxxx';