$(function () { $(".nav li").hover(function () { $(this).addClass("cur") }, function () { $(this).removeClass("cur") }) txt = $(document).attr("title"); if (txt.indexOf("公司简介") >= 0) { setnav(1) } if (txt.indexOf("白酒系列") >= 0) { setnav(2) } if (txt.indexOf("红酒系列") >= 0) { setnav(3) } if (txt.indexOf("新闻中心") >= 0) { setnav(4) } if (txt.indexOf("售后服务") >= 0) { setnav(5) } if (txt.indexOf("在线留言") >= 0) { setnav(6) } if (txt.indexOf("联系我们") >= 0) { setnav(7) } $(document).on('click', '.submit_noconfirm', function () { _frmid = $(this).attr("frmid"); _action = $(this).attr("action"); _return = $(this).attr("return"); $.ajax({ type: "POST", url: _action, data: $('#' + _frmid).serialize(), datatype: "html", success: function (data) { var models = eval("(" + data + ")"); iconnum = 1; if (models['status'] !== "ok") { iconnum = 2; } layer.msg(models['msg'], { icon: iconnum, time: 800 }, function () { if (models['status'] == "ok") { if (models['callback'] !== "") { eval(models['callback']); return; } if (_return !== "" && _return !== undefined) { window.location.href = _return; return; } else if (models['url'] !== "") { window.location.href = models['url']; } else { location.reload(); } } else { if (models['code'] !== "") { $("#" + _frmid + " #" + models['code']).focus(); } if (models['url'] !== "") { window.location.href = models['url']; } } }); } }); }) $(document).on('click', '.submit', function () { $(this).addClass("disabled"); $(this).attr({ "disabled": "disabled" }); _frmid = $(this).attr("frmid"); _action = $(this).attr("action"); _return = $(this).attr("return"); _btn = $(this) _click = 0 layer.confirm('你确定要执行此操作吗?', { btn: ['确定', '取消'] }, function () { _click = _click + 1; if (_click > 1) { return; } var layer_load = layer.load(2); $.ajax({ type: "POST", url: _action, data: $('#' + _frmid).serialize(), datatype: "html", success: function (data) { layer.close(layer_load) _btn.removeAttr("disabled") _btn.removeClass("disabled") var models = eval("(" + data + ")"); iconnum = 1; if (models['status'] !== "ok") { iconnum = 2; } layer.msg(models['msg'], { icon: iconnum, time: 800 }, function () { if (models['callback'] !== "") { eval(models['callback']); return; } if (models['status'] == "ok") { if (_return !== "" && _return !== undefined) { window.location.href = _return; return; } else if (models['url'] !== "") { window.location.href = models['url']; } else { location.reload(); } } else { if (models['code'] !== "") { $("#" + _frmid + " #" + models['code']).focus(); } if (models['url'] !== "") { window.location.href = models['url']; } } }); } }); }, function () { layer.msg("当前操作已经取消"); _btn.removeAttr("disabled") _btn.removeClass("disabled") }); return false }) $(document).on('click', '.get', function () { _action = $(this).attr("action"); _return = $(this).attr("return"); _click = 0 layer.confirm('你确定要执行此操作吗?', { btn: ['确定', '取消'] }, function () { _click = _click + 1; if (_click > 1) { return; } layer.closeAll(); layer.load(2); $.get(_action, function (data) { var models = eval("(" + data + ")"); iconnum = 1; if (models['status'] !== "ok") { iconnum = 2; } layer.msg(models['msg'], { icon: iconnum, time: 1000 }, function () { if (models['callback'] !== "") { eval(models['callback']); } if (_return !== "" && _return !== undefined) { window.location.href = _return; } else if (models['url'] !== "") { window.location.href = models['url']; } else { location.reload(); } }); }); }, function () { layer.msg("当前操作已经取消"); }); }) }); function setnav(dom) { $(".nav li").removeClass("curr") $(".nav li").eq(dom).addClass("curr"); }