From dfdab1aa564b1e9339a34a14fd7f882c68debc23 Mon Sep 17 00:00:00 2001 From: whychdw <49690745@qq.com> Date: 星期一, 16 九月 2019 10:58:01 +0800 Subject: [PATCH] 添加数据连接 --- dist/index.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5636967..2062d4e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32,4 +32,59 @@ Android.onJsFunctionCalled(2000); }, 2000); } + + var vm = new Vue({ + el: '#appStates', + data: { + timer: new Timeout(), + web: { + info: true, + error: false + } + }, + methods: { + setWeb: function setWeb(bool) { + if (bool) { + this.web.info = true; + this.web.error = false; + } else { + this.web.info = false; + this.web.error = true; + } + }, + startCheck: function startCheck() { + var self = this; + this.timer.start(function () { + self.checkServerStates(); + }, 2000); + }, + checkServerStates: function checkServerStates() { + var self = this; + var searchParams = { + num: 2 + }; + var json = JSON.stringify(searchParams); + // 璇锋眰鍚庡彴 + ajax({ + url: 'Batt_rtstateAction!serchByInfo', + data: 'json=' + json, + success: function success(res) { + //console.log(res); + self.setWeb(true); + }, + error: function error() { + // 璁剧疆鏈嶅姟鍣ㄨ繛鎺ョ姸鎬佸紓甯� + self.setWeb(); + }, + complete: function complete() { + // 寮�鍚鏃跺櫒 + self.timer.open(); + } + }); + } + }, + mounted: function mounted() { + this.startCheck(); + } + }); }); \ No newline at end of file -- Gitblit v1.9.1