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',
API_PREFIX: '',
// MQTT 配置
MQTT_HOST: '47.120.79.150',
MQTT_PORT: 8083,
MQTT_HOST: 'www.cnxhyc.com',
MQTT_PORT: 9083,
MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG'
},
@ -15,8 +15,8 @@ const config = {
BASE_URL: 'https://fuyuanshen.com/backend',
API_PREFIX: '',
// MQTT 配置
MQTT_HOST: '47.120.79.150',
MQTT_PORT: 8083,
MQTT_HOST: 'www.cnxhyc.com',
MQTT_PORT: 9084,
MQTT_USERNAME: 'admin',
MQTT_PASSWORD: '#YtvpSfCNG'
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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