msgListSub.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. var msgType=mobile.getUrlVars("msgType");
  2. var pageNum = 1;
  3. var pageSize=10;
  4. var totalPage=0;
  5. mui.init({
  6. pullRefresh: {
  7. container: '#pullrefresh',
  8. up: {
  9. contentrefresh: '正在加载...',
  10. callback: pullupRefresh
  11. }
  12. }
  13. });
  14. mui.ready(function() {
  15. pullupRefresh();
  16. $('.mui-table-view').on('tap', '.mui-table-view-cell', function(event) {
  17. top.location.href=$(this).find("a").attr("href");
  18. });
  19. });
  20. function nofind(){
  21. var img=event.srcElement;
  22. img.src=resourceUrl+"/mobile/image/blank_2.png";
  23. img.onerror=null;
  24. }
  25. /**
  26. * 上拉加载具体业务实现
  27. */
  28. function pullupRefresh() {
  29. query();
  30. }
  31. function query() {
  32. mobile.ajaxPost(base+"/wxMsg/queryMobile",{
  33. msgType:msgType,
  34. pageNumber:pageNum,
  35. pageSize:pageSize
  36. },function(json){
  37. totalPage=json.totalPage;
  38. if(json.list&&json.list.length>0){
  39. if(pageNum>=totalPage){
  40. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
  41. }else{
  42. mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
  43. }
  44. pageNum++;
  45. jQuery.each(json.list,function(id,item){
  46. var html="";
  47. html +='<li class="mui-table-view-cell mui-media" id="'+item.id+'">';
  48. html +='<a href="'+item.msg_url+'">';
  49. if(item.msg_img){
  50. html +='<img class="mui-media-object mui-pull-left" src="'+imgUrl+item.msg_img+'" onerror="nofind();">';
  51. }
  52. html +='<div class="mui-media-body">';
  53. html +='<p class="mui-ellipsis-2 color1 fs14" style="height: 38px;">'+mobile.nullToSpace(item.msg_title)+'</p>';
  54. if (parseInt(item.visit_num)>100000){
  55. item.visit_num="100000+";
  56. }
  57. html +='<p class="lh18 fs12 items"><span class="item">'+item.publish_date+'</span><span>阅读 '+item.visit_num+'</span></p>';
  58. html +='</div>';
  59. html +='</a>';
  60. html +='</li>';
  61. jQuery(".mui-table-view").append(html);
  62. });
  63. }else{
  64. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
  65. if(pageNum==1){
  66. mobile.tip(".mui-content","暂无数据");
  67. }
  68. }
  69. });
  70. }
  71. function getListContent(){
  72. ajaxPost(ctx+'/wxPubMsgListController/getListContent.do',{listId:listId},function(json){
  73. if(json.status=="error"){
  74. return layer.open({content: '请求异常',time: 3});
  75. }
  76. if(json.data){
  77. $(".mui-title").html(json.data.listTitle);
  78. $("#post-date").html("发布日期:"+json.data.publishTimeString+"");
  79. $("#js_content").html(json.data.listCont);
  80. }
  81. });
  82. }
  83. function getAll(){
  84. ajaxPost(ctx+'/wxPubMsgListController/getAll.do',{},function(json){
  85. if(json.status=="error"){
  86. return layer.open({content: '请求异常',time: 3});
  87. }
  88. $.each(json,function(id,item){
  89. $("#type"+item.LIST_TYPE+ " .mui-badge").removeClass("mui-hidden");
  90. $("#type"+item.LIST_TYPE+ " .mui-badge").html(parseInt($("#type"+item.LIST_TYPE+ " .mui-badge").html())+1);
  91. });
  92. });
  93. }