portal html css js resource

resourceList.js 4.2KB

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