/** * 琛ㄥ崟杞璞 * @returns object */ $.fn.serializeObject = function () { var o = {}; var a = this.serializeArray(); $.each(a, function () { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; } var req = {}; req.httpGet = function (url, params, callback, dataType) { dataType = dataType || 'json'; $.get(url, params, function (res) { if (res.code == 1001) { layer.msg('鐧诲綍瓒呮椂锛岃閲嶆柊鐧诲綍绯荤粺锛侊紒', function () { location.href = "/login?returnUrl=" + location.href; }); return; } callback(res); }, dataType); } req.httpPost = function (url, params, callback, dataType) { dataType = dataType || 'json'; $.post(url, params, function (res) { if (res.state == 1001) { layer.msg('鐧诲綍瓒呮椂锛岃閲嶆柊鐧诲綍绯荤粺锛侊紒', function () { location.href = "/login" + '?returnUrl=' + location.href; }); return; } callback(res); }, dataType); } req.getUrlParams = function (key) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == key) { return pair[1]; } } return (false); } function timekeeping(btn) { //鎶婃寜閽缃负涓嶅彲浠ョ偣鍑 $(btn).attr("disabled", true).addClass("btn-disabled"); //姣忕璇诲彇涓€娆ookie var interval = setInterval(function () { //浠巆ookie 涓鍙栧墿浣欏€掕鏃 total = $.cookie("total"); //鍦ㄥ彂閫佹寜閽樉绀哄墿浣欏€掕鏃 $(btn).text('璇风瓑寰? + total + '绉?); // $('.getcode2').val('璇风瓑寰? + total + '绉?); //鎶婂墿浣欐€诲€掕鏃跺噺鎺? total--; //鍓╀綑鍊掕鏃朵负闆讹紝鍒欐樉绀 閲嶆柊鍙戦€侊紝鍙偣鍑 if (total == 0) { //娓呴櫎瀹氭椂鍣 clearInterval(interval); //鍒犻櫎cookie total = $.cookie("total", total, { expires: -1 }); //鏄剧ず閲嶆柊鍙戦€ $(btn).text('閲嶆柊鍙戦€?); //鎶婂彂閫佹寜閽缃负鍙偣鍑 $(btn).removeAttr("disabled").removeClass("btn-disabled"); } else { //閲嶆柊鍐欏叆鎬诲€掕鏃 $.cookie("total", total); } }, 1000); }