//异步获取数据 function geturllist(params, url = '', callback = '') { if (!$.isplainobject(params) ) { alert('参数格式必需为json对象'); return false; } var data = ''; i = 0; var withparam = ''; for (var key in params) { //console.log('key:' +key + ',value:' + params[key]); if (i != 0) { withparam = '&'; } data += withparam + key + '=' + params[key]; i++; } $.ajax({ type: 'get', url: url, //async: false, datatype: 'json', data: data, success: callback, error: function (res) { //layer.msg(res.message); } }); } //异步获取数据 function getpost(params, url = '', callback = '') { if (!$.isplainobject(params) ) { alert('参数格式必需为json对象'); return false; } var data = ''; i = 0; var withparam = ''; for (var key in params) { //console.log('key:' +key + ',value:' + params[key]); if (i != 0) { withparam = '&'; } data += withparam + key + '=' + params[key]; i++; } $.ajax({ type: 'post', url: url, //async: false, datatype: 'json', data: data, success: callback, error: function (res) { layer.msg(res.message); } }); } //加法函数,用来得到精确的加法结果 function accadd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.tostring().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.tostring().split(".")[1].length } catch (e) { r2 = 0 } m = math.pow(10, math.max(r1, r2)); return (accmul(arg1, m) + accmul(arg2, m)) / m; } //减 function floatsub(arg1, arg2) { var r1, r2, m, n; try { r1 = arg1.tostring().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.tostring().split(".")[1].length } catch (e) { r2 = 0 } m = math.pow(10, math.max(r1, r2)); //动态控制精度长度 n = (r1 >= r2) ? r1 : r2; return ((arg1 * m - arg2 * m) / m).tofixed(n); } //乘法 function accmul(arg1, arg2) { var m = 0, s1 = arg1.tostring(), s2 = arg2.tostring(); try { m += s1.split(".")[1].length } catch (e) { } try { m += s2.split(".")[1].length } catch (e) { } return number(s1.replace(".", "")) * number(s2.replace(".", "")) / math.pow(10, m) } //除 function floatdiv(arg1, arg2) { var t1 = 0, t2 = 0, r1, r2; try { t1 = arg1.tostring().split(".")[1].length } catch (e) { } try { t2 = arg2.tostring().split(".")[1].length } catch (e) { } r1 = number(arg1.tostring().replace(".", "")); r2 = number(arg2.tostring().replace(".", "")); return (r1 / r2) * math.pow(10, t2 - t1); }