msgListSub.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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">'+mobile.nullToSpace(item.msg_title)+'</p>';
  54. html +='<p class="lh18 fs12">'+item.create_time.substring(0,10)+'</p>';
  55. html +='</div>';
  56. html +='</a>';
  57. html +='</li>';
  58. jQuery(".mui-table-view").append(html);
  59. });
  60. }else{
  61. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
  62. if(pageNum==1){
  63. mobile.tip(".mui-content","暂无数据");
  64. }
  65. }
  66. });
  67. }
  68. function getListContent(){
  69. ajaxPost(ctx+'/wxPubMsgListController/getListContent.do',{listId:listId},function(json){
  70. if(json.status=="error"){
  71. return layer.open({content: '请求异常',time: 3});
  72. }
  73. if(json.data){
  74. $(".mui-title").html(json.data.listTitle);
  75. $("#post-date").html("发布日期:"+json.data.publishTimeString+"");
  76. $("#js_content").html(json.data.listCont);
  77. }
  78. });
  79. }
  80. function getAll(){
  81. ajaxPost(ctx+'/wxPubMsgListController/getAll.do',{},function(json){
  82. if(json.status=="error"){
  83. return layer.open({content: '请求异常',time: 3});
  84. }
  85. $.each(json,function(id,item){
  86. $("#type"+item.LIST_TYPE+ " .mui-badge").removeClass("mui-hidden");
  87. $("#type"+item.LIST_TYPE+ " .mui-badge").html(parseInt($("#type"+item.LIST_TYPE+ " .mui-badge").html())+1);
  88. });
  89. });
  90. }