加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sfarm.js 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
大虎king 提交于 2021-04-27 19:55 . 插件
new Vue({
el: '#appContainer',
data: {
loading: 0,
topic: '',
projectsList: [],
lastMsg: {},
editProjectData: {},
params: {},
webtitle: '智慧农场插件'
},
created: function () {
// `this` 指向 vm 实例
this.fetchData();
},
methods: {
fetchData: function () {
var params = app.GetRequest(window.location.search);
this.getProjects();
if (params.topic) {
this.topic = params.topic;
}
},
getlastMsg(projectId, devId) {
var topic = projectId + "/" + devId;
app.get("/lastmessage?topic=" + topic, {}, function (res) {
console.log(res);
if (res.code != 1) {
app.alert(res.msg);
}
if (res.data.length > 0) {
$("."+projectId + "_" + devId).html("<b>"+res.data[0].Content+"</b> ["+res.data[0].Created+"]") ;
}
})
},
getProjects: function () {
var that = this;
app.get("/projects", this.params, function (res) {
console.log(res);
if (res.code != 1) {
app.alert(res.msg);
} else {
that.projectsList = res.data;
}
})
},
openurl: function (url) {
window.location.href = 'devices.html?projectID=' + url;
},
sendMsg_af: function (af_topic, af_msg) {
var that = this;
if (this.loading == 1) {
return;
}
this.loading = 1;
app.get("/publish", {
topic: af_topic,
msg: af_msg,
}, function (res) {
that.loading = 0;
if (res.code != 1) {
app.alert(res.msg);
} else {
app.alert("指令发送成功");
}
})
},
}
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化