123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- //招标公告
- 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");
- $(window).resize(function(){
- KeyWordDialog.SetContentHeight(dialogObj);
- });
- };
- this.hide = function(){
- dialogObj.hide();
- $("html,body").removeClass("overflow-hidden");
- $(window).unbind("resize");
- };
- KeyWordDialog.SetContentHeight(dialogObj);
- dialogObj.find(".addKeyWord").click(function(){
- KeyWordDialog.AppendNode(dialogObj);
- });
- dialogObj.find(".submit").click(function(){
- commonAjaxReq(thisClass,type);
- });
- if(dialogObj.find(".keyWordGroup").length == 0){
- KeyWordDialog.AppendNode(dialogObj);
- }
- }
- KeyWordDialog.SetContentHeight = function(dialogObj){
- 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);
- }
- KeyWordDialog.AppendNode = function(dialogObj,value){
- var getHtml = function(index,value){
- return '<div class="keyWordGroup">'
- +'<lable style="white-space:nowrap;">关键词<font>'+index+'</font></lable>'
- +'<div><input type="text" value="'+(value?value:"")+'" placeholder="示例:综合布线 电话线 网线" maxlength="100"></div>'
- +'<div>'+(index==1?'':'<img src="/wxswordfish/images/delete.png" class="delete">')+'</div>'
- +'</div>';
- }
- var count = dialogObj.find(".keyWordGroup").length;
- if(count >= 10){
- return;
- }
- var obj = $(getHtml(count+1,value));
- dialogObj.find(".addKeyWordArea").before(obj);
- //自动滚动到底部
- $("#a_end")[0].scrollIntoView();
- 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();
- }
- if(count >= 9){
- dialogObj.find(".addKeyWord").attr("disabled",true);
- }
- }
- //信息范围
- 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,type);
- });
- }
- //取积分
- function getCredit(){
- var score=0
- $.ajax({
- dataType:"json",
- url:"/member/credit/getcredit",
- type:"POST",
- async:false,
- success:function(msg){
- if(msg){
- if(msg.flag){
- score=msg.val
- }else{
- alert("请重新进入页剑鱼页面后操作")
- }
- }
- },
- error:function(x,st,err){
- alert("请稍后再试"+st)
- }
- })
- return score
- }
- var snopshot=[];
- function showAlls(){
-
- var n=0,str=[],sel=[];
- for(var i in snopshot){
- if(snopshot[i]){
- n++;
- str.push((i=="tender")?"招标公告":"中标公告")
- sel.push("types="+i)
- }
- }
- if(n>0){
- var num=getCredit();
- var pay=1000*n, rem=num-pay,strs="扣除后将剩余"+rem+"积分";
- var contents="您添加了"+n+"个信息栏目("+str.join("、")+"),确认后系统将每月扣除"+pay+"积分,您目前的积分余额是"+num+"积分,";
- if(rem<0){
- $("#credit_yes").unbind("click").hide()
- strs="请充值或去赚积分。";
- }else{
- $("#credit_yes").unbind("click").bind("click",function(e){
- $("#rule-content").text(contents+strs)
- $(".tip-dialog").show();
- $("#tip-dialog-back").unbind("click").bind("click",function(e){
- $("#tip-dialog-back").unbind("click");
- $.ajax({
- dataType:"json",
- url:"/member/credit/swordfishpay",
- data:sel.join("&"),
- type:"POST",
- async:false,
- success:function(msg){
- if(msg){
- if(msg.flag){
- //有session
- if(msg.oprstatus){
- //扣积分操作成功
- $(".visible").hide()
- }else{
- //扣积分操作无效
- alert("操作无效,请重新进入页剑鱼页面后操作")
- }
- }else{
- //无session
- alert("请重新进入页剑鱼页面后操作")
- }
- }
- },
- error:function(x,st,err){
- alert("请稍后再试"+st)
- }
- })
- window.location.reload()
- })
- $("html,body").addClass("overflow-hidden");
- })
- }
- $("#credit_no").unbind("click").bind("click",function(e){
- $.ajax({
- dataType:"json",
- url:"/member/credit/swordfishpay",
- data:sel.join("&")+"&no=1",
- type:"POST",
- async:false,
- success:function(msg){
- if(msg){
- if(msg.flag){
- //有session
- if(msg.oprstatus){
- //取消操作成功
- $(".visible").hide()
- }else{
- //取消操作无效
- alert("操作无效,请重新进入页剑鱼页面后操作")
- }
- }else{
- //无session
- alert("请重新进入页剑鱼页面后操作")
- }
- }
- },
- error:function(x,st,err){
- alert("请稍后再试"+st)
- }
- })
- window.location.reload()
- })
- $("#txt_tip").text(contents+strs)
- $(".visible").show()
- }else{
- $("#credit_yes").unbind("click")
- $(".visible").hide()
- }
- }
- function showSnopshot(module,type,on){
- //提示扣积分
- //alert(getCredit())
- if(type==0){//初始化
- //是开启状态
- //显示天数
- try{
- var days=eval("msgset."+module+".days")
- if(typeof days=="number"){
- if (days<6){
- var tiptxt="本栏目推送服务期还剩<d style='color:red'>"+days+"</d>天"
- if(winWidth<341){
- tiptxt="服务期还剩<d style='color:red'>"+days+"</d>天"
- }
- }
- }
- }catch(e){}
- if(on){
- if (!eval("msgset."+module+".i_status")){
- snopshot[module]=true
- showAlls()
- }
- $("#"+module+" .show-days").html(tiptxt)
- }else{
- $("#"+module+" .show-days").html(tiptxt).hide()
- }
- }else if(type==1){//提交修改时
- if(on){
- if(module=="tender"){
- if(typeof(msgset.tender) != "undefined"){
- if(!msgset.tender.i_status){
- if (!msgset.tender.i_status){
- snopshot[module]=true
- }else{
- snopshot[module]=false
- }
- }
- }else{
- snopshot[module]=true
- }
- }else if(module=="bid"){
- if(typeof(msgset.bid) != "undefined"){
- if(!msgset.bid.i_status){
- if (!msgset.bid.i_status){
- snopshot[module]=true
- }else{
- snopshot[module]=false
- }
- }
- }else{
- snopshot[module]=true
- }
- }
- showAlls()
- }else{
- snopshot[module]=false
- showAlls()
- }
- }
- }
- function commonAjaxReq(object,module){
- //是关的不用处理
- var dataObj = {
- reqType: "other",
- snopshot:false
- };
- if($("#"+module+"-on-off").hasClass("open")){
- //开服务要校验
- showSnopshot(module,1,1)
- $("#"+module+" .show-days").show()
- }else{
- showSnopshot(module,1,0)
- $("#"+module+" .show-days").hide()
- }
- 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('<div class="com-last">'+value+'</div>');
- }
- }
- }
- //关键词
- 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(",");
- }
- dataObj[module+"_keys"] = this.setKeyWord(module);
- dataObj[module+"_scope"] = this.setScope(module);
- if(dataObj[module+"_keys"].length > 0 && dataObj[module+"_scope"] == ""){
- dataObj[module+"_scope"] = "A";
- }
- dataObj[module+"_switchstatus"] = $("#"+module+"-on-off").hasClass("open")?1:0
-
- /*****************************************/
- $.ajax({
- type: "POST",
- url: "/member/swordfish/ajaxReq",
- data: dataObj,
- dataType: "json",
- traditional: true,
- success: function(r){
- if(object != null){
- thisClass.afterCommit();
- }
- },
- error: function(){
-
- }
- });
- }
- var winWidth=300;
- $(function(){
- winWidth=$(window).width();
- 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('<div class="com-last">全国</div>');
- }
- }
- var setKeyWord = function(type,keys){
- if(typeof(keys) == "undefined" || keys.length == 0){
- return;
- }
- for(var i=0;i<keys.length;i++){
- keys[i] = keys[i].replace(/\+/g," ");
- KeyWordDialog.AppendNode($("#"+type+"-keyword"),keys[i]);
- }
- $("#"+type+"-content li:first").append('<div class="com-last">'+keys.join(";")+'</div>');
- }
- 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<scopeArray.length;i++){
- dialogObj.find(".btn").each(function(){
- if($(this).text() == scopeArray[i]){
- $(this).addClass("active");
- return false;
- }
- });
- }
- }
- $("#"+type+"-content li:last").append('<div class="com-last">'+scope.replace(/,/g,";")+'</div>');
- }
- $("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);
- if(msgset.tender.i_switchstatus){
- turnOn($("#tender-on-off"));
- //判断要不要还原提示
- showSnopshot("tender",0,1)
- }else{
- showSnopshot("tender",0,0)
- }
- }
- if(typeof(msgset.bid) != "undefined"){
- setKeyWord("bid",msgset.bid.a_key);
- setScope("bid",msgset.bid.s_scope);
- if(msgset.bid.i_switchstatus){
- turnOn($("#bid-on-off"));
- //判断要不要还原提示
- showSnopshot("bid",0,1)
- }else{
- showSnopshot("bid",0,0)
- }
- }
- //开关
- $(".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,$(this).attr("v"));
- });
- //收费规则
- $(".rule").closest(".parent-node").click(function(){
- $(".credit-dialog").show();
- $("html,body").addClass("overflow-hidden");
- })
- $("#credit-dialog-back").click(function(){
- $(".credit-dialog").hide();
- $("html,body").removeClass("overflow-hidden");
- });
- //
- $("#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;
- }
- });
- //剑鱼协议
- if(winWidth<341){
- $("#prexieyi").append("<br>");
- }
- });
|