From 6ede2a27090fe5312428afd1d4e3459cacbe5467 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Mon, 21 Feb 2022 16:26:31 +0800
Subject: [PATCH] 优化地址三级联动组件,海南省补齐部分地区第三级地址

---
 bases/Fetcher.js |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/bases/Fetcher.js b/bases/Fetcher.js
index e0b9e8b..d850bd8 100644
--- a/bases/Fetcher.js
+++ b/bases/Fetcher.js
@@ -82,12 +82,8 @@
         }
         // 正常模式
         else {
-            // 代理模式
-            if (typeof project.host.proxyType !== 'undefined' && project.host.proxyType !== 'lc') {
-                url = '/proxy' + this._data.urlPrefix[1] + (serSuffix || devSuffix);
-            }
             // 开发环境地址
-            else if (Fetcher.inDevMod) {
+            if (Fetcher.inDevMod) {
                 url = this._data.urlPrefix[0] + devSuffix;
             }
             // 生产环境地址
@@ -191,6 +187,7 @@
         });
     }
 
+    // 小程序中,保存 cookies
     _saveCookies(cookies) {
         const localCookies = JSON.parse(Taro.getStorageSync('cookies') || '{}');
         cookies.forEach(cookie => {
@@ -200,6 +197,7 @@
         Taro.setStorageSync('cookies', JSON.stringify(localCookies));
     }
 
+    // 小程序中,获取 cookies
     _getCookies() {
         const localCookies = JSON.parse(Taro.getStorageSync('cookies') || '{}');
         const cookiesArr = [];
@@ -390,9 +388,9 @@
             if (process.env.TARO_ENV === 'weapp') {
                 Taro.navigateTo({ url: '/pages/home/index/index?mode=login' });
             }
-            // 在App中,直接跳转登陆页
+            // 在App中,跳转到首页取消登陆
             if (project.appHybrid) {
-                Taro.reLaunch({ url: '/pages/home/login/login' });
+                Taro.navigateTo({ url: '/pages/home/index/index?mode=logout' });
             }
             return null;
         } else {
@@ -512,7 +510,7 @@
                     return path;
                 }
                 // 绝对路径
-                if (/^(\/upload|\/static)/.test(path)) {
+                if (/^(\/upload|\/static|\/mini)/.test(path)) {
                     return Fetcher.host + path;
                 }
                 // 部分路径
@@ -580,8 +578,22 @@
     static inDevMod = (() => {
         // 网页
         if (process.env.TARO_ENV === 'h5') {
-            // 当没有 url 指定时,只有内网 ip 和 33**/35** 的端口号,视为本地开发模式
-            return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host);
+            // http协议访问
+            if (window.location.protocol.indexOf('http') > 0) {
+                // 当内网 ip 且使用 33**/35** 的端口号时,视为本地开发模式
+                return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host);
+            }
+            // 非http协议访问
+            else {
+                // 开发编译
+                if (process.env.NODE_ENV === 'development') {
+                    return true;
+                }
+                // 生产编译
+                else if (process.env.NODE_ENV === 'production') {
+                    return false;
+                }
+            }
         }
         // 小程序
         else if (process.env.TARO_ENV === 'weapp') {
@@ -606,9 +618,11 @@
             // 如果网址参数有指定服务器
             const server = Tools.getUrlParam('server');
             if (server) {
-                // 如果是完整网址,直接使用地址
+                // 如果是完整网址,使用网址对应的域名
                 if (server.indexOf('http') >= 0) {
-                    return server;
+                    const portal = server.split('//')[0];
+                    const domain = server.split('//')[1].split('/')[0];
+                    return portal + '//' + domain;
                 }
                 // 如果有匹配服务器,使用指定的服务器地址
                 if (typeof project.host.hosts[server] !== 'undefined') {

--
Gitblit v1.9.1