blob: 4664a9b80de205e10b1a68d4c759928370b33c67 [file] [log] [blame]
qiaoweif044a742019-07-10 16:04:20 +08001var 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");
qiaowei04771b02019-08-07 09:23:56 +080010 this.loadQrcode();
11 setInterval(function () {
12 window.location.reload();
13 },100000);
qiaoweif044a742019-07-10 16:04:20 +080014 },
qiaowei04771b02019-08-07 09:23:56 +080015 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 })
qiaoweif044a742019-07-10 16:04:20 +080062 }
63};
64app.initialize();