portal html css js resource

resourceList.js 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. $(document).ready(function(){
  2. $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
  3. var id = $.cookie('orgId');
  4. var resourceId;
  5. /*资源列表查询*/
  6. function getRecourceMe(n,isbind,num) {
  7. var resourceNameVa=$("#resouceName").val();
  8. var $info={};
  9. $info.orgId=id;
  10. $info.pageSize=10;
  11. if(resourceNameVa !="") {
  12. $info.key=resourceNameVa;
  13. }
  14. $info.pageNo=n;
  15. $.ajax({
  16. "url": "/ajax/resource/pqForOrg",
  17. "type": "GET",
  18. "success": function(data) {
  19. console.log(data)
  20. if(data.success) {
  21. $("#resourceList").html("");
  22. if(num==1) {
  23. if(data.data.data.length==0) {
  24. $("#noresource").removeClass("displayNone");
  25. $(".noContip").text("您还未发布任何资源");
  26. return;
  27. }else{
  28. $("#noresource").addClass("displayNone");
  29. }
  30. }else{
  31. if(data.data.data.length==0) {
  32. $("#noresource").removeClass("displayNone");
  33. $(".noContip").text("没有符合该搜索条件的内容");
  34. return;
  35. }else{
  36. $("#noresource").addClass("displayNone");
  37. }
  38. }
  39. resourceHtml(data.data.data);
  40. if(isbind == true) {
  41. $(".tcdPageCode").createPage({
  42. pageCount: Math.ceil(data.data.total / data.data.pageSize),
  43. current: data.data.pageNo,
  44. backFn: function(p) {
  45. getRecourceMe(p,false);
  46. }
  47. });
  48. }
  49. }
  50. },
  51. "data": $info,
  52. dataType: "json",
  53. 'error': function() {
  54. $.MsgBox.Alert('提示', '服务器连接超时!');
  55. }
  56. });
  57. }
  58. getRecourceMe(1,true);
  59. function resourceHtml($data) {
  60. for(var i=0;i<$data.length;i++) {
  61. var imgSrc="../images/default-resource.jpg";
  62. var oTime,pageview="",draftLable="",oHtml,oLi='';
  63. if($data[i].images.length) {
  64. imgSrc="/data/resource/"+$data[i].images[0].imageSrc
  65. }
  66. console.log($data[i].status)
  67. if($data[i].status==0) {
  68. oTime="修改于 "+timeTran($data[i].modifyTime);
  69. draftLable='<span class="draftLable">草稿</span>';
  70. oHtml="resourceIssue.html";
  71. oLi="class='draftList'"
  72. }else{
  73. oTime="发布于 "+timeTran($data[i].publishTime);
  74. pageview='<li><span>阅读量 '+$data[i].pageViews+'</span></li>';
  75. oHtml="../resourceShow.html"
  76. }
  77. var oStr='<li '+oLi+'>'+
  78. '<a href="'+oHtml+'?resourceId='+$data[i].resourceId+'" target="_blank">'+
  79. '<div class="madiaHead resouseHead" style="background-image: url('+imgSrc+');"></div>' +
  80. '<div class="madiaInfo">'+
  81. '<p class="h1Font ellipsisSty">'+$data[i].resourceName+'</p>'+
  82. '<ul class="h2Font clearfix">'+
  83. '<li><span>'+oTime+'</span></li>'+pageview+
  84. '</ul>'+draftLable+
  85. '</div>'+
  86. '</a>'+
  87. '<ul class="madiaEdit">'+
  88. '<li><span class="deteleThis2" data-id="'+$data[i].resourceId+'"></span></li>'+
  89. '<li><span class="editThis" data-id="'+$data[i].resourceId+'"></span></li>'+
  90. '</ul>'+
  91. '</li>'
  92. $("#resourceList").append(oStr);
  93. }
  94. }
  95. /*时间格式转换*/
  96. function timeTran(otm) {
  97. var month, day, hour, minu;
  98. var monFirst = otm.substring(4, 5);
  99. var dayFirst = otm.substring(6, 7);
  100. if(monFirst == "0") {
  101. month = otm.substring(5, 6)
  102. } else {
  103. month = otm.substring(4, 6)
  104. }
  105. if(dayFirst == "0") {
  106. day = otm.substring(7, 8);
  107. } else {
  108. day = otm.substring(6, 8);
  109. }
  110. hour = otm.substring(8, 10);
  111. minu = otm.substring(10, 12);
  112. return month + "月" + day + "日 " + hour + ":" + minu;
  113. }
  114. /*点击修改跳转修改页面*/
  115. $("#resourceList").on("click",".editThis",function(){
  116. location.href="resourceIssue.html?resourceId="+$(this).attr("data-id")
  117. })
  118. /*点击删除跳转修改页面*/
  119. $("#resourceList").on("click",".deteleThis2",function(){
  120. resourceId=$(this).attr("data-id");
  121. $.MsgBox.Confirm("提示", "确认删除该资源?",deleResource);
  122. })
  123. /*删除函数*/
  124. function deleResource() {
  125. $.ajax({
  126. "url": "/ajax/resource/delete",
  127. "type": "POST",
  128. "success": function(data) {
  129. if(data.success) {
  130. getRecourceMe(1,false);
  131. }
  132. },
  133. "data": {"resourceId":resourceId},
  134. "beforeSend": function() { /*console.log(this.data)*/ },
  135. "contentType": "application/x-www-form-urlencoded",
  136. dataType: "json"
  137. });
  138. }
  139. /*输入资源名称限制字数*/
  140. $("#resouceName").bind({
  141. keyup: function() {
  142. if($(this).val().length > 30) {
  143. $(this).val($(this).val().substr(0, 30));
  144. }
  145. }
  146. });
  147. /*点击搜索*/
  148. $(".searchSpan").click(function(){
  149. $(".tcdPageCode").remove();
  150. $(".aboutRes").append('<div class="tcdPageCode"></div>');
  151. getRecourceMe(1,true);
  152. })
  153. })