xietongfuwu-message.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. var page = 1,
  2. pagesize = 15;
  3. var $notext = $('#wushuju');
  4. var $scroll = $('.mui-scroll-wrapper');
  5. var $list = $('#show_content');
  6. mui.plusReady(function(){
  7. backParent()
  8. queryListData();
  9. bindEvents();
  10. })
  11. function backParent() {
  12. var old_back = mui.back;
  13. mui.back = function() {
  14. var self = plus.webview.currentWebview();
  15. if(self.opener && self.opener()) {
  16. mui.fire(self.opener(), "refresh");
  17. }
  18. old_back();
  19. }
  20. }
  21. function queryListData(fun,text){
  22. var params ={
  23. page:page,
  24. pagesize:pagesize
  25. }
  26. sendGet("doctor/pcCustomer/getCallServiceMes",params, function(){
  27. plus.nativeUI.closeWaiting();
  28. fun&&fun.call(this,false)
  29. mui.toast("请求失败");
  30. }, function(res){
  31. plus.nativeUI.closeWaiting();
  32. if(res.status == 200){
  33. var html = template('list_tmp',{list:res.data})
  34. if(page == 1 && res.data.length==0){
  35. $notext.show();
  36. $scroll.hide();
  37. }else{
  38. $notext.hide();
  39. $scroll.show();
  40. if(text == 'down'){
  41. $list.empty();
  42. fun&&fun.call(this,false)
  43. }else{
  44. if(res.data.length < pagesize){
  45. fun&&fun.call(this,true)
  46. }else{
  47. fun&&fun.call(this,false)
  48. }
  49. }
  50. $list.append(html);
  51. }
  52. }else{
  53. fun&&fun.call(this,false)
  54. mui.toast("获取数据失败");
  55. }
  56. })
  57. }
  58. mui.init({
  59. pullRefresh : {
  60. container:'.mui-scroll-wrapper',
  61. down : {
  62. height:50,
  63. auto: false,
  64. contentdown : "下拉可以刷新",
  65. contentover : "释放立即刷新",
  66. contentrefresh : "正在刷新...",
  67. callback: function() {
  68. var self = this;
  69. page = 1;
  70. queryListData(function(value){
  71. setTimeout(function(){
  72. self.endPulldownToRefresh(false);
  73. mui('.mui-scroll-wrapper').pullRefresh().enablePullupToRefresh();
  74. },500)
  75. },'down')
  76. }
  77. },
  78. up : {
  79. height:50,
  80. contentrefresh : "正在加载...",
  81. contentnomore:'没有更多数据了',
  82. callback: function() {
  83. var self = this;
  84. page++;
  85. queryListData(function(value){
  86. setTimeout(function(){
  87. self.endPullupToRefresh(value);
  88. },500)
  89. },'up')
  90. }
  91. }
  92. }
  93. })
  94. function bindEvents(){
  95. $(".mui-scroll").on('tap', '.list-item', function(){
  96. var $this = $(this),
  97. xtCode = $this.attr("data-code");
  98. openWebview("xietongfuwu-detail.html", {
  99. code: xtCode
  100. })
  101. })
  102. }
  103. //整体刷新
  104. function reloadPageData(){
  105. plus.nativeUI.showWaiting();
  106. page = 1;
  107. $list.empty();
  108. queryListData();
  109. }
  110. window.addEventListener("refreshXTmsg", function(){
  111. reloadPageData()
  112. })