From 55207667b0a93e37b2860447bd85165fcdc6efbd Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Thu, 25 Dec 2025 19:03:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A7=AF=E5=88=86=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/appConfig.js | 18 +- http/http.js | 8 +- http/websock - 副本.js | 241 ++++++++++ http/websock copy.js | 155 ------ http/websock.js | 244 +++++++--- http/yskApi/http.js | 20 +- http/yskApi/market/points.js | 16 + manifest.json | 482 +++++++++---------- pagesCreateOrder/choose-user/choose-user.vue | 2 +- pagesOrder/pay-order/pay-order.vue | 93 +++- stores/cart.js | 3 + vite.config.js | 10 +- vue.config.js | 53 -- 13 files changed, 758 insertions(+), 587 deletions(-) create mode 100644 http/websock - 副本.js delete mode 100644 http/websock copy.js create mode 100644 http/yskApi/market/points.js delete mode 100644 vue.config.js diff --git a/config/appConfig.js b/config/appConfig.js index 8b877e9..2e56bbd 100644 --- a/config/appConfig.js +++ b/config/appConfig.js @@ -1,3 +1,5 @@ +const DEBUG=true; + const appConfig = { // 项目名称 @@ -5,7 +7,7 @@ const appConfig = { // token取值key tokenKey: 'tokenInfo', - + baseUrl:'', // 环境变量相关 env: {}, // wss: "ws://192.168.1.42:2348", // ws://192.168.1.42:2348 @@ -24,5 +26,17 @@ const appConfig = { encryptKey: '1234567890123456' // http数据加解密的key } - +if(DEBUG){ + appConfig.wss='ws://192.168.1.42:2348' + appConfig.baseUrl='http://192.168.1.42' + // #ifdef H5 + appConfig.baseUrl='/testApi' + // #endif +}else{ + appConfig.baseUrl='https://cashier.sxczgkj.com' + appConfig.wss='wss://czgeatws.sxczgkj.com/wss' + // #ifdef H5 + appConfig.baseUrl='/proApi' + // #endif +} export default appConfig; \ No newline at end of file diff --git a/http/http.js b/http/http.js index 98572ef..3bf9764 100644 --- a/http/http.js +++ b/http/http.js @@ -12,13 +12,7 @@ import appConfig from '@/config/appConfig.js' import storageManage from '@/commons/utils/storageManage.js' import infoBox from "@/commons/utils/infoBox.js" import go from '@/commons/utils/go.js'; -let baseUrl = 'http://192.168.1.42' -// #ifdef H5 -baseUrl = '/server3/mch' -// #endif -// #ifndef H5 -baseUrl = 'http://101.37.12.135:8080/mch' -// #endif +let baseUrl = appConfig.baseUrl // 多少 ms 以内, 不提示loading const loadingShowTime = 200 diff --git a/http/websock - 副本.js b/http/websock - 副本.js new file mode 100644 index 0000000..4eb6be0 --- /dev/null +++ b/http/websock - 副本.js @@ -0,0 +1,241 @@ +import { reactive, ref } from 'vue'; + +// WebSocket 工具类,封装了 WebSocket 的连接、发送、接收、心跳、重连和关闭等操作 +class WebsocketUtil { + + // 构造函数,初始化 WebSocket 连接 + constructor(url, time, params) { + this.url = url; // WebSocket 服务器的 URL + this.params = params; // WebSocket 连接参数 + this.time = time; // 心跳发送的间隔时间(毫秒) + this.socketTask = null; // WebSocket 任务对象 + this.isOpen = false; // WebSocket 连接是否打开 + + // 定时器相关 + this.reconnectTimeout = null; // 重连定时器 + this.heartbeatInterval = null; // 心跳定时器 + this.heartbeatTimeout = null; // 心跳超时定时器(检测 pong 响应) + this.checkConnectionInterval = null; // 连接状态主动检查定时器 + + // 消息回调数组 + this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组 + + // 重连策略配置 + this.reconnectAttempts = 0; // 当前重连次数 + this.reconnectMaxAttempts = 5; // 最大重连次数(设为 Infinity 表示无限重试) + this.reconnectDelay = 3000; // 基础重连延迟(毫秒) + this.maxReconnectDelay = 30000; // 最大重连延迟(毫秒) + + // 初始化 WebSocket 连接 + this.initializeWebSocket(); + + // 监听设备唤醒事件(浏览器环境) + if (typeof document !== 'undefined') { + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible') { + // 页面可见时,主动检查连接 + this.checkConnection(); + } + }); + } + } + + // 初始化 WebSocket 连接 + initializeWebSocket() { + console.log('初始化WebSocket连接'); + if (this.isOpen) { + return; + } + + this.socketTask = uni.connectSocket({ + url: this.url, + success: () => { + console.log('WebSocket连接请求发送成功'); + }, + fail: (error) => { + console.error('WebSocket连接失败', error); + uni.$emit('is-socket-open', false); + this.reconnect(); + } + }); + + // 连接打开事件 + this.socketTask.onOpen((res) => { + console.log('WebSocket连接正常!==', res); + this.isOpen = true; + // 重置重连状态 + this.reconnectAttempts = 0; + this.reconnectDelay = 3000; + // 启动心跳和消息监听 + this.startHeartbeat(); + this.listenForMessages(); + uni.$emit('is-socket-open', true); + }); + + // 连接错误事件 + this.socketTask.onError((res) => { + console.log('WebSocket连接错误!==', res); + uni.$emit('is-socket-open', false); + this.reconnect(); + }); + + // 连接关闭事件 + this.socketTask.onClose((result) => { + console.log('WebSocket连接已关闭', result); + this.isOpen = false; + this.reconnect(); + }); + + // 启动连接状态主动检查(30秒一次) + this.startConnectionCheck(); + } + + // 启动心跳检测 + startHeartbeat() { + // 清除现有定时器 + if (this.heartbeatInterval) clearInterval(this.heartbeatInterval); + if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout); + + this.heartbeatInterval = setInterval(() => { + if (this.isOpen) { + // 发送心跳包 + this.send(JSON.stringify({ "type": "ping_interval", "set": "pad" })); + // 设置5秒超时:若未收到pong则重连 + this.heartbeatTimeout = setTimeout(() => { + console.log('心跳超时,主动断开并重连'); + this.closeSocket(); + this.reconnect(); + }, 5000); + } + }, this.time); + } + + // 启动连接状态主动检查(30秒一次) + startConnectionCheck() { + if (this.checkConnectionInterval) clearInterval(this.checkConnectionInterval); + this.checkConnectionInterval = setInterval(() => { + if (!this.isOpen && !this.reconnectTimeout) { + console.log('主动检查到连接断开,触发重连'); + this.reconnect(); + } + }, 30000); + } + + // 发送消息 + send(data, type) { + if (this.socketTask && this.isOpen) { + this.socketTask.send({ + data: data, + success: (res) => { + // 发送成功,重置心跳(可选,根据业务需求) + this.startHeartbeat(); + }, + fail: (error) => { + console.error('消息发送失败', error); + this.reconnect(); + } + }); + } else { + console.warn('WebSocket未连接,无法发送消息'); + } + } + + // 监听 WebSocket 消息 + listenForMessages() { + if (this.socketTask) { + this.socketTask.onMessage((res) => { + const data = res.data.toString(); + try { + // 尝试解析JSON,处理pong响应 + const message = JSON.parse(data); + if (message.type === 'pong') { + // 收到pong,清除心跳超时 + if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout); + } + } catch (e) { + console.warn('消息解析失败(非JSON格式):', e); + } + // 触发外部注册的回调函数 + this.messageCallbacks.forEach(callback => callback(data)); + }); + } else { + console.error('WebSocket 连接尚未建立,无法监听消息'); + } + } + + // 重连 WebSocket(指数退避策略) + reconnect() { + if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout); + + // 达到最大重连次数,停止重试(可根据需求调整为无限重试) + if (this.reconnectAttempts >= this.reconnectMaxAttempts) { + console.log(`已达最大重连次数 ${this.reconnectMaxAttempts},停止重连`); + return; + } + + // 指数退避:延迟时间 = 基础延迟 * 2^重连次数,最大不超过maxReconnectDelay + const delay = Math.min( + this.reconnectDelay * Math.pow(2, this.reconnectAttempts), + this.maxReconnectDelay + ); + + this.reconnectTimeout = setTimeout(() => { + this.reconnectAttempts++; + console.log(`重连尝试 ${this.reconnectAttempts}/${this.reconnectMaxAttempts},延迟 ${delay}ms`); + this.initializeWebSocket(); + }, delay); + } + + // 主动检查连接状态 + checkConnection() { + if (!this.isOpen && !this.reconnectTimeout) { + this.reconnect(); + } + } + + // 关闭 WebSocket 连接 + closeSocket() { + if (this.socketTask) { + uni.closeSocket({ + success: () => { + console.log('WebSocket连接已关闭'); + this.isOpen = false; + }, + fail: (error) => { + console.error('关闭WebSocket连接失败', error); + } + }); + this.socketTask = null; + } + } + + // 外部注册消息回调函数 + onMessage(callback) { + this.messageCallbacks.push(callback); + } + + // 外部注销消息回调函数 + offMessage(callback) { + // 若传入callback,则移除指定回调;否则清空所有回调 + if (callback) { + this.messageCallbacks = this.messageCallbacks.filter(cb => cb !== callback); + } else { + this.messageCallbacks = []; + } + } + + // 销毁 WebSocket 连接,清理资源 + destroy() { + this.closeSocket(); + // 清除所有定时器 + clearInterval(this.heartbeatInterval); + clearTimeout(this.heartbeatTimeout); + clearTimeout(this.reconnectTimeout); + clearInterval(this.checkConnectionInterval); + // 清空回调数组 + this.messageCallbacks = []; + console.log('WebSocket资源已销毁'); + } +} + +export default WebsocketUtil; \ No newline at end of file diff --git a/http/websock copy.js b/http/websock copy.js deleted file mode 100644 index 4d605d3..0000000 --- a/http/websock copy.js +++ /dev/null @@ -1,155 +0,0 @@ -import { - reactive, - ref -} from 'vue'; -// WebSocket 工具类,封装了 WebSocket 的连接、发送、接收、心跳、重连和关闭等操作 -class WebsocketUtil { - - // 构造函数,初始化 WebSocket 连接 - constructor(url, time, params) { - this.url = url; // WebSocket 服务器的 URL - this.params = params; // WebSocket 服务器的 URL - this.time = time; // 心跳发送的间隔时间(秒) - this.socketTask = null; // WebSocket 任务对象 - this.isOpen = false; // WebSocket 连接是否打开 - this.reconnectTimeout = null; // 重连定时器 - this.heartbeatInterval = null; // 心跳定时器 - this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组 - this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组 - - // 初始化 WebSocket 连接 - this.initializeWebSocket(); - } - - // 初始化 WebSocket 连接 - initializeWebSocket() { - if (this.isOpen) { - return - } - this.socketTask = uni.connectSocket({ - url: this.url, - success: () => { - console.log('WebSocket连接成功'); - return this.socketTask; - }, - fail: (error) => { - console.error('WebSocket连接失败', error); - uni.$emit('is-socket-open', true) - this.reconnect(); - } - }); - - this.socketTask.onOpen((res) => { - console.log('WebSocket连接正常!==', res); - this.isOpen = true; - // 连接成功后启动心跳和消息监听 - this.startHeartbeat(); - this.listenForMessages(); - uni.$emit('is-socket-open', true) - - }); - this.socketTask.onError((res) => { - console.log('WebSocket连接失败!==', res); - uni.$emit('is-socket-open', false) - this.reconnect(); - }); - // 注意:这里的 onClose 监听器应该放在 uni.connectSocket 调用之后 - this.socketTask.onClose((result) => { - this.isOpen = false; - // if( this.isOpen ){ - this.reconnect(); - // } - }); - - } - - // 启动心跳检测 - startHeartbeat() { - if (this.heartbeatInterval) { - clearInterval(this.heartbeatInterval); - } - this.heartbeatInterval = setInterval(() => { - if (this.isOpen) { - this.send(JSON.stringify({"type": "ping_interval","set": "pad"})); - } - }, this.time); - } - - // 发送消息 - send(data, type) { - if (this.socketTask && this.isOpen) { - this.socketTask.send({ - data: data, - success: (res) => { - // console.log('消息发送成功', res); - }, - fail: (error) => { - console.error('消息发送失败', error); - this.reconnect(); // 这里可能需要根据实际情况判断是否重连 - } - }); - } - } - - // 监听 WebSocket 消息 - listenForMessages() { - if (this.socketTask) { - this.socketTask.onMessage((res) => { - const { - data - } = res; - this.messageCallbacks.forEach(callback => callback(data - .toString())); // 假设 data 是字符串或可转换为字符串 - }); - // this.send("WebSocket连接正常"); - } else { - console.error('WebSocket 连接尚未建立,无法监听消息'); - } - } - - // 重连 WebSocket - reconnect() { - if (this.reconnectTimeout) { - clearTimeout(this.reconnectTimeout); - } - this.reconnectTimeout = setTimeout(() => { - this.initializeWebSocket(); - }, 3000); - } - - // 关闭 WebSocket 连接 - closeSocket() { - if (this.socketTask) { - uni.closeSocket({ - success: () => { - console.log('WebSocket连接已关闭'); - this.isOpen = false; - }, - fail: (error) => { - console.error('关闭WebSocket连接失败', error); - } - }); - this.socketTask = null; - } - } - - // 外部注册消息回调函数 - onMessage(callback) { - this.messageCallbacks.push(callback); - } - - // 外部注销消息回调函数 - offMessage(callback) { - this.messageCallbacks = [] - } - - // 销毁 WebSocket 连接,清理资源 - destroy() { - this.closeSocket(); - clearInterval(this.heartbeatInterval); - clearTimeout(this.reconnectTimeout); - this.messageCallbacks = []; - } -} - -export default WebsocketUtil; \ No newline at end of file diff --git a/http/websock.js b/http/websock.js index 4eb6be0..b2b5760 100644 --- a/http/websock.js +++ b/http/websock.js @@ -1,50 +1,110 @@ -import { reactive, ref } from 'vue'; - -// WebSocket 工具类,封装了 WebSocket 的连接、发送、接收、心跳、重连和关闭等操作 +// WebSocket 工具类 - 优化版 class WebsocketUtil { - - // 构造函数,初始化 WebSocket 连接 constructor(url, time, params) { - this.url = url; // WebSocket 服务器的 URL - this.params = params; // WebSocket 连接参数 - this.time = time; // 心跳发送的间隔时间(毫秒) - this.socketTask = null; // WebSocket 任务对象 - this.isOpen = false; // WebSocket 连接是否打开 + this.url = url; + this.params = params; + this.time = time; + this.socketTask = null; + this.isOpen = false; + this.isAppActive = true; // 应用是否活跃(前台) // 定时器相关 - this.reconnectTimeout = null; // 重连定时器 - this.heartbeatInterval = null; // 心跳定时器 - this.heartbeatTimeout = null; // 心跳超时定时器(检测 pong 响应) - this.checkConnectionInterval = null; // 连接状态主动检查定时器 + this.reconnectTimeout = null; + this.heartbeatInterval = null; + this.heartbeatTimeout = null; + this.checkConnectionInterval = null; // 消息回调数组 - this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组 + this.messageCallbacks = []; // 重连策略配置 - this.reconnectAttempts = 0; // 当前重连次数 - this.reconnectMaxAttempts = 5; // 最大重连次数(设为 Infinity 表示无限重试) - this.reconnectDelay = 3000; // 基础重连延迟(毫秒) - this.maxReconnectDelay = 30000; // 最大重连延迟(毫秒) + this.reconnectAttempts = 0; + this.reconnectMaxAttempts = 5; + this.reconnectDelay = 3000; + this.maxReconnectDelay = 30000; - // 初始化 WebSocket 连接 + // 事件监听器引用(用于销毁时移除) + this.appShowListener = null; + this.appHideListener = null; + this.networkListener = null; + this.visibilityChangeListener = null; + + // 初始化事件监听 + this.initEventListeners(); + // 初始化 WebSocket 连接 this.initializeWebSocket(); + } - // 监听设备唤醒事件(浏览器环境) + // 初始化全局事件监听 + initEventListeners() { + // 1. 监听应用显示/隐藏(Uniapp 全局事件) + this.appShowListener = uni.onAppShow(() => { + console.log('应用从后台回到前台'); + this.isAppActive = true; + // 重置重连状态,立即尝试重连 + this.resetReconnectState(); + this.checkConnection(); + this.startHeartbeat(); + this.startConnectionCheck(); + }); + + this.appHideListener = uni.onAppHide(() => { + console.log('应用进入后台'); + this.isAppActive = false; + // 后台时暂停心跳和连接检查,避免无效重连 + this.pauseHeartbeat(); + this.pauseConnectionCheck(); + }); + + // 2. 监听网络状态变化 + this.networkListener = uni.onNetworkStatusChange((res) => { + console.log('网络状态变化:', res); + if (res.isConnected) { + // 网络恢复,重置重连状态并立即重连 + this.resetReconnectState(); + this.checkConnection(); + } + }); + + // 3. 监听页面可见性变化(Web 端兼容) if (typeof document !== 'undefined') { - document.addEventListener('visibilitychange', () => { + this.visibilityChangeListener = () => { if (document.visibilityState === 'visible') { - // 页面可见时,主动检查连接 + console.log('页面可见,激活连接'); + this.isAppActive = true; + this.resetReconnectState(); this.checkConnection(); + this.startHeartbeat(); + this.startConnectionCheck(); + } else { + console.log('页面隐藏,暂停连接活动'); + this.isAppActive = false; + this.pauseHeartbeat(); + this.pauseConnectionCheck(); } - }); + }; + document.addEventListener('visibilitychange', this.visibilityChangeListener); } } - // 初始化 WebSocket 连接 + // 重置重连状态(用于应用前台切换、网络恢复时) + resetReconnectState() { + this.reconnectAttempts = 0; + this.reconnectDelay = 3000; + if (this.reconnectTimeout) { + clearTimeout(this.reconnectTimeout); + this.reconnectTimeout = null; + } + } + + // 初始化 WebSocket 连接 initializeWebSocket() { console.log('初始化WebSocket连接'); - if (this.isOpen) { - return; + if (this.isOpen) return; + + // 关闭之前可能存在的连接 + if (this.socketTask) { + this.closeSocket(); } this.socketTask = uni.connectSocket({ @@ -53,7 +113,7 @@ class WebsocketUtil { console.log('WebSocket连接请求发送成功'); }, fail: (error) => { - console.error('WebSocket连接失败', error); + console.error('WebSocket连接失败:', error); uni.$emit('is-socket-open', false); this.reconnect(); } @@ -61,12 +121,9 @@ class WebsocketUtil { // 连接打开事件 this.socketTask.onOpen((res) => { - console.log('WebSocket连接正常!==', res); + console.log('WebSocket连接正常!', res); this.isOpen = true; - // 重置重连状态 - this.reconnectAttempts = 0; - this.reconnectDelay = 3000; - // 启动心跳和消息监听 + this.resetReconnectState(); // 重置重连状态 this.startHeartbeat(); this.listenForMessages(); uni.$emit('is-socket-open', true); @@ -74,33 +131,37 @@ class WebsocketUtil { // 连接错误事件 this.socketTask.onError((res) => { - console.log('WebSocket连接错误!==', res); + console.error('WebSocket连接错误:', res); uni.$emit('is-socket-open', false); this.reconnect(); }); // 连接关闭事件 this.socketTask.onClose((result) => { - console.log('WebSocket连接已关闭', result); + console.log('WebSocket连接已关闭:', result); this.isOpen = false; - this.reconnect(); + // 只有应用活跃时才重连 + if (this.isAppActive) { + this.reconnect(); + } }); - // 启动连接状态主动检查(30秒一次) + // 启动连接状态主动检查 this.startConnectionCheck(); } - // 启动心跳检测 + // 启动心跳检测(仅在应用活跃时) startHeartbeat() { + if (!this.isAppActive) return; + // 清除现有定时器 - if (this.heartbeatInterval) clearInterval(this.heartbeatInterval); - if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout); + this.pauseHeartbeat(); this.heartbeatInterval = setInterval(() => { - if (this.isOpen) { + if (this.isOpen && this.isAppActive) { // 发送心跳包 this.send(JSON.stringify({ "type": "ping_interval", "set": "pad" })); - // 设置5秒超时:若未收到pong则重连 + // 5秒超时检测 this.heartbeatTimeout = setTimeout(() => { console.log('心跳超时,主动断开并重连'); this.closeSocket(); @@ -110,28 +171,52 @@ class WebsocketUtil { }, this.time); } + // 暂停心跳检测 + pauseHeartbeat() { + if (this.heartbeatInterval) { + clearInterval(this.heartbeatInterval); + this.heartbeatInterval = null; + } + if (this.heartbeatTimeout) { + clearTimeout(this.heartbeatTimeout); + this.heartbeatTimeout = null; + } + } + // 启动连接状态主动检查(30秒一次) startConnectionCheck() { if (this.checkConnectionInterval) clearInterval(this.checkConnectionInterval); this.checkConnectionInterval = setInterval(() => { - if (!this.isOpen && !this.reconnectTimeout) { - console.log('主动检查到连接断开,触发重连'); - this.reconnect(); - } + this.checkConnection(); }, 30000); } - // 发送消息 + // 暂停连接状态检查 + pauseConnectionCheck() { + if (this.checkConnectionInterval) { + clearInterval(this.checkConnectionInterval); + this.checkConnectionInterval = null; + } + } + + // 主动检查连接状态 + checkConnection() { + if (this.isAppActive && !this.isOpen && !this.reconnectTimeout) { + console.log('主动检查到连接断开,触发重连'); + this.reconnect(); + } + } + + // 发送消息 send(data, type) { if (this.socketTask && this.isOpen) { this.socketTask.send({ data: data, - success: (res) => { - // 发送成功,重置心跳(可选,根据业务需求) - this.startHeartbeat(); + success: () => { + this.startHeartbeat(); // 发送成功重置心跳 }, fail: (error) => { - console.error('消息发送失败', error); + console.error('消息发送失败:', error); this.reconnect(); } }); @@ -140,13 +225,12 @@ class WebsocketUtil { } } - // 监听 WebSocket 消息 + // 监听 WebSocket 消息 listenForMessages() { if (this.socketTask) { this.socketTask.onMessage((res) => { const data = res.data.toString(); try { - // 尝试解析JSON,处理pong响应 const message = JSON.parse(data); if (message.type === 'pong') { // 收到pong,清除心跳超时 @@ -155,25 +239,29 @@ class WebsocketUtil { } catch (e) { console.warn('消息解析失败(非JSON格式):', e); } - // 触发外部注册的回调函数 + // 触发外部回调 this.messageCallbacks.forEach(callback => callback(data)); }); - } else { - console.error('WebSocket 连接尚未建立,无法监听消息'); } } - // 重连 WebSocket(指数退避策略) + // 重连 WebSocket(指数退避 + 应用活跃检测) reconnect() { + // 应用在后台时,延迟重连 + if (!this.isAppActive) { + console.log('应用在后台,延迟重连'); + return; + } + if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout); - // 达到最大重连次数,停止重试(可根据需求调整为无限重试) + // 达到最大重连次数,停止重试 if (this.reconnectAttempts >= this.reconnectMaxAttempts) { console.log(`已达最大重连次数 ${this.reconnectMaxAttempts},停止重连`); return; } - // 指数退避:延迟时间 = 基础延迟 * 2^重连次数,最大不超过maxReconnectDelay + // 指数退避延迟 const delay = Math.min( this.reconnectDelay * Math.pow(2, this.reconnectAttempts), this.maxReconnectDelay @@ -186,14 +274,7 @@ class WebsocketUtil { }, delay); } - // 主动检查连接状态 - checkConnection() { - if (!this.isOpen && !this.reconnectTimeout) { - this.reconnect(); - } - } - - // 关闭 WebSocket 连接 + // 关闭 WebSocket 连接 closeSocket() { if (this.socketTask) { uni.closeSocket({ @@ -202,36 +283,39 @@ class WebsocketUtil { this.isOpen = false; }, fail: (error) => { - console.error('关闭WebSocket连接失败', error); + console.error('关闭WebSocket连接失败:', error); } }); this.socketTask = null; } } - // 外部注册消息回调函数 + // 外部注册消息回调 onMessage(callback) { this.messageCallbacks.push(callback); } - // 外部注销消息回调函数 + // 外部注销消息回调 offMessage(callback) { - // 若传入callback,则移除指定回调;否则清空所有回调 - if (callback) { - this.messageCallbacks = this.messageCallbacks.filter(cb => cb !== callback); - } else { - this.messageCallbacks = []; - } + this.messageCallbacks = callback + ? this.messageCallbacks.filter(cb => cb !== callback) + : []; } - // 销毁 WebSocket 连接,清理资源 + // 销毁 WebSocket 连接,清理资源 destroy() { this.closeSocket(); // 清除所有定时器 - clearInterval(this.heartbeatInterval); - clearTimeout(this.heartbeatTimeout); + this.pauseHeartbeat(); + this.pauseConnectionCheck(); clearTimeout(this.reconnectTimeout); - clearInterval(this.checkConnectionInterval); + // 移除所有事件监听 + if (this.appShowListener) uni.offAppShow(this.appShowListener); + if (this.appHideListener) uni.offAppHide(this.appHideListener); + if (this.networkListener) uni.offNetworkStatusChange(this.networkListener); + if (this.visibilityChangeListener && typeof document !== 'undefined') { + document.removeEventListener('visibilitychange', this.visibilityChangeListener); + } // 清空回调数组 this.messageCallbacks = []; console.log('WebSocket资源已销毁'); diff --git a/http/yskApi/http.js b/http/yskApi/http.js index c601cbf..8a84c57 100644 --- a/http/yskApi/http.js +++ b/http/yskApi/http.js @@ -13,26 +13,8 @@ import storageManage from "@/commons/utils/storageManage.js"; import infoBox from "@/commons/utils/infoBox.js"; import go from "@/commons/utils/go.js"; import { reject } from "lodash"; -// 测试服 -// let baseUrl = 'http://192.168.1.31' -// let baseUrl = 'https://admintestpapi.sxczgkj.cn' -// const proxyApiwws = 'ws://192.168.1.31:2348' // 调试地址 -//预发布 -// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn' +let baseUrl = appConfig.baseUrl -//正式 -// let baseUrl = 'https://cashieradmin.sxczgkj.cn' -let baseUrl = 'https://cashier.sxczgkj.com' - -// 本地测 -// let baseUrl = "http://192.168.1.42"; -// #ifdef H5 -baseUrl = "/ysk"; -// #endif - -// let baseUrl = 'http://192.168.1.15:8000' -// 巩 -// let baseUrl = 'http://192.168.1.9:8000' // 多少 ms 以内, 不提示loading const loadingShowTime = 200; diff --git a/http/yskApi/market/points.js b/http/yskApi/market/points.js new file mode 100644 index 0000000..a44bc70 --- /dev/null +++ b/http/yskApi/market/points.js @@ -0,0 +1,16 @@ +import http from '../http.js' +const request = http.request +import {marketUrl} from '../prveUrl.js' + + +export function pointsConfig(params) { + return request({ + url: marketUrl+`/admin/points/config`, + method: 'get', + params: { + shopId: uni.getStorageSync('shopId'), + ...params + } + }) +} + diff --git a/manifest.json b/manifest.json index 7e01739..fff1110 100644 --- a/manifest.json +++ b/manifest.json @@ -1,242 +1,242 @@ { - "name": "银收客点餐宝", - "appid": "__UNI__66E7BD0", - "description": "", - "versionName": "1.0.0", - "versionCode": 100, - "transformPx": false, - "app-plus": { - "orientation": "landscape", - /* 5+App特有相关 */ - "usingComponents": true, - "nvueCompiler": "uni-app", - "nvueStyleCompiler": "uni-app", - "splashscreen": { - "alwaysShowBeforeRender": true, - "waiting": true, - "autoclose": true, - "delay": 0 - }, - "modules": { - "Canvas": "nvue canvas", //使用Canvas模块 - "Geolocation": {}, - "Maps": {}, - "Barcode": {}, - "Camera": {} - }, - "screenOrientation": [ - "portrait-primary", - "portrait-secondary", - "landscape-primary", - "landscape-secondary" - ], - /* 模块配置 */ - "distribute": { - /* 应用发布信息 */ - "android": { - "orientation": "landscape", - /* android打包配置 */ - "permissions": [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ], - "abiFilters": ["armeabi-v7a"], - "permissionExternalStorage": { - "request": "none", - "prompt": "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。" - }, - "permissionPhoneState": { - "request": "none", - "prompt": "为保证您正常、安全地使用,需要获取设备识别码(部分手机提示为获取手机号码)使用权限,请允许。" - }, - "autoSdkPermissions": true, - "targetSdkVersion": 26, - "minSdkVersion": 21 - }, - "ios": { - "dSYMs": false - }, - /* ios打包配置 */ - "sdkConfigs": { - "geolocation": { - "amap": { - "__platform__": ["ios", "android"], - "appkey_ios": "0b9be2631525ee5e218ac26d333f215c", - "appkey_android": "9d1e62050f8558a082f7aa3ad5bb3c68" - } - }, - "maps": { - "amap": { - "appkey_ios": "0b9be2631525ee5e218ac26d333f215c", - "appkey_android": "9d1e62050f8558a082f7aa3ad5bb3c68" - } - }, - "ad": {}, - "push": {} - }, - "icons": { - "android": { - "hdpi": "unpackage/res/icons/72x72.png", - "xhdpi": "unpackage/res/icons/96x96.png", - "xxhdpi": "unpackage/res/icons/144x144.png", - "xxxhdpi": "unpackage/res/icons/192x192.png" - }, - "ios": { - "appstore": "unpackage/res/icons/1024x1024.png", - "ipad": { - "app": "unpackage/res/icons/76x76.png", - "app@2x": "unpackage/res/icons/152x152.png", - "notification": "unpackage/res/icons/20x20.png", - "notification@2x": "unpackage/res/icons/40x40.png", - "proapp@2x": "unpackage/res/icons/167x167.png", - "settings": "unpackage/res/icons/29x29.png", - "settings@2x": "unpackage/res/icons/58x58.png", - "spotlight": "unpackage/res/icons/40x40.png", - "spotlight@2x": "unpackage/res/icons/80x80.png" - }, - "iphone": { - "app@2x": "unpackage/res/icons/120x120.png", - "app@3x": "unpackage/res/icons/180x180.png", - "notification@2x": "unpackage/res/icons/40x40.png", - "notification@3x": "unpackage/res/icons/60x60.png", - "settings@2x": "unpackage/res/icons/58x58.png", - "settings@3x": "unpackage/res/icons/87x87.png", - "spotlight@2x": "unpackage/res/icons/80x80.png", - "spotlight@3x": "unpackage/res/icons/120x120.png" - } - } - }, - "splashscreen": { - "alwaysShowBeforeRender": true, - "autoclose": true, - "delay": 0, - "orientation": "landscape", - "androidStyle": "default", - "android": { - "hdpi": "C:/Users/Administrator/Desktop/bg.png", - "xhdpi": "C:/Users/Administrator/Desktop/bg.png", - "xxhdpi": "C:/Users/Administrator/Desktop/bg.png" - }, - "useOriginalMsgbox": true, - "iosStyle": "storyboard", - "ios": { - "storyboard": "C:/Users/Administrator/Downloads/CustomStoryboard.zip" - } - } - } - }, - /* SDK配置 */ - "quickapp": {}, - /* 快应用特有相关 */ - "mp-weixin": { - "appid": "wxd88fffa983758a30", - "setting": { - "urlCheck": false, - "minified": true, - "postcss": true, - "es6": true - }, - "optimization": { - "subPackages": true - }, - "usingComponents": true, - "libVersion": "latest" - }, - "vueVersion": "3", - "h5": { - "unipush": { - "enable": true - }, - "devServer": { - "disableHostCheck": true, - "proxy": { - "/shopApi": { - // 需要被代理的后台地址 - "target": "http://192.168.1.42", - "changeOrigin": true, - "secure": false, - "pathRewrite": { - "^/shopApi": "" - } - }, - "/mch": { - // 需要被代理的后台地址 - "target": "http://192.168.1.42", - "changeOrigin": true, - "secure": false, - "pathRewrite": { - "^/mch": "" - } - }, - "/server1": { - // 需要被代理的后台地址 - "target": "http://192.168.1.42", - "changeOrigin": true, - "secure": false, - "pathRewrite": { - "^/server1": "" - } - }, - "/server3": { - // 需要被代理的后台地址 - "target": "http://192.168.1.42", - "changeOrigin": true, - "secure": false, - "pathRewrite": { - "^/server3": "" - } - }, - "/ysk": { - // 需要被代理的后台地址 - "target": "http://192.168.1.42", - "changeOrigin": true, - "secure": false, - "pathRewrite": { - "^/ysk": "" - } - // "onProxyRes": function(proxyRes, req, res) { - // // proxyRes.headers['Content-Type'] = 'application/json'; - // }, - }, - "/ww": { - // 需要被代理的后台地址 - "target": "http://192.168.1.42", - "changeOrigin": true, - "secure": false, - "pathRewrite": { - "/ww": "" - } - } - } - }, - "sdkConfigs": { - "maps": { - "amap": { - "key": "6033c97e67bf2e9ceac306e1a3fa35f8", - "securityJsCode": "0547b69252ef0ed14e11f5c4ac152f07", - "serviceHost": "" - } - } - } - }, - "mp-alipay": { - "appid": "2021004128648214" - } -} \ No newline at end of file + "name" : "银收客点餐宝", + "appid" : "__UNI__66E7BD0", + "description" : "", + "versionName" : "1.0.0", + "versionCode" : 100, + "transformPx" : false, + "app-plus" : { + "orientation" : "landscape", + /* 5+App特有相关 */ + "usingComponents" : true, + "nvueCompiler" : "uni-app", + "nvueStyleCompiler" : "uni-app", + "splashscreen" : { + "alwaysShowBeforeRender" : true, + "waiting" : true, + "autoclose" : true, + "delay" : 0 + }, + "modules" : { + "Canvas" : "nvue canvas", //使用Canvas模块 + "Geolocation" : {}, + "Maps" : {}, + "Barcode" : {}, + "Camera" : {} + }, + "screenOrientation" : [ + "portrait-primary", + "portrait-secondary", + "landscape-primary", + "landscape-secondary" + ], + /* 模块配置 */ + "distribute" : { + /* 应用发布信息 */ + "android" : { + "orientation" : "landscape", + /* android打包配置 */ + "permissions" : [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ], + "abiFilters" : [ "armeabi-v7a" ], + "permissionExternalStorage" : { + "request" : "none", + "prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。" + }, + "permissionPhoneState" : { + "request" : "none", + "prompt" : "为保证您正常、安全地使用,需要获取设备识别码(部分手机提示为获取手机号码)使用权限,请允许。" + }, + "autoSdkPermissions" : true, + "targetSdkVersion" : 26, + "minSdkVersion" : 21 + }, + "ios" : { + "dSYMs" : false + }, + /* ios打包配置 */ + "sdkConfigs" : { + "geolocation" : { + "amap" : { + "__platform__" : [ "ios", "android" ], + "appkey_ios" : "0b9be2631525ee5e218ac26d333f215c", + "appkey_android" : "9d1e62050f8558a082f7aa3ad5bb3c68" + } + }, + "maps" : { + "amap" : { + "appkey_ios" : "0b9be2631525ee5e218ac26d333f215c", + "appkey_android" : "9d1e62050f8558a082f7aa3ad5bb3c68" + } + }, + "ad" : {}, + "push" : {} + }, + "icons" : { + "android" : { + "hdpi" : "unpackage/res/icons/72x72.png", + "xhdpi" : "unpackage/res/icons/96x96.png", + "xxhdpi" : "unpackage/res/icons/144x144.png", + "xxxhdpi" : "unpackage/res/icons/192x192.png" + }, + "ios" : { + "appstore" : "unpackage/res/icons/1024x1024.png", + "ipad" : { + "app" : "unpackage/res/icons/76x76.png", + "app@2x" : "unpackage/res/icons/152x152.png", + "notification" : "unpackage/res/icons/20x20.png", + "notification@2x" : "unpackage/res/icons/40x40.png", + "proapp@2x" : "unpackage/res/icons/167x167.png", + "settings" : "unpackage/res/icons/29x29.png", + "settings@2x" : "unpackage/res/icons/58x58.png", + "spotlight" : "unpackage/res/icons/40x40.png", + "spotlight@2x" : "unpackage/res/icons/80x80.png" + }, + "iphone" : { + "app@2x" : "unpackage/res/icons/120x120.png", + "app@3x" : "unpackage/res/icons/180x180.png", + "notification@2x" : "unpackage/res/icons/40x40.png", + "notification@3x" : "unpackage/res/icons/60x60.png", + "settings@2x" : "unpackage/res/icons/58x58.png", + "settings@3x" : "unpackage/res/icons/87x87.png", + "spotlight@2x" : "unpackage/res/icons/80x80.png", + "spotlight@3x" : "unpackage/res/icons/120x120.png" + } + } + }, + "splashscreen" : { + "alwaysShowBeforeRender" : true, + "autoclose" : true, + "delay" : 0, + "orientation" : "landscape", + "androidStyle" : "default", + "android" : { + "hdpi" : "static/login/bg.png", + "xhdpi" : "static/login/bg.png", + "xxhdpi" : "static/login/bg.png" + }, + "useOriginalMsgbox" : true, + "iosStyle" : "storyboard", + "ios" : { + "storyboard" : "C:/Users/Administrator/Downloads/CustomStoryboard.zip" + } + } + } + }, + /* SDK配置 */ + "quickapp" : {}, + /* 快应用特有相关 */ + "mp-weixin" : { + "appid" : "wxd88fffa983758a30", + "setting" : { + "urlCheck" : false, + "minified" : true, + "postcss" : true, + "es6" : true + }, + "optimization" : { + "subPackages" : true + }, + "usingComponents" : true, + "libVersion" : "latest" + }, + "vueVersion" : "3", + "h5" : { + "unipush" : { + "enable" : true + }, + "devServer" : { + "disableHostCheck" : true, + "proxy" : { + "/shopApi" : { + // 需要被代理的后台地址 + "target" : "http://192.168.1.42", + "changeOrigin" : true, + "secure" : false, + "pathRewrite" : { + "^/shopApi" : "" + } + }, + "/mch" : { + // 需要被代理的后台地址 + "target" : "http://192.168.1.42", + "changeOrigin" : true, + "secure" : false, + "pathRewrite" : { + "^/mch" : "" + } + }, + "/server1" : { + // 需要被代理的后台地址 + "target" : "http://192.168.1.42", + "changeOrigin" : true, + "secure" : false, + "pathRewrite" : { + "^/server1" : "" + } + }, + "/server3" : { + // 需要被代理的后台地址 + "target" : "http://192.168.1.42", + "changeOrigin" : true, + "secure" : false, + "pathRewrite" : { + "^/server3" : "" + } + }, + "/ysk" : { + // 需要被代理的后台地址 + "target" : "http://192.168.1.42", + "changeOrigin" : true, + "secure" : false, + "pathRewrite" : { + "^/ysk" : "" + } + }, + // "onProxyRes": function(proxyRes, req, res) { + // // proxyRes.headers['Content-Type'] = 'application/json'; + // }, + "/ww" : { + // 需要被代理的后台地址 + "target" : "http://192.168.1.42", + "changeOrigin" : true, + "secure" : false, + "pathRewrite" : { + "/ww" : "" + } + } + } + }, + "sdkConfigs" : { + "maps" : { + "amap" : { + "key" : "6033c97e67bf2e9ceac306e1a3fa35f8", + "securityJsCode" : "0547b69252ef0ed14e11f5c4ac152f07", + "serviceHost" : "" + } + } + } + }, + "mp-alipay" : { + "appid" : "2021004128648214" + } +} diff --git a/pagesCreateOrder/choose-user/choose-user.vue b/pagesCreateOrder/choose-user/choose-user.vue index 2d167d6..7d65256 100644 --- a/pagesCreateOrder/choose-user/choose-user.vue +++ b/pagesCreateOrder/choose-user/choose-user.vue @@ -37,7 +37,7 @@ 积分: - {{item.accountPoints}} + {{item.pointBalance||0}} diff --git a/pagesOrder/pay-order/pay-order.vue b/pagesOrder/pay-order/pay-order.vue index 204afa0..ec8a410 100644 --- a/pagesOrder/pay-order/pay-order.vue +++ b/pagesOrder/pay-order/pay-order.vue @@ -204,7 +204,7 @@ 积分抵扣 ( - {{ pageData.user.accountPoints || "0" }} + {{ pageData.user.pointBalance || "0" }} ) @@ -215,16 +215,15 @@ >{{ accountPoints.num }} - @@ -238,15 +237,12 @@ * - {{ - accountPoints.calcRes.equivalentPoints - }}积分等于1元,「可用积分{{ pageData.user.id?pageData.user.pointBalance:0}},最大可抵扣{{ + maxPointDiscount + }}元」 - - 最大抵扣积分{{ accountPoints.calcRes.maxUsablePoints }} - - , 最小抵扣积分0 + @@ -355,6 +351,7 @@ const cartStore = useCartStore(); import { getHistoryOrder } from "@/http/api/order.js"; import { getPayTypeList } from "@/http/api/payType.js"; import { shopUserDetail } from "@/http/api/shopUser.js"; +import { pointsConfig } from "@/http/yskApi/market/points.js"; import { discountActivity } from "@/http/yskApi/market/discountActivity.js"; import { @@ -448,11 +445,34 @@ async function getDiscountActivity() { fullReductionActivities.value = res ? [res] : []; } } + + + +async function getPointsConfig() { + let res = await pointsConfig(); + if (res) { + const { + equivalentPoints, + maxDeductionAmount, + enableRewards, + minPaymentAmount, + maxDeductionRatio + } = res + + pointDeductionRule.pointsPerYuan = equivalentPoints || 0; + pointDeductionRule.maxDeductionAmount = maxDeductionAmount || 0; + pointDeductionRule.maxDeductionRatio = maxDeductionRatio || 0; + pointDeductionRule.enableRewards = enableRewards || 0; + pointDeductionRule.minPaymentAmount = minPaymentAmount || 0; + console.log('pointDeductionRule',pointDeductionRule); + } +} onLoad(async (opt) => { Object.assign(order, opt); Object.assign(options, opt); await getPayType(); await getDiscountActivity(); + await getPointsConfig() console.log("pays.payTypes.list"); init(); }); @@ -572,8 +592,11 @@ const merchantReductionConfig = reactive({ }); //积分规则 const pointDeductionRule = reactive({ + enableRewards: 0, //是否开启 pointsPerYuan: 0, maxDeductionAmount: Infinity, + maxDeductionRatio: 0, //积分抵扣比例 + minPaymentAmount: 0, //门槛 }); //餐费费 const seatFeeConfig = reactive({ @@ -674,7 +697,7 @@ watch( () => accountPoints.sel, (newval) => { if (newval) { - userPoints.value = accountPoints.num; + userPoints.value = maxCanUsePoints.value } else { userPoints.value = 0; } @@ -876,6 +899,11 @@ function pointsConfirm(e) { accountPoints.num = e; } + + + +const maxPointDiscount=ref(0) +const maxCanUsePoints=ref(0) /** * 获取积分信息 * @param {Object} orderAmount @@ -884,20 +912,37 @@ async function getCalcUsablePoints() { if (!pageData.user.userId) { return; } - const res = await calcUsablePoints({ - shopUserId: pageData.user.id, - orderAmount: pointsCanDicountMaxMoney.value, - }); - console.log("getCalcUsablePoints", res); - pointDeductionRule.pointsPerYuan = res.equivalentPoints; - pointDeductionRule.maxDeductionAmount = res.maxDeductionAmount; - accountPoints.calcRes = res; - accountPoints.num = res.maxUsablePoints; - return res; + + + let userAccountPoints = pageData.user ? pageData.user.pointBalance*1 : 0; + + //1积分等于多少钱 + const onePointsMoney = pointDeductionRule.pointsPerYuan ? ((1 || 0) / pointDeductionRule.pointsPerYuan) : 0 + + + const calcMaxDiscount = Math.floor(pointsCanDicountMaxMoney.value * (pointDeductionRule.maxDeductionRatio / 100)) + const userMaxDiscount = BigNumber(userAccountPoints).times(onePointsMoney).decimalPlaces(2, BigNumber.ROUND_DOWN) + .toNumber() + + maxPointDiscount.value = Math.min(calcMaxDiscount, userMaxDiscount) + console.log('积分最大可抵扣金额', maxPointDiscount.value) + pointDeductionRule.maxDeductionAmount = maxPointDiscount.value || 0 + if (accountPoints.sel && pointDeductionRule.enableRewards) { + let num = (maxPointDiscount.value || 0) * pointDeductionRule.pointsPerYuan + if (num > userAccountPoints) { + num = userAccountPoints + } + maxCanUsePoints.value=num + userPoints.value=num + } + if (!pointDeductionRule.enableRewards) { + userPoints.value=0 + } + console.log('maxCanUsePoints.value', maxCanUsePoints.value) } function changeAccountPoints() { - if (!accountPoints.calcRes.usable) { + if (!pointDeductionRule.enableRewards) { return; } accountPoints.sel = !accountPoints.sel; diff --git a/stores/cart.js b/stores/cart.js index 1999e38..4891562 100644 --- a/stores/cart.js +++ b/stores/cart.js @@ -269,6 +269,9 @@ export const useCartStore = defineStore("cart", { */ async getOrder() { console.log("获取历史订单数据"); + if(!this.order.id){ + return + } const res = await orderApi.getOrderById({ orderId: this.order.id }); if (res) { this.setOrder(res); diff --git a/vite.config.js b/vite.config.js index 809b1d7..8b9e849 100644 --- a/vite.config.js +++ b/vite.config.js @@ -9,16 +9,16 @@ export default defineConfig({ ], server: { proxy: { - '/server3': { + '/testApi': { target: 'http://192.168.1.42', // 目标服务 changeOrigin: true, - rewrite: path => path.replace(/^\/server3/, ''), + rewrite: path => path.replace(/^\/testApi/, ''), }, - "/ysk": { + "/proApi": { // 需要被代理的后台地址 - target: "http://192.168.1.42", + target: "https://cashier.sxczgkj.com", changeOrigin: true, - rewrite: (path) => path.replace(/^\/ysk/, '') + rewrite: (path) => path.replace(/^\/proApi/, '') }, } } diff --git a/vue.config.js b/vue.config.js deleted file mode 100644 index c051178..0000000 --- a/vue.config.js +++ /dev/null @@ -1,53 +0,0 @@ -// 将图片放入分包中,最后使用图片时 /分包名称/.../*/图片名称 - -const path = require('path') -const CopyWebpackPlugin = require('copy-webpack-plugin') - -module.exports = { - // devServer: { - // proxy: { - // '/shopApi': { - // target: 'https://wxcashiertest.sxczgkj.cn/cashierService', - // changeOrigin: true, - // pathRewrite: { - // '^/shopApi': '' - // }, - // bypass(req, res, options) { - // const proxyURL = options.target + options.rewrite(req.url); - // req.headers['x-req-proxyURL'] = proxyURL; // 设置未生效 - // res.setHeader('x-req-proxyURL', proxyURL); // 设置响应头可以看到 - // }, - // onProxyRes(proxyRes, req, res) { - // const realUrl = process.env.BASEURL + req.url || ''; // 真实请求网址 - // console.log(realUrl); // 在终端显示 - // proxyRes.headers['A-Real-Url'] = realUrl; // 添加响应标头(A-Real-Url为自定义命名),在浏览器中显示 - // } - // } - // } - // }, - devServer: { - proxy: { - '/server3': { - target: 'http://192.168.1.42', // 目标服务器地址 - changeOrigin: true, // 是否改变源地址 - rewrite: '/' // 重写路径 - }, - "/ysk": { - target: "http://192.168.1.42", - changeOrigin: true, - pathRewrite: { - "^/ysk": "" - } - } - } - }, - configureWebpack: { - plugins: [ - new CopyWebpackPlugin([{ - from: path.join(__dirname, '/static'), - to: path.join(__dirname + '/unpackage/', 'dist', process.env.NODE_ENV === 'production' ? - 'build' : 'dev', process.env.UNI_PLATFORM, '/') - }]) - ] - } -} \ No newline at end of file