app.js
3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* 单页面应用
*/
define(
"check-app",
[
'mk7/app'
],
function (app) {
var $$ = Dom7;
var _autoLoading = function () {
var e = $$('.ui-loading-block');
if (0 == e.length) {
//<!--预载入页面动画-->
$$('.view-main').html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>');
window['waitingTime'] = 10000; // 显示重新加载的等待时间,默认10s
if (window['loaderTimer']) {
clearTimeout(window['loaderTimer']);
}
window['loaderTimer'] = setTimeout(function () {
var loaderTips = document.getElementById('loader-inner');
var tips = document.createElement('p');
tips.className = 'notice';
if (loaderTips) {
tips.innerHTML = '加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>';
loaderTips.appendChild(tips);
}
}, window['waitingTime']);
}
};
var fromOutside = true; // 标记是否从外部进来
app.name = 'check',//用来 smart 和 index-controller 构成完整的命名空间 smart/index-controller
app.routes = {
'index': function () {
fromOutside = false;
_autoLoading();
return app.runController('index');
},
'*': function () {
fromOutside = false;
_autoLoading();
return app.runController('index');
},
'scan-count/:uuid/:scancount': function (uuid, scancount) {
fromOutside = false;
_autoLoading();
return app.runController('scan-count',{uuid: uuid, scancount: scancount});
},
'warning/:uuid': function (uuid) {
fromOutside = false;
_autoLoading();
return app.runController('warning',{uuid: uuid});
},
'submit/:uuid': function (uuid) {
fromOutside = false;
_autoLoading();
return app.runController('submit',{uuid: uuid});
},
'error/:uuid': function (uuid) {
fromOutside = false;
_autoLoading();
return app.runController('error',{uuid: uuid});
},
'success/:uuid': function (uuid) {
fromOutside = false;
_autoLoading();
return app.runController('success',{uuid: uuid});
},
'info/:uuid/:number_code': function (uuid, number_code) {
fromOutside = false;
_autoLoading();
return app.runController('info',{uuid: uuid, number_code: number_code});
},
}
return app;
}
);