代码拉取完成,页面将自动刷新
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("指令发送成功");
}
})
},
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。