qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 1 | var app = { |
| 2 | |
| 3 | // Application Constructor |
| 4 | initialize: function() { |
| 5 | document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); |
| 6 | }, |
| 7 | |
| 8 | onDeviceReady: function() { |
| 9 | var uid = window.localStorage.getItem("token"); |
qiaowei | 04771b0 | 2019-08-07 09:23:56 +0800 | [diff] [blame] | 10 | this.loadQrcode(); |
| 11 | setInterval(function () { |
| 12 | window.location.reload(); |
| 13 | },100000); |
qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 14 | }, |
qiaowei | 04771b0 | 2019-08-07 09:23:56 +0800 | [diff] [blame] | 15 | loadQrcode: function() { |
| 16 | $.showLoading("加载中"); |
| 17 | V1Qrcode(function(ok, ret) { |
| 18 | if (ok) { |
| 19 | console.log(ret) |
| 20 | if (ret.code == 200) { |
| 21 | $.hideLoading(); |
| 22 | var qrcode = new QRCode(document.getElementById("qrcode"), { |
| 23 | text: ret.qrcode, |
| 24 | width: 150, |
| 25 | height: 150, |
| 26 | colorDark: "#000000", |
| 27 | colorLight: "#ffffff", |
| 28 | correctLevel: QRCode.CorrectLevel.L |
| 29 | }); |
| 30 | } else { |
| 31 | $.hideLoading(); |
| 32 | $.alert("请求失败,请稍后再试", "错误"); |
| 33 | } |
| 34 | } else { |
| 35 | $.hideLoading(); |
| 36 | $.alert("请求失败了:" + ret.status + "请稍后再试", "错误"); |
| 37 | } |
| 38 | }) |
| 39 | }, |
| 40 | refresh:function(){ |
| 41 | V1Qrcode(function(ok, ret) { |
| 42 | if (ok) { |
| 43 | if (ret.code == 200) { |
| 44 | $.hideLoading(); |
| 45 | var qrcode = new QRCode(document.getElementById("qrcode"), { |
| 46 | text: ret.qrcode, |
| 47 | width: 150, |
| 48 | height: 150, |
| 49 | colorDark: "#000000", |
| 50 | colorLight: "#ffffff", |
| 51 | correctLevel: QRCode.CorrectLevel.L |
| 52 | }); |
| 53 | } else { |
| 54 | $.hideLoading(); |
| 55 | $.alert("请求失败,请稍后再试", "错误"); |
| 56 | } |
| 57 | } else { |
| 58 | $.hideLoading(); |
| 59 | $.alert("请求失败了:" + ret.status + "请稍后再试", "错误"); |
| 60 | } |
| 61 | }) |
qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 62 | } |
| 63 | }; |
| 64 | app.initialize(); |