const Url = ""
const userId = "2251108"
Page({
data: {
deviceValue: null
},
onLoad: function () {
setInterval(this.deviceValueLoad, 2000)
},
deviceValueLoad: function () {
var that = this
wx.request({
url: Url,
data: {
action: "GetDeviceValue",
userId: userId
},
header: {
'content-type': 'application/json'
},
success(res) {
deviceValue: res.data
}
})
},
deviceValueSet: function (device, value) {
wx.request({
url: iotUrl,
data: {
action: "SetDeviceValue",
userId: userId,
device: device,
value: value
},
header: {
'content-type': 'application/json'
},
success(res) {
console.log(res.data);
console.log(value);
}
});
},
click: function (e) {
var value = e.currentTarget.dataset.value;
var fuhao = e.currentTarget.dataset.fuhao
var device = e.currentTarget.id;
var real = null;
var num = null;
if(value==null){
if(fuhao=="+"){
num = parseInt(this.data.realTemplate)+1;
real = num;
}else{
num = parseInt(this.data.realTemplate)-1;
real = num;
}
}else{
real = value;
}
if (value == null)
value = "-1";
this.deviceValueSet(device, real);
return
}
})
一个小小的笔记js
最新推荐文章于 2024-07-20 23:54:17 发布