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