This commit is contained in:
SelfRidicule 2024-08-22 21:41:00 +08:00
parent abc07be3aa
commit a4681d407b
3 changed files with 83 additions and 3 deletions

View File

@ -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: {},

View File

@ -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
})
})
},

View File

@ -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",