소스 검색

提交优化代码

wangming 1 개월 전
부모
커밋
74ea39cb2f
2개의 변경된 파일25개의 추가작업 그리고 13개의 파일을 삭제
  1. 21 4
      src/pages/home/home.vue
  2. 4 9
      src/utils/globalMqtt.js

+ 21 - 4
src/pages/home/home.vue

@@ -73,12 +73,12 @@
             </view>
         </view>
 
-        <!-- <view class="bottom">
+        <view class="bottom">
             <image src="../../static/linkService.png" mode="" />
             <button open-type="contact">联系客服</button>
-        </view> -->
+        </view>
 
-        <movable-area class="movable-area" direction="all">
+        <!-- <movable-area class="movable-area" direction="all">
             <movable-view
                 class="movable-button"
                 :x="pos.x"
@@ -93,7 +93,7 @@
                 <span class="pulse"></span>
                 <button open-type="contact" class="contact-btn"></button>
             </movable-view>
-        </movable-area>
+        </movable-area> -->
 
         <view class="bot_version"> v3.0.12 </view>
         <view
@@ -554,6 +554,23 @@ export default {
     height: 28rpx;
 }
 
+.bottom button {
+    all: unset;
+    margin: 0;
+    padding: 0;
+    border: none;
+    background: none;
+    font: inherit;
+    text-align: inherit;
+    line-height: normal;
+    outline: none;
+    box-shadow: none;
+    -webkit-appearance: none;
+    margin-left: 6rpx;
+    color: #a1aab4;
+    font-size: 28rpx;
+}
+
 .bot_version {
     opacity: 0.4;
     position: absolute;

+ 4 - 9
src/utils/globalMqtt.js

@@ -52,18 +52,13 @@ export function createMqttClient() {
     client.on("message", (topic, message) => {
         console.log("topic", topic, message);
         console.log("接收到消息:", JSON.parse(message.toString()));
-        const userId = uni.getStorageSync("userId");
         const noticeMatch = /^\/mps\/wx_(.+)\/notice$/;
         const match = topic.match(noticeMatch);
         if (!match) return;
     });
     client.on("error", (err) => {
         mqttCmdConnected = false;
-        console.error("MQTT连接错误:", err);
-        // 连接失败时重新尝试连接
-        setTimeout(() => {
-            createMqttClient();  // 重新连接
-        }, 1000);
+        console.error("MQTTCMD连接错误:", err);
     });
 
     client.on("disconnect", () => {
@@ -83,9 +78,10 @@ export function createMqttData() {
     if (mqttDataConnected) return mqttClientData;
 
     const params = {
-        keepalive: 15,
+        // keepalive: 15,
         // clean: false,
         // connectTimeout: 1500,
+        // reconnectPeriod: 2000
         clientId: "xcx_mqtt_data1_" + uni.getStorageSync("userId") + "_" + Date.now(),
         username: "lnradar",
         password: "lnradar",
@@ -98,7 +94,6 @@ export function createMqttData() {
                 protocols: ["mqtt"],
             });
         },
-        reconnectPeriod: 2000
     };
 
     mqttClientData = mqtt.connect("wxs://data.radar-power.cn/mqtt/", params);
@@ -115,7 +110,7 @@ export function createMqttData() {
 
     });
 
-    mqttClientData.on("error", (err) => { mqttDataConnected = false; console.error(err); });
+    mqttClientData.on("error", (err) => { mqttDataConnected = false; console.error("MQTTDATA连接错误:", err); });
     mqttClientData.on("disconnect", () => { mqttDataConnected = false; console.log("DATA MQTT 断开"); });
     mqttClientData.close = function (force = true) {
         mqttClientData.end(force, () => {