var url_api = "https://gwn.huatec.com/HuatecService"; function fun_numb_increase(v) { var _this = $(this); $(v).each(function () { var _this = $(this); _this.numberRock({ lastNumber: _this.html(), duration: 2000, easing: 'swing', }); }); return; } // ajax请求封装 var opt = { type: "get", url: "", data: null, async: true, cache: false, authorize: true, //鉴权认证 beforeSend: function () { }, success: function (r) { }, error: function (xhr) { }, complete: function () { }, loadingpnl: "", loadingbtn: "" } function fw_ajax(opt) { if (!opt.url || opt.url == "") return false; if (!opt.type) opt.type = "GET"; if (opt.async == undefined) opt.async = true; if (opt.cache == undefined) opt.cache = false; if (opt.loadingpnl || opt.loadingpnl != "") $(opt.loadingpnl).removeClass("hidden"); if (opt.loadingbtn || opt.loadingbtn != "") $(opt.loadingbtn).button("loading"); $.ajax({ type: opt.type.toUpperCase(), url: opt.url, data: opt.data, async: opt.async, cache: opt.cache, beforeSend: function (xhr) { if (opt.authorize) { xhr.setRequestHeader("Authorization", "Bearer " + $.cookie("ids_access_token")); } try { if (opt.beforeSend) opt.beforeSend(); } catch (e) { } }, success: function (r) { //console.log(r); try { if (opt.success) opt.success(r); } catch (e) { } }, error: function (xhr, status, error) { //console.log(xhr); switch (xhr.status) { case 401: $("#pnl_401").modal({ show: true, keyboard: false, backdrop: 'static' }); return; break; case 0: toastr.error("网络连接失败"); return; break; }; if (xhr.responseText != "") { var rjson = JSON.parse(xhr.responseText); switch (rjson.code) { case 40101: toastr.error(rjson.message); //console.log(rjson.message); break; default: break; } toastr.error(rjson.message); } try { if (opt.error) opt.error(xhr); } catch (e) { } }, complete: function (xhr, status) { if (opt.loadingpnl || opt.loadingpnl != "") $(opt.loadingpnl).addClass("hidden"); if (opt.loadingbtn || opt.loadingbtn != "") $(opt.loadingbtn).button("reset"); try { if (opt.complete) opt.complete(); } catch (e) { } } }); } function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; }