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