warehouselist.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. wx.hideLoading()
  61. }
  62. if (this.data.isRefresh) {
  63. this.setData({
  64. enterpriseList: res.data.rows,
  65. total: res.data.total
  66. })
  67. // 隐藏导航栏加载框
  68. setTimeout(function () {
  69. that.setData({
  70. loadingData: false
  71. });
  72. wx.hideNavigationBarLoading();
  73. // 停止下拉动作
  74. wx.stopPullDownRefresh();
  75. wx.hideLoading()
  76. }, 1000)
  77. } else {
  78. this.setData({
  79. enterpriseList: this.data.enterpriseList.concat(res.data.rows)
  80. })
  81. // 隐藏加载框
  82. setTimeout(function () {
  83. that.setData({
  84. hidden: true,
  85. loadingData: false
  86. });
  87. wx.hideLoading();
  88. }, 1000)
  89. }
  90. } else {
  91. console.log("@@!", "请求失败")
  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. })