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