//意见反馈 var feedback = null; //招标公告 var Tender = { keyWordDialog: null, getKeyWordDialog: function(clickLi){ if(this.keyWordDialog == null){ this.keyWordDialog = new KeyWordDialog("tender",clickLi); } return this.keyWordDialog; }, scopeDialog: null, getScopeDialog: function(clickLi){ if(this.scopeDialog == null){ this.scopeDialog = new ScopeDialog("tender",clickLi); } return this.scopeDialog; } }; //中标公告 var Bid = { keyWordDialog: null, getKeyWordDialog: function(clickLi){ if(this.keyWordDialog == null){ this.keyWordDialog = new KeyWordDialog("bid",clickLi); } return this.keyWordDialog; }, scopeDialog: null, getScopeDialog: function(clickLi){ if(this.scopeDialog == null){ this.scopeDialog = new ScopeDialog("bid",clickLi); } return this.scopeDialog; } }; //关键字弹出框 function KeyWordDialog(type,clickLi){ var thisClass = this; var dialogObj = $("#"+type+"-keyword"); this.type = type; this.clickLi = clickLi; this.show = function(){ dialogObj.show(); $("html,body").addClass("overflow-hidden"); }; this.hide = function(){ dialogObj.hide(); $("html,body").removeClass("overflow-hidden"); }; var contentObj = dialogObj.find(".dialog-content"); var padding = parseInt(contentObj.css('padding-top'))+parseInt(contentObj.css('padding-bottom')) contentObj.css("max-height",document.body.clientHeight-dialogObj.find(".dialog-head").height()-padding-40); dialogObj.find(".addKeyWord").click(function(){ KeyWordDialog.AppendNode(dialogObj); }); dialogObj.find(".submit").click(function(){ commonAjaxReq(thisClass); }); if(dialogObj.find(".keyWordGroup").length == 0){ KeyWordDialog.AppendNode(dialogObj); } } KeyWordDialog.AppendNode = function(dialogObj,value){ var getHtml = function(index,value){ return '
' +'关键词'+index+'' +'
' +'
' +'
'; } var count = dialogObj.find(".keyWordGroup").length; if(count >= 5){ dialogObj.find(".addKeyWord").attr("disabled",true); return; } var obj = $(getHtml(count+1,value)); dialogObj.find(".addKeyWordArea").before(obj); obj.find(".delete").click(function(){ dialogObj.find(".addKeyWord").removeAttr("disabled"); $(this).parents(".keyWordGroup").remove(); dialogObj.find(".keyWordGroup").each(function(i){ $(this).children("lable").children("font").text(i+1); }); }); if(typeof(value) == "undefined" || value == ""){ obj.find("[type='text']").focus() } } //信息范围 function ScopeDialog(type,clickLi){ var thisClass = this; var dialogObj = $("#"+type+"-scope"); this.type = type; this.clickLi = clickLi; this.show = function(){ dialogObj.show(); $("html,body").addClass("overflow-hidden"); }; this.hide = function(){ dialogObj.hide(); $("html,body").removeClass("overflow-hidden"); }; dialogObj.find(".dialog-content").css("max-height",document.body.clientHeight-dialogObj.find(".dialog-head").height()-40); dialogObj.find(".btn").click(function(){ if($(this).parent().index() == 0){ dialogObj.find(".btn").removeClass("active"); }else{ dialogObj.find("ul:first li:first .btn").removeClass("active"); } $(this).toggleClass("active"); if(dialogObj.find(".btn.active").length == 0){ dialogObj.find("ul:first li:first .btn").addClass("active"); } }); dialogObj.find(".submit").click(function(){ commonAjaxReq(thisClass); }); } //意见反馈 function Feedback(){ this.show = function(){ $(".feedback-dialog").show(); $("html,body").addClass("overflow-hidden"); }; this.setCount = function(count){ $(".feedback-dialog .statistics>span").text(count); }; var thisClass = this; $("#feedback-textarea").on("input propertychange",function(){ var count = $.trim(this.value).length; if(count > 0){ $(this).parent().removeClass("red-border"); } if(count > 200){ this.value = this.value.substring(0,200); return; } thisClass.setCount(count); }); $("#feedback-submit").click(function(){ var value = $("#feedback-textarea").val(); if($.trim(value) == ""){ $("#feedback-textarea").focus().parent().addClass("red-border"); return; } var obj = {reqType:"feedback"}; $.ajax({ type: "POST", url: "/swordfish/ajaxReq", data:{reqType:"feedback",value:value,title:"剑鱼-意见反馈"}, dataType: "json", success: function(r){ if(r.flag == "y"){ $(".feedback-dialog").hide(); $("html,body").removeClass("overflow-hidden"); $("#feedback-textarea").val(""); thisClass.setCount(0); alert("您的意见我们已经收到,谢谢!"); }else{ alert("提交失败!"); } }, error: function(){ alert("网络连接错误!"); } }); }); } function commonAjaxReq(object){ var dataObj = { reqType: "other", tender_flag: $("#tender-on-off").hasClass("open"), bid_flag: $("#bid-on-off").hasClass("open") }; var keysString = "",scopeString = ""; var thisClass = this; this.afterCommit = function(){ object.hide(); var value = ""; switch(object.clickLi.index()){ case 0: value = keysString; break; case 1: value = scopeString; break; } value = value.substring(0,value.length-1); if(object.clickLi.children(".com-last").length == 1){ if(value == ""){ object.clickLi.children(".com-last").remove(); }else{ object.clickLi.children(".com-last").text(value); } }else{ if(value != ""){ object.clickLi.append('
'+value+'
'); } } } //关键词 this.setKeyWord = function(type){ var tender_keys = []; $("#"+type+"-keyword .keyWordGroup").each(function(){ var value = $.trim($(this).find("[type='text']").val()).replace(/\r\n/g,""); if(value == ""){ return true; } if(object != null && object.type == type){ keysString += value+";"; } tender_keys.push(value.replace(/\s+/g,"+")); }); return tender_keys; } //信息范围 this.setScope = function(type){ var tender_scope = []; $("#"+type+"-scope .btn.active").each(function(){ var thisText = $(this).text(); if(thisText == "全国"){ tender_scope.push("A"); if(object != null && object.type == type){ scopeString += "全国;"; } return false; }else{ tender_scope.push(thisText); if(object != null && object.type == type){ scopeString += thisText+";"; } } }); return tender_scope.join(","); } /*******************招标公告****************/ if(dataObj.tender_flag){ dataObj["tender_keys"] = this.setKeyWord("tender"); dataObj["tender_scope"] = this.setScope("tender"); if(dataObj.tender_keys.length > 0 && dataObj.tender_scope == ""){ dataObj["tender_scope"] = "A"; } } /*******************中标公告****************/ if(dataObj.bid_flag){ dataObj["bid_keys"] = this.setKeyWord("bid"); dataObj["bid_scope"] = this.setScope("bid"); if(dataObj.bid_keys.length > 0 && dataObj.bid_scope == ""){ dataObj["bid_scope"] = "A"; } } /*****************************************/ $.ajax({ type: "POST", url: "/swordfish/ajaxReq", data: dataObj, dataType: "json", traditional: true, success: function(r){ if(object != null){ thisClass.afterCommit(); } }, error: function(){ } }); } $(function(){ var turnOn = function(obj){ obj.addClass("open"); var liobj = obj.parents("li"); liobj.next().show(); liobj.nextAll(".parent-node").eq(0).addClass("border-top"); if(liobj.next(".child-node").find(".com-last").length == 0){ liobj.next(".child-node").find("li:eq(1)").append('
全国
'); } } var setKeyWord = function(type,keys){ if(typeof(keys) == "undefined" || keys.length == 0){ return; } for(var i=0;i'+keys.join(";")+''); } var setScope = function(type,scope){ var dialogObj = $("#"+type+"-scope"); if(typeof(scope) == "undefined" || scope == ""){ return; } if(scope == "A"){ dialogObj.find("ul:first li:first .btn").addClass("active"); scope = "全国"; }else{ dialogObj.find("ul:first li:first .btn").removeClass("active"); var scopeArray = scope.split(","); for(var i=0;i'+scope.replace(/,/g,";")+''); } $("body").append($("#tender-keyword").clone().removeAttr("id").attr("id","bid-keyword")) .append($("#tender-scope").clone().removeAttr("id").attr("id","bid-scope")); if(typeof(msgset.tender) != "undefined"){ setKeyWord("tender",msgset.tender.a_key); setScope("tender",msgset.tender.s_scope); turnOn($("#tender-on-off")); } if(typeof(msgset.bid) != "undefined"){ setKeyWord("bid",msgset.bid.a_key); setScope("bid",msgset.bid.s_scope); turnOn($("#bid-on-off")); } //开关 $(".on-off").click(function(){ if(this.id == "intelligence-on-off"){//企业情报 alert("开发中,敬请期待!"); return; } if($(this).hasClass("open")){ $(this).removeClass("open") $(this).parents("li").next().hide(); $(this).parents("li").nextAll(".parent-node").eq(0).removeClass("border-top"); }else{ turnOn($(this)); } commonAjaxReq(null); }); // $("#tender-content>li").click(function(){ switch($(this).index()){ case 0: Tender.getKeyWordDialog($(this)).show(); break; case 1: Tender.getScopeDialog($(this)).show(); break; } }); $("#bid-content>li").click(function(){ switch($(this).index()){ case 0: Bid.getKeyWordDialog($(this)).show(); break; case 1: Bid.getScopeDialog($(this)).show(); break; } }); //弹出框消失 $(".dialog").click(function(e){ if($(e.target).hasClass("dialog")){ $(this).hide(); $("html,body").removeClass("overflow-hidden"); } }); $("#feedback").click(function(){ if(feedback == null){ feedback = new Feedback(); } feedback.show(); $("#feedback-textarea").focus().parent().removeClass("red-border"); }); });