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