notice.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import http from '../../base/httputil'
  2. const app = getApp()
  3. Page({
  4. data: {
  5. /**
  6. * 控制上拉到底部时是否出现 "数据加载中..."
  7. */
  8. hidden: true,
  9. /**
  10. * 数据是否正在加载中,避免数据多次加载
  11. */
  12. loadingData: false,
  13. enterpriseList: [],
  14. isRefresh: true,
  15. total: 0,
  16. pageNum: 1 // 页码
  17. },
  18. onLoad: function () {
  19. // wx.showLoading({
  20. // title: '加载中'
  21. // })
  22. this.loadData()
  23. },
  24. //加载数据
  25. loadData: function () {
  26. let obj = new Object()
  27. obj.pageNum = this.data.pageNum
  28. obj.pageSize = 10
  29. obj.reasonable= false
  30. http.send_get("/system/AppNoticeController/getNotice", obj, this.getQiyeEnterpriseListSuccess)
  31. },
  32. getQiyeEnterpriseListSuccess(res) {
  33. // 显示加载图标
  34. wx.showLoading({
  35. title: '玩命加载中',
  36. })
  37. var that = this
  38. if(res.data.rows.length==0){
  39. wx.showToast({
  40. title: '暂无更多数据',
  41. icon:"none"
  42. })
  43. }
  44. if (this.data.isRefresh) {
  45. this.setData({
  46. enterpriseList: res.data.rows,
  47. total: res.data.total
  48. })
  49. // 隐藏导航栏加载框
  50. setTimeout(function () {
  51. that.setData({
  52. loadingData: false
  53. });
  54. wx.hideNavigationBarLoading();
  55. // 停止下拉动作
  56. wx.stopPullDownRefresh();
  57. wx.hideLoading()
  58. }, 1000)
  59. } else {
  60. this.setData({
  61. enterpriseList: this.data.enterpriseList.concat(res.data.rows)
  62. })
  63. // 隐藏加载框
  64. setTimeout(function () {
  65. that.setData({
  66. hidden: true,
  67. loadingData: false
  68. });
  69. wx.hideLoading();
  70. }, 1000)
  71. }
  72. },
  73. onPullDownRefresh: function () {
  74. // 显示顶部刷新图标
  75. wx.showNavigationBarLoading();
  76. var that = this;
  77. var loadingData = this.data.loadingData
  78. if (loadingData) {
  79. return;
  80. }
  81. that.setData({
  82. pageNum: 1,
  83. isRefresh: true
  84. })
  85. this.loadData()
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. let that = this
  92. var loadingData = that.data.loadingData
  93. var hidden = that.data.hidden
  94. // 页数+1
  95. that.setData({
  96. pageNum: that.data.pageNum + 1,
  97. isRefresh: false
  98. })
  99. if (hidden) {
  100. that.setData({
  101. hidden: false
  102. });
  103. console.info(that.data.hidden);
  104. }
  105. if (loadingData) {
  106. return;
  107. }
  108. that.setData({
  109. loadingData: true
  110. });
  111. //console.log("@@@@"+Math.ceil(this.data.total/10))
  112. // if(Math.ceil(that.data.total/10)>=that.data.pageNum){
  113. that.loadData();
  114. // }else{
  115. // setTimeout(function () {
  116. // that.setData({
  117. // hidden: true,
  118. // });
  119. // }, 2000)
  120. // }
  121. },
  122. bindViewDetails(e) {
  123. let details = e.currentTarget.dataset.index
  124.     let competition = {}//这是一个很长的很多数据的对象
  125. //转成String编码一下
  126. competition = encodeURIComponent(JSON.stringify(details))
  127.     wx.navigateTo({
  128.    
  129.       url:`../notice/notice_details?details=${competition}`
  130.     })
  131.   }
  132. })