1
0
forked from dyf/APP

Merge branch 'new-20250827' of http://47.107.152.87:3000/liubiao/APP into new-20250827

# Conflicts:
#	pages/670/HBY670.vue
This commit is contained in:
liub
2025-09-23 12:00:43 +08:00
8 changed files with 30 additions and 25 deletions

View File

@ -5,8 +5,8 @@ const config = {
BASE_URL: 'http://192.168.2.34:8000', BASE_URL: 'http://192.168.2.34:8000',
API_PREFIX: '', API_PREFIX: '',
// MQTT 配置 // MQTT 配置
MQTT_HOST: '47.120.79.150', MQTT_HOST: 'www.cnxhyc.com',
MQTT_PORT: 8083, MQTT_PORT: 9083,
MQTT_USERNAME: 'admin', MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG' MQTT_PASSWORD: '#YtvpSfCNG'
}, },
@ -15,8 +15,8 @@ const config = {
BASE_URL: 'https://fuyuanshen.com/backend', BASE_URL: 'https://fuyuanshen.com/backend',
API_PREFIX: '', API_PREFIX: '',
// MQTT 配置 // MQTT 配置
MQTT_HOST: '47.120.79.150', MQTT_HOST: 'www.cnxhyc.com',
MQTT_PORT: 8083, MQTT_PORT: 9084,
MQTT_USERNAME: 'admin', MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG' MQTT_PASSWORD: '#YtvpSfCNG'
} }

View File

@ -178,26 +178,26 @@
} }
}, },
{ {
"path": "pages/6170/allShare/index", "path": "pages/common/allShare/index",
"style": { "style": {
"navigationBarTitleText": "所有分享" "navigationBarTitleText": "所有分享"
} }
}, },
{ {
"path": "pages/6170/share/index", "path": "pages/common/share/index",
"style": { "style": {
"navigationBarTitleText": "分享" "navigationBarTitleText": "分享"
} }
}, },
{ {
"path": "pages/6170/shareDevices/index", "path": "pages/common/shareDevices/index",
"style": { "style": {
"navigationBarTitleText": "分享设备" "navigationBarTitleText": "分享设备"
} }
}, },
{ {
"path": "pages/6170/shareManagement/index", "path": "pages/common/shareManagement/index",
"style": { "style": {
"navigationBarTitleText": "分享管理" "navigationBarTitleText": "分享管理"
} }

View File

@ -757,7 +757,7 @@
// 分享 // 分享
shareUp() { shareUp() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/6170/share/index', url: '/pages/common/share/index',
events: { events: {
ack: function(data) {} ack: function(data) {}
}, },

View File

@ -25,7 +25,7 @@
// //
shareDevice(){ shareDevice(){
uni.navigateTo({ uni.navigateTo({
url: '/pages/6170/shareDevices/index', url: '/pages/common/shareDevices/index',
events: { events: {
ack: function(data) {} ack: function(data) {}
}, },
@ -39,7 +39,7 @@
// //
shareManagement(){ shareManagement(){
uni.navigateTo({ uni.navigateTo({
url: '/pages/6170/shareManagement/index', url: '/pages/common/shareManagement/index',
events: { events: {
ack: function(data) {} ack: function(data) {}
}, },

View File

@ -227,7 +227,7 @@
handleBtn() { handleBtn() {
this.shareShow = false this.shareShow = false
uni.navigateTo({ uni.navigateTo({
url: '/pages/6170/allShare/index' url: '/pages/common/allShare/index'
}) })
}, },
}, },

View File

@ -171,8 +171,10 @@
}, },
// //
handleFile(item) { handleFile(item) {
let url = item.detailPageUrl;
console.log(item,'item');
uni.navigateTo({ uni.navigateTo({
url: "/pages/6170/deviceControl/index", url: url,
success: (res) => { success: (res) => {
// //
res.eventChannel.emit('detailData', { res.eventChannel.emit('detailData', {

View File

@ -117,19 +117,20 @@
*/ */
import Paho from 'paho-mqtt'; import Paho from 'paho-mqtt';
import allConfigs from '../config/index.js'; import allConfigs from '../config/index.js';
// 根据环境选择正确的配置 // 根据环境选择正确的配置
const env = 'production'; //production //开发of线上 改这里就行 const env = 'production'; //production development
const config = allConfigs[env]; const envConfig = allConfigs[env];
const mqttProtocol = env === 'production' ? 'wss' : 'ws';
const useSSL = env === 'production';
class MqttClient { class MqttClient {
constructor() { constructor() {
this.client = null; this.client = null;
this.options = { this.options = {
host: config.MQTT_HOST, host: envConfig.MQTT_HOST,
port: config.MQTT_PORT, port: envConfig.MQTT_PORT,
clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8), clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
username: config.MQTT_USERNAME, username: envConfig.MQTT_USERNAME,
password: config.MQTT_PASSWORD, password: envConfig.MQTT_PASSWORD,
}; };
this.onConnectCallback = null; this.onConnectCallback = null;
this.messageCallbacks = new Map(); this.messageCallbacks = new Map();
@ -170,7 +171,7 @@ class MqttClient {
potentialJsons.forEach(jsonString => { potentialJsons.forEach(jsonString => {
if (jsonString.trim() === '') return; if (jsonString.trim() === '') return;
if (this.messageCallbacks.has(topic)) { if (this.messageCallbacks.has(topic)) {
this.messageCallbacks.get(topic)(jsonString,message); this.messageCallbacks.get(topic)(jsonString, message);
} }
}); });
}; };
@ -189,16 +190,18 @@ class MqttClient {
this.manualDisconnect = false; this.manualDisconnect = false;
this.onConnectCallback = onConnectCallback; this.onConnectCallback = onConnectCallback;
console.log(`环境识别http https${env}`, {
console.log(`正在连接MQTT: ${this.options.host}:${this.options.port}/mqtt`); connectUrl: `${mqttProtocol}://${this.options.host}:${this.options.port}/mqtt`,
useSSL: useSSL,
clientId: this.options.clientId
});
try { try {
const connectOptions = { const connectOptions = {
timeout: 10, // 增加连接超时时间,应对网络波动 timeout: 10, // 增加连接超时时间,应对网络波动
keepAliveInterval: 30, // 明确设置心跳间隔为30秒 keepAliveInterval: 30, // 明确设置心跳间隔为30秒
userName: this.options.username, userName: this.options.username,
password: this.options.password, password: this.options.password,
useSSL: false, useSSL: useSSL, //http ws https wss开启
cleanSession: true, cleanSession: true,
onSuccess: () => { onSuccess: () => {
console.log('MQTT连接成功'); console.log('MQTT连接成功');