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