main.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. //招标公告
  2. var Tender = {
  3. keyWordDialog: null,
  4. getKeyWordDialog: function(clickLi){
  5. if(this.keyWordDialog == null){
  6. this.keyWordDialog = new KeyWordDialog("tender",clickLi);
  7. }
  8. return this.keyWordDialog;
  9. },
  10. scopeDialog: null,
  11. getScopeDialog: function(clickLi){
  12. if(this.scopeDialog == null){
  13. this.scopeDialog = new ScopeDialog("tender",clickLi);
  14. }
  15. return this.scopeDialog;
  16. }
  17. };
  18. //中标公告
  19. var Bid = {
  20. keyWordDialog: null,
  21. getKeyWordDialog: function(clickLi){
  22. if(this.keyWordDialog == null){
  23. this.keyWordDialog = new KeyWordDialog("bid",clickLi);
  24. }
  25. return this.keyWordDialog;
  26. },
  27. scopeDialog: null,
  28. getScopeDialog: function(clickLi){
  29. if(this.scopeDialog == null){
  30. this.scopeDialog = new ScopeDialog("bid",clickLi);
  31. }
  32. return this.scopeDialog;
  33. }
  34. };
  35. //关键字弹出框
  36. function KeyWordDialog(type,clickLi){
  37. var thisClass = this;
  38. var dialogObj = $("#"+type+"-keyword");
  39. this.type = type;
  40. this.clickLi = clickLi;
  41. this.show = function(){
  42. dialogObj.show();
  43. $("html,body").addClass("overflow-hidden");
  44. $(window).resize(function(){
  45. KeyWordDialog.SetContentHeight(dialogObj);
  46. });
  47. };
  48. this.hide = function(){
  49. dialogObj.hide();
  50. $("html,body").removeClass("overflow-hidden");
  51. $(window).unbind("resize");
  52. };
  53. KeyWordDialog.SetContentHeight(dialogObj);
  54. dialogObj.find(".addKeyWord").click(function(){
  55. KeyWordDialog.AppendNode(dialogObj);
  56. });
  57. dialogObj.find(".submit").click(function(){
  58. commonAjaxReq(thisClass,type);
  59. });
  60. if(dialogObj.find(".keyWordGroup").length == 0){
  61. KeyWordDialog.AppendNode(dialogObj);
  62. }
  63. }
  64. KeyWordDialog.SetContentHeight = function(dialogObj){
  65. var contentObj = dialogObj.find(".dialog-content");
  66. var padding = parseInt(contentObj.css('padding-top'))+parseInt(contentObj.css('padding-bottom'))
  67. contentObj.css("max-height",document.body.clientHeight-dialogObj.find(".dialog-head").height()-padding-40);
  68. }
  69. KeyWordDialog.AppendNode = function(dialogObj,value){
  70. var getHtml = function(index,value){
  71. return '<div class="keyWordGroup">'
  72. +'<lable style="white-space:nowrap;">关键词<font>'+index+'</font></lable>'
  73. +'<div><input type="text" value="'+(value?value:"")+'" placeholder="示例:综合布线 电话线 网线" maxlength="100"></div>'
  74. +'<div>'+(index==1?'':'<img src="/wxswordfish/images/delete.png" class="delete">')+'</div>'
  75. +'</div>';
  76. }
  77. var count = dialogObj.find(".keyWordGroup").length;
  78. if(count >= 10){
  79. return;
  80. }
  81. var obj = $(getHtml(count+1,value));
  82. dialogObj.find(".addKeyWordArea").before(obj);
  83. //自动滚动到底部
  84. $("#a_end")[0].scrollIntoView();
  85. obj.find(".delete").click(function(){
  86. dialogObj.find(".addKeyWord").removeAttr("disabled");
  87. $(this).parents(".keyWordGroup").remove();
  88. dialogObj.find(".keyWordGroup").each(function(i){
  89. $(this).children("lable").children("font").text(i+1);
  90. });
  91. });
  92. if(typeof(value) == "undefined" || value == ""){
  93. obj.find("[type='text']").focus();
  94. }
  95. if(count >= 9){
  96. dialogObj.find(".addKeyWord").attr("disabled",true);
  97. }
  98. }
  99. //信息范围
  100. function ScopeDialog(type,clickLi){
  101. var thisClass = this;
  102. var dialogObj = $("#"+type+"-scope");
  103. this.type = type;
  104. this.clickLi = clickLi;
  105. this.show = function(){
  106. dialogObj.show();
  107. $("html,body").addClass("overflow-hidden");
  108. };
  109. this.hide = function(){
  110. dialogObj.hide();
  111. $("html,body").removeClass("overflow-hidden");
  112. };
  113. dialogObj.find(".dialog-content").css("max-height",document.body.clientHeight-dialogObj.find(".dialog-head").height()-40);
  114. dialogObj.find(".btn").click(function(){
  115. if($(this).parent().index() == 0){
  116. dialogObj.find(".btn").removeClass("active");
  117. }else{
  118. dialogObj.find("ul:first li:first .btn").removeClass("active");
  119. }
  120. $(this).toggleClass("active");
  121. if(dialogObj.find(".btn.active").length == 0){
  122. dialogObj.find("ul:first li:first .btn").addClass("active");
  123. }
  124. });
  125. dialogObj.find(".submit").click(function(){
  126. commonAjaxReq(thisClass,type);
  127. });
  128. }
  129. //取积分
  130. function getCredit(){
  131. var score=0
  132. $.ajax({
  133. dataType:"json",
  134. url:"/member/credit/getcredit",
  135. type:"POST",
  136. async:false,
  137. success:function(msg){
  138. if(msg){
  139. if(msg.flag){
  140. score=msg.val
  141. }else{
  142. alert("请重新进入页剑鱼页面后操作")
  143. }
  144. }
  145. },
  146. error:function(x,st,err){
  147. alert("请稍后再试"+st)
  148. }
  149. })
  150. return score
  151. }
  152. var snopshot=[];
  153. function showAlls(){
  154. var n=0,str=[],sel=[];
  155. for(var i in snopshot){
  156. if(snopshot[i]){
  157. n++;
  158. str.push((i=="tender")?"招标公告":"中标公告")
  159. sel.push("types="+i)
  160. }
  161. }
  162. if(n>0){
  163. var num=getCredit();
  164. var pay=1000*n, rem=num-pay,strs="扣除后将剩余"+rem+"积分";
  165. var contents="您添加了"+n+"个信息栏目("+str.join("、")+"),确认后系统将每月扣除"+pay+"积分,您目前的积分余额是"+num+"积分,";
  166. if(rem<0){
  167. $("#credit_yes").unbind("click").hide()
  168. strs="请充值或去赚积分。";
  169. }else{
  170. $("#credit_yes").unbind("click").bind("click",function(e){
  171. $("#rule-content").text(contents+strs)
  172. $(".tip-dialog").show();
  173. $("#tip-dialog-back").unbind("click").bind("click",function(e){
  174. $("#tip-dialog-back").unbind("click");
  175. $.ajax({
  176. dataType:"json",
  177. url:"/member/credit/swordfishpay",
  178. data:sel.join("&"),
  179. type:"POST",
  180. async:false,
  181. success:function(msg){
  182. if(msg){
  183. if(msg.flag){
  184. //有session
  185. if(msg.oprstatus){
  186. //扣积分操作成功
  187. $(".visible").hide()
  188. }else{
  189. //扣积分操作无效
  190. alert("操作无效,请重新进入页剑鱼页面后操作")
  191. }
  192. }else{
  193. //无session
  194. alert("请重新进入页剑鱼页面后操作")
  195. }
  196. }
  197. },
  198. error:function(x,st,err){
  199. alert("请稍后再试"+st)
  200. }
  201. })
  202. window.location.reload()
  203. })
  204. $("html,body").addClass("overflow-hidden");
  205. })
  206. }
  207. $("#credit_no").unbind("click").bind("click",function(e){
  208. $.ajax({
  209. dataType:"json",
  210. url:"/member/credit/swordfishpay",
  211. data:sel.join("&")+"&no=1",
  212. type:"POST",
  213. async:false,
  214. success:function(msg){
  215. if(msg){
  216. if(msg.flag){
  217. //有session
  218. if(msg.oprstatus){
  219. //取消操作成功
  220. $(".visible").hide()
  221. }else{
  222. //取消操作无效
  223. alert("操作无效,请重新进入页剑鱼页面后操作")
  224. }
  225. }else{
  226. //无session
  227. alert("请重新进入页剑鱼页面后操作")
  228. }
  229. }
  230. },
  231. error:function(x,st,err){
  232. alert("请稍后再试"+st)
  233. }
  234. })
  235. window.location.reload()
  236. })
  237. $("#txt_tip").text(contents+strs)
  238. $(".visible").show()
  239. }else{
  240. $("#credit_yes").unbind("click")
  241. $(".visible").hide()
  242. }
  243. }
  244. function showSnopshot(module,type,on){
  245. //提示扣积分
  246. //alert(getCredit())
  247. if(type==0){//初始化
  248. //是开启状态
  249. //显示天数
  250. try{
  251. var days=eval("msgset."+module+".days")
  252. if(typeof days=="number"){
  253. if (days<6){
  254. var tiptxt="本栏目推送服务期还剩<d style='color:red'>"+days+"</d>天"
  255. if(winWidth<341){
  256. tiptxt="服务期还剩<d style='color:red'>"+days+"</d>天"
  257. }
  258. }
  259. }
  260. }catch(e){}
  261. if(on){
  262. if (!eval("msgset."+module+".i_status")){
  263. snopshot[module]=true
  264. showAlls()
  265. }
  266. $("#"+module+" .show-days").html(tiptxt)
  267. }else{
  268. $("#"+module+" .show-days").html(tiptxt).hide()
  269. }
  270. }else if(type==1){//提交修改时
  271. if(on){
  272. if(module=="tender"){
  273. if(typeof(msgset.tender) != "undefined"){
  274. if(!msgset.tender.i_status){
  275. if (!msgset.tender.i_status){
  276. snopshot[module]=true
  277. }else{
  278. snopshot[module]=false
  279. }
  280. }
  281. }else{
  282. snopshot[module]=true
  283. }
  284. }else if(module=="bid"){
  285. if(typeof(msgset.bid) != "undefined"){
  286. if(!msgset.bid.i_status){
  287. if (!msgset.bid.i_status){
  288. snopshot[module]=true
  289. }else{
  290. snopshot[module]=false
  291. }
  292. }
  293. }else{
  294. snopshot[module]=true
  295. }
  296. }
  297. showAlls()
  298. }else{
  299. snopshot[module]=false
  300. showAlls()
  301. }
  302. }
  303. }
  304. function commonAjaxReq(object,module){
  305. //是关的不用处理
  306. var dataObj = {
  307. reqType: "other",
  308. snopshot:false
  309. };
  310. if($("#"+module+"-on-off").hasClass("open")){
  311. //开服务要校验
  312. showSnopshot(module,1,1)
  313. $("#"+module+" .show-days").show()
  314. }else{
  315. showSnopshot(module,1,0)
  316. $("#"+module+" .show-days").hide()
  317. }
  318. var keysString = "",scopeString = "";
  319. var thisClass = this;
  320. this.afterCommit = function(){
  321. object.hide();
  322. var value = "";
  323. switch(object.clickLi.index()){
  324. case 0:
  325. value = keysString;
  326. break;
  327. case 1:
  328. value = scopeString;
  329. break;
  330. }
  331. value = value.substring(0,value.length-1);
  332. if(object.clickLi.children(".com-last").length == 1){
  333. if(value == ""){
  334. object.clickLi.children(".com-last").remove();
  335. }else{
  336. object.clickLi.children(".com-last").text(value);
  337. }
  338. }else{
  339. if(value != ""){
  340. object.clickLi.append('<div class="com-last">'+value+'</div>');
  341. }
  342. }
  343. }
  344. //关键词
  345. this.setKeyWord = function(type){
  346. var tender_keys = [];
  347. $("#"+type+"-keyword .keyWordGroup").each(function(){
  348. var value = $.trim($(this).find("[type='text']").val()).replace(/\r\n/g,"");
  349. if(value == ""){
  350. return true;
  351. }
  352. if(object != null && object.type == type){
  353. keysString += value+";";
  354. }
  355. tender_keys.push(value.replace(/\s+/g,"+"));
  356. });
  357. return tender_keys;
  358. }
  359. //信息范围
  360. this.setScope = function(type){
  361. var tender_scope = [];
  362. $("#"+type+"-scope .btn.active").each(function(){
  363. var thisText = $(this).text();
  364. if(thisText == "全国"){
  365. tender_scope.push("A");
  366. if(object != null && object.type == type){
  367. scopeString += "全国;";
  368. }
  369. return false;
  370. }else{
  371. tender_scope.push(thisText);
  372. if(object != null && object.type == type){
  373. scopeString += thisText+";";
  374. }
  375. }
  376. });
  377. return tender_scope.join(",");
  378. }
  379. dataObj[module+"_keys"] = this.setKeyWord(module);
  380. dataObj[module+"_scope"] = this.setScope(module);
  381. if(dataObj[module+"_keys"].length > 0 && dataObj[module+"_scope"] == ""){
  382. dataObj[module+"_scope"] = "A";
  383. }
  384. dataObj[module+"_switchstatus"] = $("#"+module+"-on-off").hasClass("open")?1:0
  385. /*****************************************/
  386. $.ajax({
  387. type: "POST",
  388. url: "/member/swordfish/ajaxReq",
  389. data: dataObj,
  390. dataType: "json",
  391. traditional: true,
  392. success: function(r){
  393. if(object != null){
  394. thisClass.afterCommit();
  395. }
  396. },
  397. error: function(){
  398. }
  399. });
  400. }
  401. var winWidth=300;
  402. $(function(){
  403. winWidth=$(window).width();
  404. var turnOn = function(obj){
  405. obj.addClass("open");
  406. var liobj = obj.parents("li");
  407. liobj.next().show();
  408. liobj.nextAll(".parent-node").eq(0).addClass("border-top");
  409. if(liobj.next(".child-node").find(".com-last").length == 0){
  410. liobj.next(".child-node").find("li:eq(1)").append('<div class="com-last">全国</div>');
  411. }
  412. }
  413. var setKeyWord = function(type,keys){
  414. if(typeof(keys) == "undefined" || keys.length == 0){
  415. return;
  416. }
  417. for(var i=0;i<keys.length;i++){
  418. keys[i] = keys[i].replace(/\+/g," ");
  419. KeyWordDialog.AppendNode($("#"+type+"-keyword"),keys[i]);
  420. }
  421. $("#"+type+"-content li:first").append('<div class="com-last">'+keys.join(";")+'</div>');
  422. }
  423. var setScope = function(type,scope){
  424. var dialogObj = $("#"+type+"-scope");
  425. if(typeof(scope) == "undefined" || scope == ""){
  426. return;
  427. }
  428. if(scope == "A"){
  429. dialogObj.find("ul:first li:first .btn").addClass("active");
  430. scope = "全国";
  431. }else{
  432. dialogObj.find("ul:first li:first .btn").removeClass("active");
  433. var scopeArray = scope.split(",");
  434. for(var i=0;i<scopeArray.length;i++){
  435. dialogObj.find(".btn").each(function(){
  436. if($(this).text() == scopeArray[i]){
  437. $(this).addClass("active");
  438. return false;
  439. }
  440. });
  441. }
  442. }
  443. $("#"+type+"-content li:last").append('<div class="com-last">'+scope.replace(/,/g,";")+'</div>');
  444. }
  445. $("body").append($("#tender-keyword").clone().removeAttr("id").attr("id","bid-keyword"))
  446. .append($("#tender-scope").clone().removeAttr("id").attr("id","bid-scope"));
  447. if(typeof(msgset.tender) != "undefined"){
  448. setKeyWord("tender",msgset.tender.a_key);
  449. setScope("tender",msgset.tender.s_scope);
  450. if(msgset.tender.i_switchstatus){
  451. turnOn($("#tender-on-off"));
  452. //判断要不要还原提示
  453. showSnopshot("tender",0,1)
  454. }else{
  455. showSnopshot("tender",0,0)
  456. }
  457. }
  458. if(typeof(msgset.bid) != "undefined"){
  459. setKeyWord("bid",msgset.bid.a_key);
  460. setScope("bid",msgset.bid.s_scope);
  461. if(msgset.bid.i_switchstatus){
  462. turnOn($("#bid-on-off"));
  463. //判断要不要还原提示
  464. showSnopshot("bid",0,1)
  465. }else{
  466. showSnopshot("bid",0,0)
  467. }
  468. }
  469. //开关
  470. $(".on-off").click(function(){
  471. if(this.id == "intelligence-on-off"){//企业情报
  472. alert("开发中,敬请期待!");
  473. return;
  474. }
  475. if($(this).hasClass("open")){
  476. $(this).removeClass("open")
  477. $(this).parents("li").next().hide();
  478. $(this).parents("li").nextAll(".parent-node").eq(0).removeClass("border-top");
  479. }else{
  480. turnOn($(this));
  481. }
  482. //判断是不是开,是开再判断是不是在有效期内,如果不在有效期内,则进行提示并存快照
  483. commonAjaxReq(null,$(this).attr("v"));
  484. });
  485. //收费规则
  486. $(".rule").closest(".parent-node").click(function(){
  487. $(".credit-dialog").show();
  488. $("html,body").addClass("overflow-hidden");
  489. })
  490. $("#credit-dialog-back").click(function(){
  491. $(".credit-dialog").hide();
  492. $("html,body").removeClass("overflow-hidden");
  493. });
  494. //
  495. $("#tender-content>li").click(function(){
  496. switch($(this).index()){
  497. case 0:
  498. Tender.getKeyWordDialog($(this)).show();
  499. break;
  500. case 1:
  501. Tender.getScopeDialog($(this)).show();
  502. break;
  503. }
  504. });
  505. $("#bid-content>li").click(function(){
  506. switch($(this).index()){
  507. case 0:
  508. Bid.getKeyWordDialog($(this)).show();
  509. break;
  510. case 1:
  511. Bid.getScopeDialog($(this)).show();
  512. break;
  513. }
  514. });
  515. //剑鱼协议
  516. if(winWidth<341){
  517. $("#prexieyi").append("<br>");
  518. }
  519. });