通过中移onenet进行微信小程序。
Page({
data: {
temp:0
},
// 事件处理函数
getinfo(){
var that = this //this变量赋值给that
wx.request({
url: "https://api.heclouds.com/devices/1123621674/datapoints",
//将请求行中的数字换成自己的设备ID
header: {
"api-key": "8Hq4KKZr5c40yMUHQkY26pRNK9E=" //自己的api-key
},
method: "GET",
success: function (e) {
console.log("获取成功",e)
that.setData({
temp:e.data.data.datastreams[1].datapoints[0].value
})
console.log("temp==",that.data.temp)
}
});
},
onLoad() {
var that = this
that.getinfo()
}
})
<text class="userinfo">{{temp}}</text>