warehouselist.js 3.7 KB

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