diff --git a/miniprogram/app.js b/miniprogram/app.js index ab933b9..ac74a45 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -9,10 +9,12 @@ App({ DOMAIN_NAME_PREFIX: 'http://192.168.0.30', DOMAIN_NAME: 'http://192.168.0.30:9227', //接口域名 IMG_NAME: 'http://192.168.0.30:9227', + socketUrl: 'wss://company.haxy.com.cn:4443/changyang-office/websocket-server', // 生产 // DOMAIN_NAME_PREFIX: 'https://www.chuangzhikj.com', // DOMAIN_NAME: 'https://www.chuangzhikj.com/saas-ics', //接口域名 // IMG_NAME: 'https://www.chuangzhikj.com/saas-ics', + // socketUrl: 'wss://company.haxy.com.cn:4443/changyang-office/websocket-server', globals: { refreshMyPages: false, homedata: {}, diff --git a/miniprogram/pages/smartDevice/room/room.js b/miniprogram/pages/smartDevice/room/room.js index 8a0a253..9bd2c5b 100644 --- a/miniprogram/pages/smartDevice/room/room.js +++ b/miniprogram/pages/smartDevice/room/room.js @@ -297,14 +297,85 @@ Page({ // 初始化socket initSocket() { + return + let _this = this let socketTask = wx.connectSocket({ - url: 'ws:///222.184.49.22:8081/websocket-server', + url: app.socketUrl, header: { 'content-type': 'application/json' } }) - socketTask.onMessage(res=>{ - console.log('onMessage' , res); + socketTask.onMessage(res => { + // + console.log('onMessage data', res.data); + console.log('onMessage data', JSON.parse(res.data)); + let equipmentList = _this.data.equipmentList; + // 推送数据 + let sendData = JSON.parse(res.data); + // 推送内容 + let pushMsg = sendData.pushMsg; + // 设备类型 + let type = pushMsg.type + // 推送类型 + let pushMsgType = sendData.pushMsgType + + + // + if (type == 'KONKE_ZIGBEE_CHOPIN_LIGHT_PROJECT') { // 灯控面板、雾化玻璃 + let id = pushMsg.id + let on = pushMsg.status.on // true 开 false 关 + let equipmentData = equipmentList.find(item => item.id == id) + if (equipmentData) { + equipmentData.status = on + } + + } else if (type == 'KONKE_ZIGBEE_Z3S_GALAXY_DIMMER_LIGHT') { // 调光灯 + let id = pushMsg.id + let on = pushMsg.status.on // true 开 false 关 + let brightness = pushMsg.status.brightness // 亮度 [1,100] + let whiteBri = pushMsg.status.whiteBri // 白光亮度 [1,100] + let colourTemperature = pushMsg.status.colourTemperature // 色温[1,100] + // + let equipmentData = equipmentList.find(item => item.id == id) + if (equipmentData) { + equipmentData.status = on + } + + } else if (type == 'KONKE_ZIGBEE_CHOPIN_CURTAIN_CUSTOM') { // 窗帘 + let id = pushMsg.id + let MotorStatus = pushMsg.status.MotorStatus // OPEN 开 、CLOSE 关、 STOP 暂停 + let equipmentData = equipmentList.find(item => item.id == id) + equipmentData.status = MotorStatus + + } else if (type == 'KONKE_ZIGBEE_CHOPIN_10A_SOCKET') { // 插座 + let id = pushMsg.id + let on = pushMsg.status.on // on 开关状态 true开 false关 + let equipmentData = equipmentList.find(item => item.id == id) + equipmentData.status = on + + } else if (type == 'KONKE_ZIGBEE_KIT_TEMPSENSOR') { // 温度 + let id = pushMsg.id + let num = pushMsg.status.num + + } else if (type == 'KONKE_ZIGBEE_BANGDE_ILLUMSENSOR') { // 光照亮度 + let id = pushMsg.id + let num = pushMsg.status.num + + } else if (type == 'KONKE_ZIGBEE_KIT_HUMISENSOR') { // 湿度 + let id = pushMsg.id + let num = pushMsg.status.num + + } + + // 情景面板 + if (pushMsgType == 'ShortcutPanelActivedEvent') { + console.log('ShortcutPanelActivedEvent', sendData); + } + + // 赋值 + _this.setData({ + equipmentList + }) }) }, diff --git a/project.private.config.json b/project.private.config.json index e6b0b2a..1f6d844 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -6,6 +6,13 @@ "condition": { "miniprogram": { "list": [ + { + "name": "pages/test/test", + "pathName": "pages/test/test", + "query": "", + "launchMode": "default", + "scene": null + }, { "name": "pages/meeting/invite/invite", "pathName": "pages/meeting/invite/invite",