blob: 64a6da683a31fcc1ab374c205cbd575ecc0e67d2 [file] [log] [blame]
qiaowei22e23f82019-09-26 11:15:57 +08001var dev = false;
2var SERVER = "https://yy.dlsmk.cn/payapi/mobileapi";
qiaowei5f8f92f2019-11-15 10:27:57 +08003var DOOR_URl = "http://172.28.43.8:8099/door/app/appMintUIindex";//门禁服务地址
qiaoweif044a742019-07-10 16:04:20 +08004var GLOBAL_TODAY="";
5var GLOBAL_YESTERDAY="";
6var CURRENT_INDEX=1;
7if (dev) {
qiaowei5f8f92f2019-11-15 10:27:57 +08008 SERVER = "http://172.28.43.7:8099/payapi/mobileapi";
qiaoweif044a742019-07-10 16:04:20 +08009}
qiaowei22e23f82019-09-26 11:15:57 +080010
qiaowei04771b02019-08-07 09:23:56 +080011function V1Qrcode(callback) {
12 ajaxPost("/v1/qrcode", {}, callback)
13}
qiaowei60c27e42019-07-11 16:43:54 +080014function V1Idtypes(callback) {
15 ajaxPost("/v1/idtypes", {}, callback)
16}
qiaoweif044a742019-07-10 16:04:20 +080017function V1Cardinfor(callback) {
18 ajaxPost("/v1/cardinfor", {}, callback)
19}
20
21function V1Pwdset(param,callback) {
22 ajaxPost("/v1/pwdset", param, callback)
23}
24
25function V1Billdetail(param,callback) {
26 ajaxPost("/v1/billdetail", param, callback)
27}
28
29function V1Bills(param,callback) {
30 ajaxPost("/v1/bills", param, callback)
31}
32
33function V1CardLost(param,callback) {
34 ajaxPost("/v1/cardlost", param, callback)
35}
36
37function V1Signbxy(param,callback) {
38 ajaxPost("/v1/signbxy", param, callback)
39}
40
41function V1Bxy(callback) {
42 ajaxPost("/v1/bxy", {}, callback)
43}
44
45function V1Paypwd(param,callback) {
46 ajaxPost("/v1/paypwd", param, callback)
47}
48function V1Code(callback) {
49 ajaxPost("/v1/code", {}, callback)
50}
51function V1Checkcode(param,callback) {
52 ajaxPost("/v1/checkcode", param, callback)
53}
54
55function V1Bindcard(param,callback) {
56 ajaxPost("/v1/bindcard", param, callback)
57}
58
59function V1Infor(callback) {
60 ajaxPost("/v1/infor", {}, callback)
61}
62
63function IRegister(param,callback) {
64 ajaxPost("/i/register", param, callback)
65}
66
67function ICheckCode(param,callback) {
68 ajaxPost("/i/checkcode", param, callback)
69}
70
71function IGetPage(callback) {
72 ajaxPost("/i/uxy", {}, callback)
73}
74
75function IGetCode(param,callback) {
76 ajaxPost("/i/code", param, callback)
77}
78
79
80function IServeTime(callback) {
81 ajaxPost("/i/time", {}, callback)
82}
83
84function Login(param, callback) {
85 ajaxPost("/login", param, callback)
86}
87
88function ajaxGet(url, callback) {
89 var token = window.localStorage.getItem("token");
90 var tenantid = window.localStorage.getItem("tenantid");
91 $.ajax({
92 url: SERVER + url,
93 type: "GET",
94 dataType: "json",
95 headers: hd,
96 crossDomain: true,
97 success: function(result) {
98 if (callback) {
99 callback(true, result)
100 }
101 },
102 error: function(status, err) {
103 if (callback) {
104 callback(false, status)
105 }
106 }
107 });
108}
109
110function ajaxPost(url, param, callback) {
111 var token = window.localStorage.getItem("token");
112 var tenantid = window.localStorage.getItem("tenantid");
113 var hd = {};
114 hd["Authorization"] = "Bearer " + token;
115 hd["X-TENANT-ID"] = tenantid;
116 console.log(param)
117 $.ajax({
118 url: SERVER + url,
119 type: "POST",
120 contentType: "application/x-www-form-urlencoded",
121 dataType: "json",
122 data: param,
123 crossDomain: true,
124 timeout: 10000,
125 headers: hd,
126 success: function(result) {
127 if (callback) {
128 callback(true, result)
129 }
130 },
131 error: function(status, err) {
132 console.log(status,err)
133 if (status && status.status == 401) {
134 window.location = "login.html";
135 } else {
136 if (callback) {
137 callback(false, status, err)
138 }
139 }
140 }
141 });
142}
143
144
145function formatDateShort(date) {
146 if (!date || date.length == 0) {
147 return date;
148 }
149 if (date.length < 6) {
150 return date;
151 }
152 if (date.length < 8) {
153 return date.substring(0, 4) + "-" + date.substring(4, 6);
154 }
155 return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8);
156}
157
158function formatDate(date, flag) {
159 if (!date || date.length == 0) {
160 return date;
161 }
162 if (date.length < 6) {
163 return date;
164 }
165 if (date.length < 8) {
166 return date.substring(0, 4) + "-" + date.substring(4, 6);
167 }
168 if (date.length < 12) {
169 return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8);
170 }
171 if (flag || date.length < 14) {
172 return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + " " + date.substring(8, 10) + ":" + date.substring(10, 12);
173 }
174 return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + " " + date.substring(8, 10) + ":" + date.substring(10, 12) + ":" + date.substring(12, 14);
175}
176function formatDateNoYear(date,time) {
177 if (isEmpty(date)) {
178 return date;
179 }
180 if(isEmpty(time)){
181 return date;
182 }
183 if (date.length < 8||time.length<4) {
184 return date;
185 }
186 if(!isEmpty(GLOBAL_TODAY)){
187 if(date==GLOBAL_TODAY){
188 return "今天 "+time.substring(0,2)+":"+time.substring(2,4)
189 }
190 }else if(!isEmpty(GLOBAL_YESTERDAY)){
191 if(date==GLOBAL_YESTERDAY){
192 return "昨天 "+time.substring(0,2)+":"+time.substring(2,4)
193 }
194 }
195 return date.substring(4, 6) + "-" + date.substring(6, 8) + " " +time.substring(0,2)+":"+time.substring(2,4)
196}
197
198function formateDateZH(date) {
199 if (!date || date.length == 0) {
200 return date;
201 }
202 if (date.length < 6) {
203 return date;
204 }
205 if (date.length < 8) {
206 return date.substring(0, 4) + "年" + date.substring(4, 6) + "月";
207 }
208 if (date.length < 12) {
209 return date.substring(0, 4) + "年" + date.substring(4, 6) + "月" + date.substring(6, 8) + "日";
210 }
211 if (date.length < 14) {
212 return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + " " + date.substring(8, 10) + ":" + date.substring(10, 12);
213 }
214 return date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8) + " " + date.substring(8, 10) + ":" + date.substring(10, 12) + ":" + date.substring(12, 14);
215}
216
217function isNull(data) {
218 return (data == "" || data == undefined || data == null) ? true : false;
219}
220
221function checkMobile(sMobile) {
222 if (!(/^1[3|4|5|7|8|9][0-9]{9}$/.test(sMobile))) {
223 return false;
224 }
225 return true;
226}
227
228function isEmpty(str) {
229 if (!str || str == 'undefined' || str == null || str == '') {
230 return true;
231 }
232 return false;
233}
234
235function timeText(stime, t) {
236 var temp = parseInt((stime - t) / 1000);
237 if (temp <= 30) {
238 return '刚刚';
239 }
240 if (temp < 60) {
241 return temp + '秒钟前';
242 }
243 temp = parseInt(temp / 60);
244 if (temp < 60) {
245 return temp + '分钟前';
246 }
247 temp = parseInt(temp / 60);
248 if (temp < 24) {
249 return temp + '小时前';
250 }
251 temp = parseInt(temp / 24);
252 if (temp < 30) {
253 return temp + '天前';
254 }
255 temp = parseInt(temp / 30);
256 if (temp < 12) {
257 return temp + '个月前';
258 }
259 temp = parseInt(temp / 12);
260 return temp + '年前';
261}
262
263function trimTxt(str) {
264 if (isEmpty(str)) {
265 return '';
266 }
267 return str;
268}
269var wait=60;
270function btnTime(id) {
271 if (wait == 0) {
272 $("#"+id).removeAttr("disabled");
273 $("#"+id).removeClass("vcodedisabled")
274 $("#"+id).text("获取验证码");
275 wait = 60;
276 } else {
277 $("#"+id).attr("disabled", "disabled");
278 $("#"+id).text(wait + "s");
279 wait--;
280 setTimeout(function() {
281 btnTime(id)
282 },
283 1000)
284 }
285}
286var dialog;
287function showOk(m,callback){
288 if(!dialog||dialog==null){
289 dialog = new auiDialog({});
290 }
291 dialog.alert({
292 title:"提示",
293 msg:m,
294 buttons:['确定']
295 },function(ret){
296 if(callback){
297 callback(ret)
298 }
299 })
300}
301function alertError(msg){
302 $.alert(msg, "错误");
303}
304function alertOk(msg){
305 $.alert(msg, "提示");
306}