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