$(document).ready(function(){ var id = $.cookie('orgId'); var resourceId; /*资源列表查询*/ function getRecourceMe(n,isbind) { var resourceNameVa=$("#resouceName").val(); var $info={}; $info.orgId=id; $info.pageSize=3; if(resourceNameVa !="") { $info.key=resourceNameVa; } $info.pageNo=n; $.ajax({ "url": "/ajax/resource/pqForOrg", "type": "GET", "success": function(data) { console.log(data) if(data.success) { $("#resourceList").html(""); if(data.data.data.length==0) { $("#noresource").removeClass("displayNone"); return; }else{ $("#noresource").addClass("displayNone"); } resourceHtml(data.data.data); if(isbind == true) { $(".tcdPageCode").createPage({ pageCount: Math.ceil(data.data.total / data.data.pageSize), current: data.data.pageNo, backFn: function(p) { getRecourceMe(p,false); } }); } } }, "data": $info, dataType: "json", 'error': function() { $.MsgBox.Alert('提示', '服务器连接超时!'); } }); } getRecourceMe(1,true); function resourceHtml($data) { for(var i=0;i<$data.length;i++) { var imgSrc="../images/default-resource.jpg"; var oTime,pageview="",draftLable="",oHtml,oLi=''; if($data[i].images.length) { imgSrc="/data/resource/"+$data[i].images[0].imageSrc } console.log($data[i].status) if($data[i].status==0) { oTime="修改于 "+timeTran($data[i].modifyTime); draftLable='草稿'; oHtml="resourceIssue.html"; oLi="class='draftList'" }else{ oTime="发布于 "+timeTran($data[i].publishTime); pageview='
  • 阅读量 '+$data[i].pageViews+'
  • '; oHtml="../resourceShow.html" } var oStr='
  • '+ ''+ '
    ' + '
    '+ '

    '+$data[i].resourceName+'

    '+ '
      '+ '
    • '+oTime+'
    • '+pageview+ '
    '+draftLable+ '
    '+ '
    '+ ''+ '
  • ' $("#resourceList").append(oStr); } } /*时间格式转换*/ function timeTran(otm) { var month, day, hour, minu; var monFirst = otm.substring(4, 5); var dayFirst = otm.substring(6, 7); if(monFirst == "0") { month = otm.substring(5, 6) } else { month = otm.substring(4, 6) } if(dayFirst == "0") { day = otm.substring(7, 8); } else { day = otm.substring(6, 8); } hour = otm.substring(8, 10); minu = otm.substring(10, 12); return month + "月" + day + "日 " + hour + ":" + minu; } /*点击修改跳转修改页面*/ $("#resourceList").on("click",".editThis",function(){ location.href="resourceIssue.html?resourceId="+$(this).attr("data-id") }) /*点击删除跳转修改页面*/ $("#resourceList").on("click",".deteleThis2",function(){ resourceId=$(this).attr("data-id"); $.MsgBox.Confirm("提示", "确认删除该资源?",deleResource); }) /*删除函数*/ function deleResource() { $.ajax({ "url": "/ajax/resource/delete", "type": "POST", "success": function(data) { if(data.success) { getRecourceMe(1,false); } }, "data": {"resourceId":resourceId}, "beforeSend": function() { /*console.log(this.data)*/ }, "contentType": "application/x-www-form-urlencoded", dataType: "json" }); } /*输入资源名称限制字数*/ $("#resouceName").bind({ keyup: function() { if($(this).val().length > 30) { $(this).val($(this).val().substr(0, 30)); } } }); /*点击搜索*/ $(".searchSpan").click(function(){ $(".tcdPageCode").remove(); $(".aboutRes").append('
    '); getRecourceMe(1,true); }) })