diff --git a/config.js b/config.js
index c882b80..9e80a59 100644
--- a/config.js
+++ b/config.js
@@ -1,7 +1,8 @@
// 应用全局配置
module.exports = {
// baseUrl: 'https://vue.ruoyi.vip/prod-api',
- baseUrl: 'http://localhost:8088',
+ // baseUrl: 'http://localhost:8088',
+ baseUrl: 'http://1.94.254.176:8088',
// 应用信息
appInfo: {
// 应用名称
diff --git a/main.js b/main.js
index ab2c781..a6e0a62 100644
--- a/main.js
+++ b/main.js
@@ -1,4 +1,5 @@
import Vue from 'vue'
+
import App from './App'
import store from './store' // store
import plugins from './plugins' // plugins
diff --git a/pages/demo/index.vue b/pages/demo/index.vue
index 358d84c..9a2272f 100644
--- a/pages/demo/index.vue
+++ b/pages/demo/index.vue
@@ -1,166 +1,138 @@
-
-
-
-
-
-
- {{ album.photos.length }}张
-
-
- {{ album.name }}
- {{ album.date }}
-
-
-
-
-
-
- 暂无相册
-
-
-
-
-
-
- {{ isAllSelected ? '取消全选' : '全选' }}
-
-
-
+
+
+
+
+ {{ temp1 }}
+ 温度1 ℃
+
+
+
+
+ {{ temp2 }}
+ 温度2
+
+
+
+
+ {{ temp3 }}
+ 温度3
+
+
+
+
+ {{ temp4 }}
+ 温度4
+
+
+
+
+
+
+ {{ humi1 }}
+ 湿度1
+
+
+
+
+ {{ humi2 }}
+ 湿度2
+
+
+
+
+ {{ humi3 }}
+ 湿度3
+
+
+
+
+ {{ humi4 }}
+ 湿度4 %RH
+
+
+
+
diff --git a/utils/mqtt.js b/utils/mqtt.js
new file mode 100644
index 0000000..f970a65
--- /dev/null
+++ b/utils/mqtt.js
@@ -0,0 +1,68 @@
+import mqtt from 'mqtt/dist/mqtt.js' //引入mqtt依赖
+
+var client
+let mqttConnected = false //mqtt连接状态,这个可以不要,直接查询client.connected即可
+const publishTopic = '/test/123/456/set' //发布Topic
+const MQTT_IP = '192.168.9.128:8083/mqtt' //mqtt地址端口
+const MQTT_OPTIONS = {
+ connectTimeout: 5000, //连接超时时间
+ clientId: 'SiD0FMMAxrs', //clientId不能重复,这里可以随机生成
+ username: 'test', //用户名
+ password: 'test', //密码
+ clean: false
+}
+
+//创建客户端连接
+export function mqttConnect() {
+ // #ifdef H5
+ client = mqtt.connect('ws://' + MQTT_IP, MQTT_OPTIONS,function(err){
+ console.log(err)
+ })
+ // #endif
+ // #ifdef MP-WEIXIN||APP-PLUS
+ client = mqtt.connect('wx://' + MQTT_IP, MQTT_OPTIONS,function(err){
+ console.log(err)
+ })
+ // #endif
+
+ client.on('connect', function() {
+ console.log('连接成功')
+ mqttConnected = true
+ }).on('reconnect', function(error) {
+ console.log('正在重连...', error)
+ mqttConnected = false
+ }).on('error', function(error) {
+ console.log('连接失败...', error)
+ mqttConnected = false
+ }).on('end', function() {
+ console.log('连接断开')
+ mqttConnected = false
+ }).on('close',function(){
+ console.log('连接关闭')
+ mqttConnected = false
+ }).on('offline',function(){
+ console.log('客户端下线')
+ })
+}
+//发布消息
+export function mqttPublish(msg){
+ if(mqttConnected){
+ client.publish(publishTopic,msg,{qos:1,retain:false});//hello mqtt +
+ console.log('发布了一条消息',msg)
+ }else{
+ uni.showToast({
+ title: 'MQTT服务器未连接',
+ icon: 'none'
+ });
+ }
+}
+//断开连接
+export function mqttDisconnect(){
+ console.log('mqttConnected',mqttConnected)
+ console.log('client',client)
+ if(mqttConnected){
+ client.end(true)
+ mqttConnected = false
+ }
+
+}