修改积分计算
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
const DEBUG=true;
|
||||||
|
|
||||||
const appConfig = {
|
const appConfig = {
|
||||||
|
|
||||||
// 项目名称
|
// 项目名称
|
||||||
@@ -5,7 +7,7 @@ const appConfig = {
|
|||||||
|
|
||||||
// token取值key
|
// token取值key
|
||||||
tokenKey: 'tokenInfo',
|
tokenKey: 'tokenInfo',
|
||||||
|
baseUrl:'',
|
||||||
// 环境变量相关
|
// 环境变量相关
|
||||||
env: {},
|
env: {},
|
||||||
// wss: "ws://192.168.1.42:2348", // ws://192.168.1.42:2348
|
// wss: "ws://192.168.1.42:2348", // ws://192.168.1.42:2348
|
||||||
@@ -24,5 +26,17 @@ const appConfig = {
|
|||||||
encryptKey: '1234567890123456' // http数据加解密的key
|
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;
|
export default appConfig;
|
||||||
@@ -12,13 +12,7 @@ import appConfig from '@/config/appConfig.js'
|
|||||||
import storageManage from '@/commons/utils/storageManage.js'
|
import storageManage from '@/commons/utils/storageManage.js'
|
||||||
import infoBox from "@/commons/utils/infoBox.js"
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
import go from '@/commons/utils/go.js';
|
import go from '@/commons/utils/go.js';
|
||||||
let baseUrl = 'http://192.168.1.42'
|
let baseUrl = appConfig.baseUrl
|
||||||
// #ifdef H5
|
|
||||||
baseUrl = '/server3/mch'
|
|
||||||
// #endif
|
|
||||||
// #ifndef H5
|
|
||||||
baseUrl = 'http://101.37.12.135:8080/mch'
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// 多少 ms 以内, 不提示loading
|
// 多少 ms 以内, 不提示loading
|
||||||
const loadingShowTime = 200
|
const loadingShowTime = 200
|
||||||
|
|||||||
241
http/websock - 副本.js
Normal file
241
http/websock - 副本.js
Normal file
@@ -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;
|
||||||
@@ -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;
|
|
||||||
228
http/websock.js
228
http/websock.js
@@ -1,50 +1,110 @@
|
|||||||
import { reactive, ref } from 'vue';
|
// WebSocket 工具类 - 优化版
|
||||||
|
|
||||||
// WebSocket 工具类,封装了 WebSocket 的连接、发送、接收、心跳、重连和关闭等操作
|
|
||||||
class WebsocketUtil {
|
class WebsocketUtil {
|
||||||
|
|
||||||
// 构造函数,初始化 WebSocket 连接
|
|
||||||
constructor(url, time, params) {
|
constructor(url, time, params) {
|
||||||
this.url = url; // WebSocket 服务器的 URL
|
this.url = url;
|
||||||
this.params = params; // WebSocket 连接参数
|
this.params = params;
|
||||||
this.time = time; // 心跳发送的间隔时间(毫秒)
|
this.time = time;
|
||||||
this.socketTask = null; // WebSocket 任务对象
|
this.socketTask = null;
|
||||||
this.isOpen = false; // WebSocket 连接是否打开
|
this.isOpen = false;
|
||||||
|
this.isAppActive = true; // 应用是否活跃(前台)
|
||||||
|
|
||||||
// 定时器相关
|
// 定时器相关
|
||||||
this.reconnectTimeout = null; // 重连定时器
|
this.reconnectTimeout = null;
|
||||||
this.heartbeatInterval = null; // 心跳定时器
|
this.heartbeatInterval = null;
|
||||||
this.heartbeatTimeout = null; // 心跳超时定时器(检测 pong 响应)
|
this.heartbeatTimeout = null;
|
||||||
this.checkConnectionInterval = null; // 连接状态主动检查定时器
|
this.checkConnectionInterval = null;
|
||||||
|
|
||||||
// 消息回调数组
|
// 消息回调数组
|
||||||
this.messageCallbacks = []; // 存储外部注册的消息回调函数的数组
|
this.messageCallbacks = [];
|
||||||
|
|
||||||
// 重连策略配置
|
// 重连策略配置
|
||||||
this.reconnectAttempts = 0; // 当前重连次数
|
this.reconnectAttempts = 0;
|
||||||
this.reconnectMaxAttempts = 5; // 最大重连次数(设为 Infinity 表示无限重试)
|
this.reconnectMaxAttempts = 5;
|
||||||
this.reconnectDelay = 3000; // 基础重连延迟(毫秒)
|
this.reconnectDelay = 3000;
|
||||||
this.maxReconnectDelay = 30000; // 最大重连延迟(毫秒)
|
this.maxReconnectDelay = 30000;
|
||||||
|
|
||||||
|
// 事件监听器引用(用于销毁时移除)
|
||||||
|
this.appShowListener = null;
|
||||||
|
this.appHideListener = null;
|
||||||
|
this.networkListener = null;
|
||||||
|
this.visibilityChangeListener = null;
|
||||||
|
|
||||||
|
// 初始化事件监听
|
||||||
|
this.initEventListeners();
|
||||||
// 初始化 WebSocket 连接
|
// 初始化 WebSocket 连接
|
||||||
this.initializeWebSocket();
|
this.initializeWebSocket();
|
||||||
|
}
|
||||||
|
|
||||||
// 监听设备唤醒事件(浏览器环境)
|
// 初始化全局事件监听
|
||||||
if (typeof document !== 'undefined') {
|
initEventListeners() {
|
||||||
document.addEventListener('visibilitychange', () => {
|
// 1. 监听应用显示/隐藏(Uniapp 全局事件)
|
||||||
if (document.visibilityState === 'visible') {
|
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();
|
this.checkConnection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 3. 监听页面可见性变化(Web 端兼容)
|
||||||
|
if (typeof document !== 'undefined') {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置重连状态(用于应用前台切换、网络恢复时)
|
||||||
|
resetReconnectState() {
|
||||||
|
this.reconnectAttempts = 0;
|
||||||
|
this.reconnectDelay = 3000;
|
||||||
|
if (this.reconnectTimeout) {
|
||||||
|
clearTimeout(this.reconnectTimeout);
|
||||||
|
this.reconnectTimeout = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化 WebSocket 连接
|
// 初始化 WebSocket 连接
|
||||||
initializeWebSocket() {
|
initializeWebSocket() {
|
||||||
console.log('初始化WebSocket连接');
|
console.log('初始化WebSocket连接');
|
||||||
if (this.isOpen) {
|
if (this.isOpen) return;
|
||||||
return;
|
|
||||||
|
// 关闭之前可能存在的连接
|
||||||
|
if (this.socketTask) {
|
||||||
|
this.closeSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socketTask = uni.connectSocket({
|
this.socketTask = uni.connectSocket({
|
||||||
@@ -53,7 +113,7 @@ class WebsocketUtil {
|
|||||||
console.log('WebSocket连接请求发送成功');
|
console.log('WebSocket连接请求发送成功');
|
||||||
},
|
},
|
||||||
fail: (error) => {
|
fail: (error) => {
|
||||||
console.error('WebSocket连接失败', error);
|
console.error('WebSocket连接失败:', error);
|
||||||
uni.$emit('is-socket-open', false);
|
uni.$emit('is-socket-open', false);
|
||||||
this.reconnect();
|
this.reconnect();
|
||||||
}
|
}
|
||||||
@@ -61,12 +121,9 @@ class WebsocketUtil {
|
|||||||
|
|
||||||
// 连接打开事件
|
// 连接打开事件
|
||||||
this.socketTask.onOpen((res) => {
|
this.socketTask.onOpen((res) => {
|
||||||
console.log('WebSocket连接正常!==', res);
|
console.log('WebSocket连接正常!', res);
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
// 重置重连状态
|
this.resetReconnectState(); // 重置重连状态
|
||||||
this.reconnectAttempts = 0;
|
|
||||||
this.reconnectDelay = 3000;
|
|
||||||
// 启动心跳和消息监听
|
|
||||||
this.startHeartbeat();
|
this.startHeartbeat();
|
||||||
this.listenForMessages();
|
this.listenForMessages();
|
||||||
uni.$emit('is-socket-open', true);
|
uni.$emit('is-socket-open', true);
|
||||||
@@ -74,33 +131,37 @@ class WebsocketUtil {
|
|||||||
|
|
||||||
// 连接错误事件
|
// 连接错误事件
|
||||||
this.socketTask.onError((res) => {
|
this.socketTask.onError((res) => {
|
||||||
console.log('WebSocket连接错误!==', res);
|
console.error('WebSocket连接错误:', res);
|
||||||
uni.$emit('is-socket-open', false);
|
uni.$emit('is-socket-open', false);
|
||||||
this.reconnect();
|
this.reconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 连接关闭事件
|
// 连接关闭事件
|
||||||
this.socketTask.onClose((result) => {
|
this.socketTask.onClose((result) => {
|
||||||
console.log('WebSocket连接已关闭', result);
|
console.log('WebSocket连接已关闭:', result);
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
|
// 只有应用活跃时才重连
|
||||||
|
if (this.isAppActive) {
|
||||||
this.reconnect();
|
this.reconnect();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 启动连接状态主动检查(30秒一次)
|
// 启动连接状态主动检查
|
||||||
this.startConnectionCheck();
|
this.startConnectionCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 启动心跳检测
|
// 启动心跳检测(仅在应用活跃时)
|
||||||
startHeartbeat() {
|
startHeartbeat() {
|
||||||
|
if (!this.isAppActive) return;
|
||||||
|
|
||||||
// 清除现有定时器
|
// 清除现有定时器
|
||||||
if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
|
this.pauseHeartbeat();
|
||||||
if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout);
|
|
||||||
|
|
||||||
this.heartbeatInterval = setInterval(() => {
|
this.heartbeatInterval = setInterval(() => {
|
||||||
if (this.isOpen) {
|
if (this.isOpen && this.isAppActive) {
|
||||||
// 发送心跳包
|
// 发送心跳包
|
||||||
this.send(JSON.stringify({ "type": "ping_interval", "set": "pad" }));
|
this.send(JSON.stringify({ "type": "ping_interval", "set": "pad" }));
|
||||||
// 设置5秒超时:若未收到pong则重连
|
// 5秒超时检测
|
||||||
this.heartbeatTimeout = setTimeout(() => {
|
this.heartbeatTimeout = setTimeout(() => {
|
||||||
console.log('心跳超时,主动断开并重连');
|
console.log('心跳超时,主动断开并重连');
|
||||||
this.closeSocket();
|
this.closeSocket();
|
||||||
@@ -110,15 +171,40 @@ class WebsocketUtil {
|
|||||||
}, this.time);
|
}, this.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 暂停心跳检测
|
||||||
|
pauseHeartbeat() {
|
||||||
|
if (this.heartbeatInterval) {
|
||||||
|
clearInterval(this.heartbeatInterval);
|
||||||
|
this.heartbeatInterval = null;
|
||||||
|
}
|
||||||
|
if (this.heartbeatTimeout) {
|
||||||
|
clearTimeout(this.heartbeatTimeout);
|
||||||
|
this.heartbeatTimeout = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 启动连接状态主动检查(30秒一次)
|
// 启动连接状态主动检查(30秒一次)
|
||||||
startConnectionCheck() {
|
startConnectionCheck() {
|
||||||
if (this.checkConnectionInterval) clearInterval(this.checkConnectionInterval);
|
if (this.checkConnectionInterval) clearInterval(this.checkConnectionInterval);
|
||||||
this.checkConnectionInterval = setInterval(() => {
|
this.checkConnectionInterval = setInterval(() => {
|
||||||
if (!this.isOpen && !this.reconnectTimeout) {
|
this.checkConnection();
|
||||||
|
}, 30000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暂停连接状态检查
|
||||||
|
pauseConnectionCheck() {
|
||||||
|
if (this.checkConnectionInterval) {
|
||||||
|
clearInterval(this.checkConnectionInterval);
|
||||||
|
this.checkConnectionInterval = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 主动检查连接状态
|
||||||
|
checkConnection() {
|
||||||
|
if (this.isAppActive && !this.isOpen && !this.reconnectTimeout) {
|
||||||
console.log('主动检查到连接断开,触发重连');
|
console.log('主动检查到连接断开,触发重连');
|
||||||
this.reconnect();
|
this.reconnect();
|
||||||
}
|
}
|
||||||
}, 30000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送消息
|
// 发送消息
|
||||||
@@ -126,12 +212,11 @@ class WebsocketUtil {
|
|||||||
if (this.socketTask && this.isOpen) {
|
if (this.socketTask && this.isOpen) {
|
||||||
this.socketTask.send({
|
this.socketTask.send({
|
||||||
data: data,
|
data: data,
|
||||||
success: (res) => {
|
success: () => {
|
||||||
// 发送成功,重置心跳(可选,根据业务需求)
|
this.startHeartbeat(); // 发送成功重置心跳
|
||||||
this.startHeartbeat();
|
|
||||||
},
|
},
|
||||||
fail: (error) => {
|
fail: (error) => {
|
||||||
console.error('消息发送失败', error);
|
console.error('消息发送失败:', error);
|
||||||
this.reconnect();
|
this.reconnect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -146,7 +231,6 @@ class WebsocketUtil {
|
|||||||
this.socketTask.onMessage((res) => {
|
this.socketTask.onMessage((res) => {
|
||||||
const data = res.data.toString();
|
const data = res.data.toString();
|
||||||
try {
|
try {
|
||||||
// 尝试解析JSON,处理pong响应
|
|
||||||
const message = JSON.parse(data);
|
const message = JSON.parse(data);
|
||||||
if (message.type === 'pong') {
|
if (message.type === 'pong') {
|
||||||
// 收到pong,清除心跳超时
|
// 收到pong,清除心跳超时
|
||||||
@@ -155,25 +239,29 @@ class WebsocketUtil {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('消息解析失败(非JSON格式):', e);
|
console.warn('消息解析失败(非JSON格式):', e);
|
||||||
}
|
}
|
||||||
// 触发外部注册的回调函数
|
// 触发外部回调
|
||||||
this.messageCallbacks.forEach(callback => callback(data));
|
this.messageCallbacks.forEach(callback => callback(data));
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.error('WebSocket 连接尚未建立,无法监听消息');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重连 WebSocket(指数退避策略)
|
// 重连 WebSocket(指数退避 + 应用活跃检测)
|
||||||
reconnect() {
|
reconnect() {
|
||||||
|
// 应用在后台时,延迟重连
|
||||||
|
if (!this.isAppActive) {
|
||||||
|
console.log('应用在后台,延迟重连');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
|
if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
|
||||||
|
|
||||||
// 达到最大重连次数,停止重试(可根据需求调整为无限重试)
|
// 达到最大重连次数,停止重试
|
||||||
if (this.reconnectAttempts >= this.reconnectMaxAttempts) {
|
if (this.reconnectAttempts >= this.reconnectMaxAttempts) {
|
||||||
console.log(`已达最大重连次数 ${this.reconnectMaxAttempts},停止重连`);
|
console.log(`已达最大重连次数 ${this.reconnectMaxAttempts},停止重连`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指数退避:延迟时间 = 基础延迟 * 2^重连次数,最大不超过maxReconnectDelay
|
// 指数退避延迟
|
||||||
const delay = Math.min(
|
const delay = Math.min(
|
||||||
this.reconnectDelay * Math.pow(2, this.reconnectAttempts),
|
this.reconnectDelay * Math.pow(2, this.reconnectAttempts),
|
||||||
this.maxReconnectDelay
|
this.maxReconnectDelay
|
||||||
@@ -186,13 +274,6 @@ class WebsocketUtil {
|
|||||||
}, delay);
|
}, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 主动检查连接状态
|
|
||||||
checkConnection() {
|
|
||||||
if (!this.isOpen && !this.reconnectTimeout) {
|
|
||||||
this.reconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭 WebSocket 连接
|
// 关闭 WebSocket 连接
|
||||||
closeSocket() {
|
closeSocket() {
|
||||||
if (this.socketTask) {
|
if (this.socketTask) {
|
||||||
@@ -202,36 +283,39 @@ class WebsocketUtil {
|
|||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
},
|
},
|
||||||
fail: (error) => {
|
fail: (error) => {
|
||||||
console.error('关闭WebSocket连接失败', error);
|
console.error('关闭WebSocket连接失败:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.socketTask = null;
|
this.socketTask = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 外部注册消息回调函数
|
// 外部注册消息回调
|
||||||
onMessage(callback) {
|
onMessage(callback) {
|
||||||
this.messageCallbacks.push(callback);
|
this.messageCallbacks.push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 外部注销消息回调函数
|
// 外部注销消息回调
|
||||||
offMessage(callback) {
|
offMessage(callback) {
|
||||||
// 若传入callback,则移除指定回调;否则清空所有回调
|
this.messageCallbacks = callback
|
||||||
if (callback) {
|
? this.messageCallbacks.filter(cb => cb !== callback)
|
||||||
this.messageCallbacks = this.messageCallbacks.filter(cb => cb !== callback);
|
: [];
|
||||||
} else {
|
|
||||||
this.messageCallbacks = [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 销毁 WebSocket 连接,清理资源
|
// 销毁 WebSocket 连接,清理资源
|
||||||
destroy() {
|
destroy() {
|
||||||
this.closeSocket();
|
this.closeSocket();
|
||||||
// 清除所有定时器
|
// 清除所有定时器
|
||||||
clearInterval(this.heartbeatInterval);
|
this.pauseHeartbeat();
|
||||||
clearTimeout(this.heartbeatTimeout);
|
this.pauseConnectionCheck();
|
||||||
clearTimeout(this.reconnectTimeout);
|
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 = [];
|
this.messageCallbacks = [];
|
||||||
console.log('WebSocket资源已销毁');
|
console.log('WebSocket资源已销毁');
|
||||||
|
|||||||
@@ -13,26 +13,8 @@ import storageManage from "@/commons/utils/storageManage.js";
|
|||||||
import infoBox from "@/commons/utils/infoBox.js";
|
import infoBox from "@/commons/utils/infoBox.js";
|
||||||
import go from "@/commons/utils/go.js";
|
import go from "@/commons/utils/go.js";
|
||||||
import { reject } from "lodash";
|
import { reject } from "lodash";
|
||||||
// 测试服
|
let baseUrl = appConfig.baseUrl
|
||||||
// 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 = '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
|
// 多少 ms 以内, 不提示loading
|
||||||
const loadingShowTime = 200;
|
const loadingShowTime = 200;
|
||||||
|
|
||||||
|
|||||||
16
http/yskApi/market/points.js
Normal file
16
http/yskApi/market/points.js
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
312
manifest.json
312
manifest.json
@@ -1,42 +1,42 @@
|
|||||||
{
|
{
|
||||||
"name": "银收客点餐宝",
|
"name" : "银收客点餐宝",
|
||||||
"appid": "__UNI__66E7BD0",
|
"appid" : "__UNI__66E7BD0",
|
||||||
"description": "",
|
"description" : "",
|
||||||
"versionName": "1.0.0",
|
"versionName" : "1.0.0",
|
||||||
"versionCode": 100,
|
"versionCode" : 100,
|
||||||
"transformPx": false,
|
"transformPx" : false,
|
||||||
"app-plus": {
|
"app-plus" : {
|
||||||
"orientation": "landscape",
|
"orientation" : "landscape",
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
"usingComponents": true,
|
"usingComponents" : true,
|
||||||
"nvueCompiler": "uni-app",
|
"nvueCompiler" : "uni-app",
|
||||||
"nvueStyleCompiler": "uni-app",
|
"nvueStyleCompiler" : "uni-app",
|
||||||
"splashscreen": {
|
"splashscreen" : {
|
||||||
"alwaysShowBeforeRender": true,
|
"alwaysShowBeforeRender" : true,
|
||||||
"waiting": true,
|
"waiting" : true,
|
||||||
"autoclose": true,
|
"autoclose" : true,
|
||||||
"delay": 0
|
"delay" : 0
|
||||||
},
|
},
|
||||||
"modules": {
|
"modules" : {
|
||||||
"Canvas": "nvue canvas", //使用Canvas模块
|
"Canvas" : "nvue canvas", //使用Canvas模块
|
||||||
"Geolocation": {},
|
"Geolocation" : {},
|
||||||
"Maps": {},
|
"Maps" : {},
|
||||||
"Barcode": {},
|
"Barcode" : {},
|
||||||
"Camera": {}
|
"Camera" : {}
|
||||||
},
|
},
|
||||||
"screenOrientation": [
|
"screenOrientation" : [
|
||||||
"portrait-primary",
|
"portrait-primary",
|
||||||
"portrait-secondary",
|
"portrait-secondary",
|
||||||
"landscape-primary",
|
"landscape-primary",
|
||||||
"landscape-secondary"
|
"landscape-secondary"
|
||||||
],
|
],
|
||||||
/* 模块配置 */
|
/* 模块配置 */
|
||||||
"distribute": {
|
"distribute" : {
|
||||||
/* 应用发布信息 */
|
/* 应用发布信息 */
|
||||||
"android": {
|
"android" : {
|
||||||
"orientation": "landscape",
|
"orientation" : "landscape",
|
||||||
/* android打包配置 */
|
/* android打包配置 */
|
||||||
"permissions": [
|
"permissions" : [
|
||||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
|
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
|
||||||
@@ -57,186 +57,186 @@
|
|||||||
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
|
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||||
],
|
],
|
||||||
"abiFilters": ["armeabi-v7a"],
|
"abiFilters" : [ "armeabi-v7a" ],
|
||||||
"permissionExternalStorage": {
|
"permissionExternalStorage" : {
|
||||||
"request": "none",
|
"request" : "none",
|
||||||
"prompt": "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
|
"prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
|
||||||
},
|
},
|
||||||
"permissionPhoneState": {
|
"permissionPhoneState" : {
|
||||||
"request": "none",
|
"request" : "none",
|
||||||
"prompt": "为保证您正常、安全地使用,需要获取设备识别码(部分手机提示为获取手机号码)使用权限,请允许。"
|
"prompt" : "为保证您正常、安全地使用,需要获取设备识别码(部分手机提示为获取手机号码)使用权限,请允许。"
|
||||||
},
|
},
|
||||||
"autoSdkPermissions": true,
|
"autoSdkPermissions" : true,
|
||||||
"targetSdkVersion": 26,
|
"targetSdkVersion" : 26,
|
||||||
"minSdkVersion": 21
|
"minSdkVersion" : 21
|
||||||
},
|
},
|
||||||
"ios": {
|
"ios" : {
|
||||||
"dSYMs": false
|
"dSYMs" : false
|
||||||
},
|
},
|
||||||
/* ios打包配置 */
|
/* ios打包配置 */
|
||||||
"sdkConfigs": {
|
"sdkConfigs" : {
|
||||||
"geolocation": {
|
"geolocation" : {
|
||||||
"amap": {
|
"amap" : {
|
||||||
"__platform__": ["ios", "android"],
|
"__platform__" : [ "ios", "android" ],
|
||||||
"appkey_ios": "0b9be2631525ee5e218ac26d333f215c",
|
"appkey_ios" : "0b9be2631525ee5e218ac26d333f215c",
|
||||||
"appkey_android": "9d1e62050f8558a082f7aa3ad5bb3c68"
|
"appkey_android" : "9d1e62050f8558a082f7aa3ad5bb3c68"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"maps": {
|
"maps" : {
|
||||||
"amap": {
|
"amap" : {
|
||||||
"appkey_ios": "0b9be2631525ee5e218ac26d333f215c",
|
"appkey_ios" : "0b9be2631525ee5e218ac26d333f215c",
|
||||||
"appkey_android": "9d1e62050f8558a082f7aa3ad5bb3c68"
|
"appkey_android" : "9d1e62050f8558a082f7aa3ad5bb3c68"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ad": {},
|
"ad" : {},
|
||||||
"push": {}
|
"push" : {}
|
||||||
},
|
},
|
||||||
"icons": {
|
"icons" : {
|
||||||
"android": {
|
"android" : {
|
||||||
"hdpi": "unpackage/res/icons/72x72.png",
|
"hdpi" : "unpackage/res/icons/72x72.png",
|
||||||
"xhdpi": "unpackage/res/icons/96x96.png",
|
"xhdpi" : "unpackage/res/icons/96x96.png",
|
||||||
"xxhdpi": "unpackage/res/icons/144x144.png",
|
"xxhdpi" : "unpackage/res/icons/144x144.png",
|
||||||
"xxxhdpi": "unpackage/res/icons/192x192.png"
|
"xxxhdpi" : "unpackage/res/icons/192x192.png"
|
||||||
},
|
},
|
||||||
"ios": {
|
"ios" : {
|
||||||
"appstore": "unpackage/res/icons/1024x1024.png",
|
"appstore" : "unpackage/res/icons/1024x1024.png",
|
||||||
"ipad": {
|
"ipad" : {
|
||||||
"app": "unpackage/res/icons/76x76.png",
|
"app" : "unpackage/res/icons/76x76.png",
|
||||||
"app@2x": "unpackage/res/icons/152x152.png",
|
"app@2x" : "unpackage/res/icons/152x152.png",
|
||||||
"notification": "unpackage/res/icons/20x20.png",
|
"notification" : "unpackage/res/icons/20x20.png",
|
||||||
"notification@2x": "unpackage/res/icons/40x40.png",
|
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||||
"proapp@2x": "unpackage/res/icons/167x167.png",
|
"proapp@2x" : "unpackage/res/icons/167x167.png",
|
||||||
"settings": "unpackage/res/icons/29x29.png",
|
"settings" : "unpackage/res/icons/29x29.png",
|
||||||
"settings@2x": "unpackage/res/icons/58x58.png",
|
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||||
"spotlight": "unpackage/res/icons/40x40.png",
|
"spotlight" : "unpackage/res/icons/40x40.png",
|
||||||
"spotlight@2x": "unpackage/res/icons/80x80.png"
|
"spotlight@2x" : "unpackage/res/icons/80x80.png"
|
||||||
},
|
},
|
||||||
"iphone": {
|
"iphone" : {
|
||||||
"app@2x": "unpackage/res/icons/120x120.png",
|
"app@2x" : "unpackage/res/icons/120x120.png",
|
||||||
"app@3x": "unpackage/res/icons/180x180.png",
|
"app@3x" : "unpackage/res/icons/180x180.png",
|
||||||
"notification@2x": "unpackage/res/icons/40x40.png",
|
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||||
"notification@3x": "unpackage/res/icons/60x60.png",
|
"notification@3x" : "unpackage/res/icons/60x60.png",
|
||||||
"settings@2x": "unpackage/res/icons/58x58.png",
|
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||||
"settings@3x": "unpackage/res/icons/87x87.png",
|
"settings@3x" : "unpackage/res/icons/87x87.png",
|
||||||
"spotlight@2x": "unpackage/res/icons/80x80.png",
|
"spotlight@2x" : "unpackage/res/icons/80x80.png",
|
||||||
"spotlight@3x": "unpackage/res/icons/120x120.png"
|
"spotlight@3x" : "unpackage/res/icons/120x120.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"splashscreen": {
|
"splashscreen" : {
|
||||||
"alwaysShowBeforeRender": true,
|
"alwaysShowBeforeRender" : true,
|
||||||
"autoclose": true,
|
"autoclose" : true,
|
||||||
"delay": 0,
|
"delay" : 0,
|
||||||
"orientation": "landscape",
|
"orientation" : "landscape",
|
||||||
"androidStyle": "default",
|
"androidStyle" : "default",
|
||||||
"android": {
|
"android" : {
|
||||||
"hdpi": "C:/Users/Administrator/Desktop/bg.png",
|
"hdpi" : "static/login/bg.png",
|
||||||
"xhdpi": "C:/Users/Administrator/Desktop/bg.png",
|
"xhdpi" : "static/login/bg.png",
|
||||||
"xxhdpi": "C:/Users/Administrator/Desktop/bg.png"
|
"xxhdpi" : "static/login/bg.png"
|
||||||
},
|
},
|
||||||
"useOriginalMsgbox": true,
|
"useOriginalMsgbox" : true,
|
||||||
"iosStyle": "storyboard",
|
"iosStyle" : "storyboard",
|
||||||
"ios": {
|
"ios" : {
|
||||||
"storyboard": "C:/Users/Administrator/Downloads/CustomStoryboard.zip"
|
"storyboard" : "C:/Users/Administrator/Downloads/CustomStoryboard.zip"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* SDK配置 */
|
/* SDK配置 */
|
||||||
"quickapp": {},
|
"quickapp" : {},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
"mp-weixin": {
|
"mp-weixin" : {
|
||||||
"appid": "wxd88fffa983758a30",
|
"appid" : "wxd88fffa983758a30",
|
||||||
"setting": {
|
"setting" : {
|
||||||
"urlCheck": false,
|
"urlCheck" : false,
|
||||||
"minified": true,
|
"minified" : true,
|
||||||
"postcss": true,
|
"postcss" : true,
|
||||||
"es6": true
|
"es6" : true
|
||||||
},
|
},
|
||||||
"optimization": {
|
"optimization" : {
|
||||||
"subPackages": true
|
"subPackages" : true
|
||||||
},
|
},
|
||||||
"usingComponents": true,
|
"usingComponents" : true,
|
||||||
"libVersion": "latest"
|
"libVersion" : "latest"
|
||||||
},
|
},
|
||||||
"vueVersion": "3",
|
"vueVersion" : "3",
|
||||||
"h5": {
|
"h5" : {
|
||||||
"unipush": {
|
"unipush" : {
|
||||||
"enable": true
|
"enable" : true
|
||||||
},
|
},
|
||||||
"devServer": {
|
"devServer" : {
|
||||||
"disableHostCheck": true,
|
"disableHostCheck" : true,
|
||||||
"proxy": {
|
"proxy" : {
|
||||||
"/shopApi": {
|
"/shopApi" : {
|
||||||
// 需要被代理的后台地址
|
// 需要被代理的后台地址
|
||||||
"target": "http://192.168.1.42",
|
"target" : "http://192.168.1.42",
|
||||||
"changeOrigin": true,
|
"changeOrigin" : true,
|
||||||
"secure": false,
|
"secure" : false,
|
||||||
"pathRewrite": {
|
"pathRewrite" : {
|
||||||
"^/shopApi": ""
|
"^/shopApi" : ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/mch": {
|
"/mch" : {
|
||||||
// 需要被代理的后台地址
|
// 需要被代理的后台地址
|
||||||
"target": "http://192.168.1.42",
|
"target" : "http://192.168.1.42",
|
||||||
"changeOrigin": true,
|
"changeOrigin" : true,
|
||||||
"secure": false,
|
"secure" : false,
|
||||||
"pathRewrite": {
|
"pathRewrite" : {
|
||||||
"^/mch": ""
|
"^/mch" : ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/server1": {
|
"/server1" : {
|
||||||
// 需要被代理的后台地址
|
// 需要被代理的后台地址
|
||||||
"target": "http://192.168.1.42",
|
"target" : "http://192.168.1.42",
|
||||||
"changeOrigin": true,
|
"changeOrigin" : true,
|
||||||
"secure": false,
|
"secure" : false,
|
||||||
"pathRewrite": {
|
"pathRewrite" : {
|
||||||
"^/server1": ""
|
"^/server1" : ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/server3": {
|
"/server3" : {
|
||||||
// 需要被代理的后台地址
|
// 需要被代理的后台地址
|
||||||
"target": "http://192.168.1.42",
|
"target" : "http://192.168.1.42",
|
||||||
"changeOrigin": true,
|
"changeOrigin" : true,
|
||||||
"secure": false,
|
"secure" : false,
|
||||||
"pathRewrite": {
|
"pathRewrite" : {
|
||||||
"^/server3": ""
|
"^/server3" : ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/ysk": {
|
"/ysk" : {
|
||||||
// 需要被代理的后台地址
|
// 需要被代理的后台地址
|
||||||
"target": "http://192.168.1.42",
|
"target" : "http://192.168.1.42",
|
||||||
"changeOrigin": true,
|
"changeOrigin" : true,
|
||||||
"secure": false,
|
"secure" : false,
|
||||||
"pathRewrite": {
|
"pathRewrite" : {
|
||||||
"^/ysk": ""
|
"^/ysk" : ""
|
||||||
}
|
}
|
||||||
|
},
|
||||||
// "onProxyRes": function(proxyRes, req, res) {
|
// "onProxyRes": function(proxyRes, req, res) {
|
||||||
// // proxyRes.headers['Content-Type'] = 'application/json';
|
// // proxyRes.headers['Content-Type'] = 'application/json';
|
||||||
// },
|
// },
|
||||||
},
|
"/ww" : {
|
||||||
"/ww": {
|
|
||||||
// 需要被代理的后台地址
|
// 需要被代理的后台地址
|
||||||
"target": "http://192.168.1.42",
|
"target" : "http://192.168.1.42",
|
||||||
"changeOrigin": true,
|
"changeOrigin" : true,
|
||||||
"secure": false,
|
"secure" : false,
|
||||||
"pathRewrite": {
|
"pathRewrite" : {
|
||||||
"/ww": ""
|
"/ww" : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sdkConfigs": {
|
"sdkConfigs" : {
|
||||||
"maps": {
|
"maps" : {
|
||||||
"amap": {
|
"amap" : {
|
||||||
"key": "6033c97e67bf2e9ceac306e1a3fa35f8",
|
"key" : "6033c97e67bf2e9ceac306e1a3fa35f8",
|
||||||
"securityJsCode": "0547b69252ef0ed14e11f5c4ac152f07",
|
"securityJsCode" : "0547b69252ef0ed14e11f5c4ac152f07",
|
||||||
"serviceHost": ""
|
"serviceHost" : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mp-alipay": {
|
"mp-alipay" : {
|
||||||
"appid": "2021004128648214"
|
"appid" : "2021004128648214"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="u-m-l-30 u-flex">
|
<view class="u-m-l-30 u-flex">
|
||||||
<text class="">积分:</text>
|
<text class="">积分:</text>
|
||||||
<text class="color-main">{{item.accountPoints}}</text>
|
<text class="color-main">{{item.pointBalance||0}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -204,7 +204,7 @@
|
|||||||
<view class="">积分抵扣</view>
|
<view class="">积分抵扣</view>
|
||||||
<view class="color-999 u-m-l-10">
|
<view class="color-999 u-m-l-10">
|
||||||
<text>(</text>
|
<text>(</text>
|
||||||
<text>{{ pageData.user.accountPoints || "0" }}</text>
|
<text>{{ pageData.user.pointBalance || "0" }}</text>
|
||||||
<text>)</text>
|
<text>)</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view><text class="color-red font-bold">{{accountPoints.price}}</text>元</view> -->
|
<!-- <view><text class="color-red font-bold">{{accountPoints.price}}</text>元</view> -->
|
||||||
@@ -215,16 +215,15 @@
|
|||||||
><text>{{ accountPoints.num }}</text></view
|
><text>{{ accountPoints.num }}</text></view
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
v-if="accountPoints.calcRes.usable"
|
v-if="pointDeductionRule.enableRewards"
|
||||||
@click.stop="refPointsOpen"
|
@click.stop="refPointsOpen"
|
||||||
>
|
>
|
||||||
<up-icon name="edit-pen" size="16" color="#999"></up-icon>
|
<up-icon name="edit-pen" size="16" color="#999"></up-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="u-m-l-32 u-relative"
|
class="u-m-l-32 u-relative"
|
||||||
v-if="accountPoints.calcRes.usable"
|
v-if="pointDeductionRule.enableRewards"
|
||||||
>
|
>
|
||||||
<view class="u-absolute position-all"></view>
|
<view class="u-absolute position-all"></view>
|
||||||
<my-radio :modelValue="accountPoints.sel"> </my-radio>
|
<my-radio :modelValue="accountPoints.sel"> </my-radio>
|
||||||
@@ -238,15 +237,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="" v-if="accountPoints.calcRes.usable">
|
<view class="" v-if="accountPoints.calcRes.usable">
|
||||||
<text class="color-red">*</text>
|
<text class="color-red">*</text>
|
||||||
<text class="" v-if="accountPoints.calcRes.equivalentPoints"
|
<text class="" v-if="pointDeductionRule.enableRewards"
|
||||||
>{{
|
>「可用积分{{ pageData.user.id?pageData.user.pointBalance:0}},最大可抵扣{{
|
||||||
accountPoints.calcRes.equivalentPoints
|
maxPointDiscount
|
||||||
}}积分等于1元,</text
|
}}元」</text
|
||||||
>
|
>
|
||||||
<text>
|
|
||||||
最大抵扣积分{{ accountPoints.calcRes.maxUsablePoints }}
|
|
||||||
</text>
|
|
||||||
<text>, 最小抵扣积分0 </text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-60 u-p-b-30">
|
<view class="u-m-t-60 u-p-b-30">
|
||||||
@@ -355,6 +351,7 @@ const cartStore = useCartStore();
|
|||||||
import { getHistoryOrder } from "@/http/api/order.js";
|
import { getHistoryOrder } from "@/http/api/order.js";
|
||||||
import { getPayTypeList } from "@/http/api/payType.js";
|
import { getPayTypeList } from "@/http/api/payType.js";
|
||||||
import { shopUserDetail } from "@/http/api/shopUser.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 { discountActivity } from "@/http/yskApi/market/discountActivity.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -448,11 +445,34 @@ async function getDiscountActivity() {
|
|||||||
fullReductionActivities.value = res ? [res] : [];
|
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) => {
|
onLoad(async (opt) => {
|
||||||
Object.assign(order, opt);
|
Object.assign(order, opt);
|
||||||
Object.assign(options, opt);
|
Object.assign(options, opt);
|
||||||
await getPayType();
|
await getPayType();
|
||||||
await getDiscountActivity();
|
await getDiscountActivity();
|
||||||
|
await getPointsConfig()
|
||||||
console.log("pays.payTypes.list");
|
console.log("pays.payTypes.list");
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
@@ -572,8 +592,11 @@ const merchantReductionConfig = reactive({
|
|||||||
});
|
});
|
||||||
//积分规则
|
//积分规则
|
||||||
const pointDeductionRule = reactive({
|
const pointDeductionRule = reactive({
|
||||||
|
enableRewards: 0, //是否开启
|
||||||
pointsPerYuan: 0,
|
pointsPerYuan: 0,
|
||||||
maxDeductionAmount: Infinity,
|
maxDeductionAmount: Infinity,
|
||||||
|
maxDeductionRatio: 0, //积分抵扣比例
|
||||||
|
minPaymentAmount: 0, //门槛
|
||||||
});
|
});
|
||||||
//餐费费
|
//餐费费
|
||||||
const seatFeeConfig = reactive({
|
const seatFeeConfig = reactive({
|
||||||
@@ -674,7 +697,7 @@ watch(
|
|||||||
() => accountPoints.sel,
|
() => accountPoints.sel,
|
||||||
(newval) => {
|
(newval) => {
|
||||||
if (newval) {
|
if (newval) {
|
||||||
userPoints.value = accountPoints.num;
|
userPoints.value = maxCanUsePoints.value
|
||||||
} else {
|
} else {
|
||||||
userPoints.value = 0;
|
userPoints.value = 0;
|
||||||
}
|
}
|
||||||
@@ -876,6 +899,11 @@ function pointsConfirm(e) {
|
|||||||
accountPoints.num = e;
|
accountPoints.num = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const maxPointDiscount=ref(0)
|
||||||
|
const maxCanUsePoints=ref(0)
|
||||||
/**
|
/**
|
||||||
* 获取积分信息
|
* 获取积分信息
|
||||||
* @param {Object} orderAmount
|
* @param {Object} orderAmount
|
||||||
@@ -884,20 +912,37 @@ async function getCalcUsablePoints() {
|
|||||||
if (!pageData.user.userId) {
|
if (!pageData.user.userId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await calcUsablePoints({
|
|
||||||
shopUserId: pageData.user.id,
|
|
||||||
orderAmount: pointsCanDicountMaxMoney.value,
|
let userAccountPoints = pageData.user ? pageData.user.pointBalance*1 : 0;
|
||||||
});
|
|
||||||
console.log("getCalcUsablePoints", res);
|
//1积分等于多少钱
|
||||||
pointDeductionRule.pointsPerYuan = res.equivalentPoints;
|
const onePointsMoney = pointDeductionRule.pointsPerYuan ? ((1 || 0) / pointDeductionRule.pointsPerYuan) : 0
|
||||||
pointDeductionRule.maxDeductionAmount = res.maxDeductionAmount;
|
|
||||||
accountPoints.calcRes = res;
|
|
||||||
accountPoints.num = res.maxUsablePoints;
|
const calcMaxDiscount = Math.floor(pointsCanDicountMaxMoney.value * (pointDeductionRule.maxDeductionRatio / 100))
|
||||||
return res;
|
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() {
|
function changeAccountPoints() {
|
||||||
if (!accountPoints.calcRes.usable) {
|
if (!pointDeductionRule.enableRewards) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
accountPoints.sel = !accountPoints.sel;
|
accountPoints.sel = !accountPoints.sel;
|
||||||
|
|||||||
@@ -269,6 +269,9 @@ export const useCartStore = defineStore("cart", {
|
|||||||
*/
|
*/
|
||||||
async getOrder() {
|
async getOrder() {
|
||||||
console.log("获取历史订单数据");
|
console.log("获取历史订单数据");
|
||||||
|
if(!this.order.id){
|
||||||
|
return
|
||||||
|
}
|
||||||
const res = await orderApi.getOrderById({ orderId: this.order.id });
|
const res = await orderApi.getOrderById({ orderId: this.order.id });
|
||||||
if (res) {
|
if (res) {
|
||||||
this.setOrder(res);
|
this.setOrder(res);
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/server3': {
|
'/testApi': {
|
||||||
target: 'http://192.168.1.42', // 目标服务
|
target: 'http://192.168.1.42', // 目标服务
|
||||||
changeOrigin: true,
|
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,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/ysk/, '')
|
rewrite: (path) => path.replace(/^\/proApi/, '')
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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, '/')
|
|
||||||
}])
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user