teamlist.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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/AppTeamController/getTeamList", obj, this.getQiyeEnterpriseListSuccess)
  31. },
  32. getQiyeEnterpriseListSuccess(res) {
  33. console.log("@@@@",res)
  34. if(res.code==200){
  35. // 显示加载图标
  36. wx.showLoading({
  37. title: '玩命加载中',
  38. })
  39. var that = this
  40. if(res.data.rows.length==0){
  41. wx.showToast({
  42. title: '暂无更多数据',
  43. icon:"none"
  44. })
  45. wx.hideLoading()
  46. }
  47. if (this.data.isRefresh) {
  48. this.setData({
  49. enterpriseList: res.data.rows,
  50. total: res.data.total
  51. })
  52. // 隐藏导航栏加载框
  53. setTimeout(function () {
  54. that.setData({
  55. loadingData: false
  56. });
  57. wx.hideNavigationBarLoading();
  58. // 停止下拉动作
  59. wx.stopPullDownRefresh();
  60. wx.hideLoading()
  61. }, 1000)
  62. } else {
  63. this.setData({
  64. enterpriseList: this.data.enterpriseList.concat(res.data.rows)
  65. })
  66. // 隐藏加载框
  67. setTimeout(function () {
  68. that.setData({
  69. hidden: true,
  70. loadingData: false
  71. });
  72. wx.hideLoading();
  73. }, 1000)
  74. }
  75. }else{
  76. console.log("@@!","请求失败")
  77. }
  78. },
  79. onPullDownRefresh: function () {
  80. // 显示顶部刷新图标
  81. wx.showNavigationBarLoading();
  82. var that = this;
  83. var loadingData = this.data.loadingData
  84. if (loadingData) {
  85. return;
  86. }
  87. that.setData({
  88. pageNum: 1,
  89. isRefresh: true
  90. })
  91. this.loadData()
  92. },
  93. /**
  94. * 页面上拉触底事件的处理函数
  95. */
  96. onReachBottom: function () {
  97. let that = this
  98. var loadingData = that.data.loadingData
  99. var hidden = that.data.hidden
  100. // 页数+1
  101. that.setData({
  102. pageNum: that.data.pageNum + 1,
  103. isRefresh: false
  104. })
  105. if (hidden) {
  106. that.setData({
  107. hidden: false
  108. });
  109. console.info(that.data.hidden);
  110. }
  111. if (loadingData) {
  112. return;
  113. }
  114. that.setData({
  115. loadingData: true
  116. });
  117. //console.log("@@@@"+Math.ceil(this.data.total/10))
  118. // if(Math.ceil(that.data.total/10)>=that.data.pageNum){
  119. that.loadData();
  120. // }else{
  121. // setTimeout(function () {
  122. // that.setData({
  123. // hidden: true,
  124. // });
  125. // }, 2000)
  126. // }
  127. },
  128. bindViewDetails(e) {
  129. let teamlist_details = e.currentTarget.dataset.index
  130. wx.navigateTo({
  131. url: '../teamlist/details/team_details?details='+JSON.stringify(teamlist_details)
  132. })
  133. },
  134. // 搜索结果跳页
  135. bindViewSearchEnd() {
  136. wx.navigateTo({
  137. url:'../teamlist/serch/team_serch'
  138. })
  139. },
  140. })