qiaowei | 743de0d | 2020-05-07 15:06:58 +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=""; |
qiaowei | bd656ad | 2020-06-11 15:12:03 +0800 | [diff] [blame] | 5 | var BASE_URL="https://yy.dlsmk.cn"; |
qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 6 | var GLOBAL_YESTERDAY=""; |
| 7 | var CURRENT_INDEX=1; |
| 8 | if (dev) { |
qiaowei | bd656ad | 2020-06-11 15:12:03 +0800 | [diff] [blame] | 9 | SERVER = "http://172.28.43.7:8099/payapi/mobileapi"; |
qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 10 | } |
qiaowei | c5a87f7 | 2020-03-27 12:40:19 +0800 | [diff] [blame] | 11 | function V1Bindcardcode(param,callback) { |
| 12 | ajaxPost("/v1/bindcardcode", param, callback) |
| 13 | } |
| 14 | |
qiaowei | 8055aa7 | 2019-12-05 11:40:00 +0800 | [diff] [blame] | 15 | function V1Unbindcard(param,callback){ |
| 16 | ajaxPost("/v1/unbindcard", param, callback) |
| 17 | } |
| 18 | |
| 19 | function V1UnSignbxy(param,callback){ |
| 20 | ajaxPost("/v1/unsignbxy", param, callback) |
| 21 | } |
qiaowei | 22e23f8 | 2019-09-26 11:15:57 +0800 | [diff] [blame] | 22 | |
qiaowei | 04771b0 | 2019-08-07 09:23:56 +0800 | [diff] [blame] | 23 | function V1Qrcode(callback) { |
| 24 | ajaxPost("/v1/qrcode", {}, callback) |
| 25 | } |
qiaowei | 60c27e4 | 2019-07-11 16:43:54 +0800 | [diff] [blame] | 26 | function V1Idtypes(callback) { |
| 27 | ajaxPost("/v1/idtypes", {}, callback) |
| 28 | } |
qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 29 | function V1Cardinfor(callback) { |
| 30 | ajaxPost("/v1/cardinfor", {}, callback) |
| 31 | } |
| 32 | |
| 33 | function V1Pwdset(param,callback) { |
| 34 | ajaxPost("/v1/pwdset", param, callback) |
| 35 | } |
| 36 | |
| 37 | function V1Billdetail(param,callback) { |
| 38 | ajaxPost("/v1/billdetail", param, callback) |
| 39 | } |
| 40 | |
| 41 | function V1Bills(param,callback) { |
| 42 | ajaxPost("/v1/bills", param, callback) |
| 43 | } |
| 44 | |
| 45 | function V1CardLost(param,callback) { |
| 46 | ajaxPost("/v1/cardlost", param, callback) |
| 47 | } |
| 48 | |
| 49 | function V1Signbxy(param,callback) { |
| 50 | ajaxPost("/v1/signbxy", param, callback) |
| 51 | } |
| 52 | |
| 53 | function V1Bxy(callback) { |
| 54 | ajaxPost("/v1/bxy", {}, callback) |
| 55 | } |
| 56 | |
| 57 | function V1Paypwd(param,callback) { |
| 58 | ajaxPost("/v1/paypwd", param, callback) |
| 59 | } |
| 60 | function V1Code(callback) { |
| 61 | ajaxPost("/v1/code", {}, callback) |
| 62 | } |
| 63 | function V1Checkcode(param,callback) { |
| 64 | ajaxPost("/v1/checkcode", param, callback) |
| 65 | } |
| 66 | |
| 67 | function V1Bindcard(param,callback) { |
| 68 | ajaxPost("/v1/bindcard", param, callback) |
| 69 | } |
| 70 | |
| 71 | function V1Infor(callback) { |
| 72 | ajaxPost("/v1/infor", {}, callback) |
| 73 | } |
| 74 | |
| 75 | function IRegister(param,callback) { |
| 76 | ajaxPost("/i/register", param, callback) |
| 77 | } |
| 78 | |
| 79 | function ICheckCode(param,callback) { |
| 80 | ajaxPost("/i/checkcode", param, callback) |
| 81 | } |
| 82 | |
| 83 | function IGetPage(callback) { |
| 84 | ajaxPost("/i/uxy", {}, callback) |
| 85 | } |
| 86 | |
| 87 | function IGetCode(param,callback) { |
| 88 | ajaxPost("/i/code", param, callback) |
| 89 | } |
| 90 | |
qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame] | 91 | function IServeTime(callback) { |
| 92 | ajaxPost("/i/time", {}, callback) |
| 93 | } |
| 94 | |
| 95 | function Login(param, callback) { |
| 96 | ajaxPost("/login", param, callback) |
| 97 | } |
| 98 | |
| 99 | function 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 | |
| 121 | function 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 | |
| 156 | function 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 | |
| 169 | function 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 | } |
| 187 | function 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 | |
| 209 | function 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 | |
| 228 | function isNull(data) { |
| 229 | return (data == "" || data == undefined || data == null) ? true : false; |
| 230 | } |
| 231 | |
| 232 | function 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 | |
| 239 | function isEmpty(str) { |
| 240 | if (!str || str == 'undefined' || str == null || str == '') { |
| 241 | return true; |
| 242 | } |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | function 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 | |
| 274 | function trimTxt(str) { |
| 275 | if (isEmpty(str)) { |
| 276 | return ''; |
| 277 | } |
| 278 | return str; |
| 279 | } |
| 280 | var wait=60; |
| 281 | function 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 | } |
| 297 | var dialog; |
| 298 | function 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 | } |
| 312 | function alertError(msg){ |
| 313 | $.alert(msg, "错误"); |
| 314 | } |
| 315 | function alertOk(msg){ |
| 316 | $.alert(msg, "提示"); |
| 317 | } |