busInit.js
5.08 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//var _REQUESTURL = "http://localhost:9092";
var _REQUESTURL = "http://127.0.0.1:8080";
var _DEFAULT_SIZE = 10,
_DEFAULT_PAGE = 1;
var _SYSTEMKEY = {
"USERID": "adminUserId",
"SESSIONID": "adminSessionId",
"REDIRECTURL": "redirectUrl",
"PAGEPARAMS": "pageParams",
"SYSTEMUSER": "systemuser",
"LOGINBACK": "loginback"
}
var CDNPATH = "";
var OSSPARAM = {
region: 'oss-cn-qingdao',
accessKeyId: 'LTAI0W9uVALkeFpo',
accessKeySecret: 'U3wESI1dSTqhgX8EV5wc66b39cE8V9',
bucket: 'luobaoan'
};
var SUBMITLOCK = false;
var _QUERYPARAM = {};
var REGULARBUS_ACTIVE_LINES_STATUS = {
1: "售票",
2: "检票",
3: "发班",
4: "停班",
5: "停售",
6: "募集"
}
function isLogin() {
if (window.location.href.indexOf("login.html") == -1) {
var user = getCookie(_SYSTEMKEY.SYSTEMUSER);
if (!user) {
window.location.href = "login.html";
}
}
}
isLogin();
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.htmlTrim = function() {
return this.replace(/<[^>]*?>(.*?)/gi, '$1').replace(/(.*?)<\/[^>]*?>/gi, '$1');
}
Date.prototype.format = function(fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
function _putSession(key, val) {
var session = window.localStorage;
session.setItem(key, val);
// setCookie(key, val);
}
function _getSession(key) {
var session = window.localStorage;
return session.getItem(key);
// return getCookie(key);
}
function _removeSession(key) {
var session = window.localStorage;
return session.removeItem(key);
// delCookie(key);
}
function _clearSession() {
var session = window.localStorage;
session.clear();
}
function setCookie(name, value) {
var Days = 7;
var exp = new Date();
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
//读取cookies
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
//删除cookies
function delCookie(name) {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(name);
if (cval != null)
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
function _isLogin() {
var sessionId = _getSession(_SYSTEMKEY.SESSIONID);
console.log(sessionId);
if (sessionId && sessionId.trim() != "") {
return true;
}
return false;
}
function loginInit() {
}
function _getSessionId() {
return _getSession(_SYSTEMKEY.SESSIONID);
}
function _putSessionId(sid) {
_putSession(_SYSTEMKEY.SESSIONID, sid);
}
function getUuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
function logout() {
_putSession(_SYSTEMKEY.LOGINBACK, window.location.href);
_removeSession(_SYSTEMKEY.SESSIONID);
// location.href = LOGINURL;
}
function _getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
function _nullValue(value) {
if (value) {
return value;
} else {
return "";
}
}
var m = "yrymaster";
function showError(message) {
alert(message);
}
function _timestampToString(timestamp) {
timestamp = timestamp + "";
if (timestamp.length == 10) {
timestamp = timestamp + "000";
}
// console.log(timestamp);
timestamp = Number(timestamp);
var date = new Date(timestamp);
// var d = date.getDate();
// var m = date.getMonth();
// var y = date.getFullYear();
// var now = new Date();
// var nd = now.getDate();
// var nm = now.getMonth();
// var ny = now.getFullYear();
// var format = "";
// if (y == ny && m == nm) {
// if (d == nd) {
// s = "hh:mm";
// } else if (nd - 1 == d) {
// s = "昨天 hh:mm";
// } else if (nd == d - 1) {
// s = "明天 hh:mm";
// } else {
// s = "MM-dd hh:mm";
// }
// } else if (y == ny) {
var s = "MM-dd hh:mm";
// } else {
// s = "yyyy-MM-dd hh:mm";
// }
return new Date(timestamp).format(s);
}
var p = "YRY@34AJ1056921";