portal html css js resource

cmp-needList.js 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. $(document).ready(function() {
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. var id = $.cookie('orgId');
  4. if(id == "" || id == null || id == "null"){
  5. location.href = "cmp-settled-log.html";
  6. }
  7. demandList(true,10, 1);
  8. /*查询企业认证状态*/
  9. function companyAuthentState() {
  10. $.ajax({
  11. url: '/ajax/org/authStatus',
  12. type: "GET",
  13. timeout: 10000,
  14. dataType: "json",
  15. data: {
  16. "id": id
  17. },
  18. beforeSend: function() {},
  19. success: function(data, textState) {
  20. if(data.success) {
  21. console.log(data);
  22. if(data.data == 3) {
  23. $("#companyDemandList").show();
  24. } else {
  25. $("#identityState").show();
  26. }
  27. }
  28. },
  29. error: function(XMLHttpRequest, textStats, errorThrown) {
  30. $.MsgBox.Alert('提示', '服务器请求失败')
  31. }
  32. })
  33. }
  34. companyAuthentState();
  35. $("#cmpneedList").on("click",".closeThis",function(){//关闭
  36. var dataId=$(this).parents("li").find(".urlHref").attr("data-id");
  37. $.MsgBox.Confirm("提示", "确认要关闭该需求?",function(){
  38. $.ajax({
  39. "url": "/ajax/demand/close",
  40. "type": "POST",
  41. "async": true,
  42. "data":{
  43. "id":dataId,
  44. "uid":id
  45. },
  46. "success": function(data) {
  47. if(data.success && data.data) {
  48. console.log(data);
  49. $(".madiaEdit").remove();
  50. demandList(true,10, 1);
  51. }
  52. }
  53. });
  54. });
  55. })
  56. /*需求列表*/
  57. function demandList(isbind, pageSize, pageNo) {
  58. $.ajax({
  59. url: "/ajax/demand/pq",
  60. type: "GET",
  61. timeout: 10000,
  62. dataType: "json",
  63. data: {
  64. "oid": id,
  65. "pageNo": pageNo,
  66. "pageSize": pageSize
  67. },
  68. "beforeSend": function() {
  69. $("#cmpneedList").append('<img src="../images/loading.gif" class="loading" />');
  70. },
  71. success: function(data, textState) {
  72. if(data.success) {
  73. console.log(data);
  74. $("#cmpneedList").html("");
  75. var $info = data.data.data;
  76. if($info.length > 0){
  77. for(var i = 0; i < $info.length; i++) {
  78. var liStr=$("<li></li>").appendTo("#cmpneedList");
  79. demandHtml($info[i],liStr);
  80. userFun($info[i].creator,liStr);
  81. }
  82. if($info.length != 0) {
  83. if(isbind == true) {
  84. $(".tcdPageCode").createPage({
  85. pageCount: Math.ceil(data.data.total / pageSize),
  86. current: data.data.data.pageNo,
  87. backFn: function(p) {
  88. $("#cmpneedList").html("");
  89. demandList(false,10, p);
  90. document.body.scrollTop = document.documentElement.scrollTop = 0;
  91. }
  92. });
  93. }
  94. }
  95. }else{
  96. $("#cmpneedList").parent().find(".nodatabox").removeClass("displayNone")
  97. }
  98. }
  99. $(".loading").remove();
  100. },
  101. error: function() {
  102. }
  103. })
  104. }
  105. function demandHtml($data,liStr) {
  106. var sowU="";
  107. if($data.pageViews!=0){
  108. sowU='<li><span>浏览量 '+$data.pageViews+'</span></li>'
  109. }
  110. var statusU="";
  111. var dateGap = delayDay($data.invalidDay);
  112. if($data.state==1 && dateGap=="1"){
  113. statusU='<li><span class="draftLable">即将于 '+TimeTr($data.invalidDay)+' 过期</span></li>'
  114. }
  115. if($data.state==0){
  116. statusU='<li><span class="draftLable">已于 '+TimeTr($data.invalidDay)+' 过期</span></li>'
  117. }else if($data.state==2){
  118. statusU='<li><span style="color:#14b521;">已于 '+TimeTr($data.modifyTime)+' 完成</span></li>'
  119. }else if($data.state==3){
  120. statusU='<li><span>已于 '+TimeTr($data.modifyTime)+' 关闭</span></li>'
  121. }
  122. var closStr='',pdRight="";
  123. if($data.state==1 || $data.state==0){
  124. pdRight="padding-right:80px";
  125. closStr += '<ul class="madiaEdit"><li><span class="closeThis">关闭</span></li></ul>'
  126. }
  127. var strCon='';
  128. strCon+='<a class="madiaInfo urlHref" style="'+pdRight+'" target="_blank" href="../demandShow.html?demandId='+$data.id+'" data-id="'+$data.id+'">'
  129. strCon+='<p class="h1Font ellipsisSty">'+ $data.title +'</p>'
  130. strCon+='<ul class="showliTop h2Font clearfix">'
  131. strCon+='<li><span>发布于 '+commenTime($data.createTime)+'</span></li>'
  132. strCon+= sowU
  133. strCon+='<li><span class="creator"></span></li>'
  134. strCon+= statusU
  135. strCon+='</ul>'
  136. strCon+='</a>'+closStr
  137. $(strCon).appendTo(liStr);
  138. }
  139. function userFun(id,$listItem) {
  140. $.ajax({
  141. "url": "/ajax/professor/editBaseInfo/" + id,
  142. "type": "get",
  143. "async": true,
  144. "data":{
  145. "id":id
  146. },
  147. "success": function(data) {
  148. if(data.success && data.data) {
  149. $listItem.find(".creator").text(data.data.name);
  150. }
  151. },
  152. "error": function() {
  153. $.MsgBox.Alert('提示', '链接服务器超时')
  154. }
  155. });
  156. }
  157. function delayDay(startTime){
  158. var dateToday = new Date();
  159. var dateInvalid = new Date();
  160. dateInvalid.setFullYear(parseInt(startTime.substring(0, 4)));
  161. dateInvalid.setMonth(parseInt(startTime.substring(4, 6)) - 1);
  162. dateInvalid.setDate(parseInt(startTime.substring(6, 8)));
  163. var dateGap = Math.abs(dateToday.getTime() - dateInvalid.getTime());
  164. var ifDelay="0";
  165. if(dateGap < 604800000){
  166. ifDelay="1";
  167. }
  168. return ifDelay;
  169. }
  170. })