- 关于切换页面后 appdata中的markes中的数据消失?
在调用map组件标记定位后 markets中有数据 页面也显示正常 切换到另外的页面后切换回来 页面数据中的markers中的数据消失
2021-10-20 - 加入登录页面后,登录跳转到主页面,主页面的函数没有执行?
在加入一个登录页面后 没有执行函数 that.data.client.on('connect', that.ConnectCallback); that.data.client.on("message", that.MessageProcess); //获取应用实例 const app = getApp(); Page({ data: { client: null, topic: { areaTopic: 'area', LEDcontrolTopic: 'ledcontrol', }, value: { areaAValue:0, areaBValue:0, areaCValue:0, areaDValue:0, }, LED1Value: [{ LEDlogo: './../images/LED_gray.png', ButtonValue: '区域1开灯', ButtonFlag: true, }], LED2Value: [{ LEDlogo: './../images/LED_gray.png', ButtonValue: '区域2开灯', ButtonFlag: true, }], LED3Value: [{ LEDlogo: './../images/LED_gray.png', ButtonValue: '区域3开灯', ButtonFlag: true, }], LED4Value: [{ LEDlogo: './../images/LED_gray.png', ButtonValue: '区域4开灯', ButtonFlag: true, }] }, onLoad: function() { var that = this; this.data.client = app.globalData.client; that.data.client.on('connect', that.ConnectCallback); that.data.client.on("message", that.MessageProcess); that.data.client.on("error", that.ConnectError); that.data.client.on("reconnect", that.ClientReconnect); that.data.client.on("offline", that.ClientOffline); console.log("on load1"); }, onShow: function() { console.log("on show1"); }, onHide: function() { console.log("on hide1"); }, onUnload: function() { console.log("on unload1"); var that = this; that.data.client.end(); }, LedControl: function() { var that = this; if (that.data.LED1Value[0].ButtonFlag) { that.setData({ 'LED1Value[0].ButtonValue': '区域1关灯', 'LED1Value[0].ButtonFlag': false, "LED1Value[0].LEDlogo": './../images/LED_red.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic,'ckon1',{ qos: 1 }); } else { that.setData({ 'LED1Value[0].ButtonValue': '区域1开灯', 'LED1Value[0].ButtonFlag': true, "LED1Value[0].LEDlogo": './../images/LED_gray.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic,'ckoff1',{ qos: 1 }); } }, LedContro2: function() { var that = this; if (that.data.LED2Value[0].ButtonFlag) { that.setData({ 'LED2Value[0].ButtonValue': '区域2关灯', 'LED2Value[0].ButtonFlag': false, "LED2Value[0].LEDlogo": './../images/LED_red.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic, 'ckon2',{ qos: 1 }); } else { that.setData({ 'LED2Value[0].ButtonValue': '区域2开灯', 'LED2Value[0].ButtonFlag': true, "LED2Value[0].LEDlogo": './../images/LED_gray.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic, 'ckoff2',{ qos: 1 }); } }, LedContro3: function() { var that = this; if (that.data.LED3Value[0].ButtonFlag) { that.setData({ 'LED3Value[0].ButtonValue': '区域3关灯', 'LED3Value[0].ButtonFlag': false, "LED3Value[0].LEDlogo": './../images/LED_red.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic,'ckon3',{ qos: 1 }); } else { that.setData({ 'LED3Value[0].ButtonValue': '区域3开灯', 'LED3Value[0].ButtonFlag': true, "LED3Value[0].LEDlogo": './../images/LED_gray.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic, 'ckoff3',{ qos: 1 }); } }, LedContro4: function() { var that = this; if (that.data.LED4Value[0].ButtonFlag) { that.setData({ 'LED4Value[0].ButtonValue': '区域4关灯', 'LED4Value[0].ButtonFlag': false, "LED4Value[0].LEDlogo": './../images/LED_red.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic, 'ckon4',{ qos: 1 }); } else { that.setData({ 'LED4Value[0].ButtonValue': '区域4开灯', 'LED4Value[0].ButtonFlag': true, "LED4Value[0].LEDlogo": './../images/LED_gray.png', }) that.data.client.publish(that.data.topic.LEDcontrolTopic, 'ckoff4',{ qos: 1 }); } }, MessageProcess: function(topic, payload) { var that = this; //var payload_string = payload.toString(); //var jsonObj = JSON.parse(Uint8ArrayToString(payload)); //var payload = JSON.stringify(payload) console.log("on MessageProcess"); var jsonObj = JSON.parse(payload); var payload_areaA = jsonObj.aA; var payload_areaB = jsonObj.aB; var payload_areaC = jsonObj.aC; var payload_areaD = jsonObj.aD; if (topic == that.data.topic.areaTopic) { that.setData({ 'value.areaAValue': payload_areaA, 'value.areaBValue': payload_areaB, 'value.areaCValue': payload_areaC, 'value.areaDValue': payload_areaD, }) } }, ConnectCallback: function() { var that = this; console.log("connect callback "); this.data.client.subscribe('area', { qos: 1 }); }, ConnectError: function(error) { console.log(error) }, ClientReconnect: function() { console.log("Client Reconnect") }, ClientOffline: function() { console.log("Client Offline") } })
2021-06-24 - Unexpected token c in JSON at position 0 ?
[图片] [图片] 同样的代码 引用的mqtt.js是一样的 在一个程序中可以用‘ckoff1’直接发送 一个只能发送json格式的数据 发送‘ckoff1’就报以上错误 有没有大佬给点思路 我想发不是json格式的
2021-06-24 - 域名备案已过但是在小程序官方后台的配置服务器域名时显示域名未备案怎么处理?
[图片]
2021-06-01