$(function() { $(".icheck a").click(function(){ is = $(this).hasClass("cur") if (! is) { $(this).find("input").each(function(index, element) { this.checked = true; }); } else { $(this).find("input").each(function(index, element) { this.checked = false; }); } $(this).toggleClass("cur") }) $(".iradio a").click(function(){ _index = $(this).parent().find("a").index(this) $(this).parent().find("a").removeClass("cur") $(this).addClass("cur") $(this).parent().find("input").each(function(index, element) { if (_index == index) { this.checked = true; } else { this.checked = false; } }); }) $(".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) } $(".nav li").hover(function() { $(this).find(".la").show(); }, function() { $(this).find(".la").hide(); }) $(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; } layer.closeAll(); layer.load(2); $.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() { layer.closeAll(); if (models['callback'] !== "" && models['callback'] !== undefined) { 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'] !== "") { $("#" + models['code']).focus(); } if (models['url'] !== "") { window.location.href = models['url']; } _btn.removeAttr("disabled") _btn.removeClass("disabled") } }); } }); }, 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"); }