2 Star 8 Fork 3

iot_camp / wechat_onenet_led

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app.js 935 Bytes
一键复制 编辑 原始数据 按行查看 历史
brown 提交于 2019-10-26 10:43 . 完成授权登录功能
//app.js
var onenet = require('js/onenet.js');
App({
onLaunch: function () {
// 展示本地存储能力
var that = this;
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
//get devices of onenet
wx.request({
url: "https://api.heclouds.com/devices",
header: {
"api-key": "eCQJZEKoyVqA5qV4ef3qTH2OZzo="
},
data: {
},
success(res) {
console.log(res)
var devices = [];
if (res.data.errno == 0) {
for (var i = 0; i < res.data.data.total_count; i++) {
devices.push(res.data.data.devices[i]);
}
}
that.globalData.devices = devices
console.log(devices)
},
fail(res) {
console.log("请求失败")
// deviceConnected = false
}
})
},
globalData: {
userInfo: null,
devices: [],
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/iot_camp/wechat_onenet_led.git
git@gitee.com:iot_camp/wechat_onenet_led.git
iot_camp
wechat_onenet_led
wechat_onenet_led
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891