From e717135aa986827ebf0a42cdee70ebf888d98987 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Tue, 29 Dec 2020 09:33:37 +0800
Subject: [PATCH] 优化顶部导航显示与交互

---
 bases/Fetcher.js |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/bases/Fetcher.js b/bases/Fetcher.js
index d670dee..a80b451 100644
--- a/bases/Fetcher.js
+++ b/bases/Fetcher.js
@@ -3,11 +3,8 @@
  * @author Tevin
  */
 
-// import Axios from 'axios';
-// import Qs from 'qs';
-// import {message, Modal} from 'antd';
-// import { AtToast } from 'taro-ui-vue'
 import Taro from '@tarojs/taro';
+import Qs from 'qs';
 import {Tools} from '@components/common/Tools';
 
 export class Fetcher {
@@ -84,6 +81,12 @@
      * @return {Promise<any>}
      */
     get(url, data, remap = [], options = null) {
+        const params = Qs.stringify(data);
+        if (url.indexOf('?') >= 0) {
+            url += '&' + params;
+        } else {
+            url += '?' + params;
+        }
         return this.query('get', url, null, remap, options);
     }
 
@@ -96,7 +99,15 @@
      * @return {Promise<any>}
      */
     post(url, data, remap = [], options = null) {
-        return this.query('post', url, data, remap, options);
+        const params = Qs.stringify(data);
+        const data2 = {};
+        params.split('&').forEach(param => {
+            if (param) {
+                const item = param.split('=');
+                data2[decodeURIComponent(item[0])] = decodeURIComponent(item[1]);
+            }
+        });
+        return this.query('post', url, data2, remap, options);
     }
 
     /**
@@ -430,7 +441,7 @@
         } else {
             // 修复补齐
             if (type === 'fix') {
-                if (!path || /^\/(upload|static)/.test(path)) {
+                if (!path || /^(http|\/upload|\/static)/.test(path)) {
                     return path;
                 } else {
                     return '/upload/' + path;
@@ -486,8 +497,8 @@
         if (Tools.getTopUrlParam('query') === 'real') {
             return false;
         }
-        // 当没有 url 指定时,只有内网 ip 和 35** 的端口号,视为本地开发模式
-        return /^(192|127|localhost).*?:35\d{2}$/i.test(window.location.host);
+        // 当没有 url 指定时,只有内网 ip 和 33** 的端口号,视为本地开发模式
+        return /^(192|127|localhost).*?:33\d{2}$/i.test(window.location.host);
     })();
 
 

--
Gitblit v1.9.1