portal html css js resource

resourceList.js 4.8KB

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