list.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. var page = 1;
  2. var app= getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. needAuth: false,
  9. isHideLoadMore: true,
  10. loadText: '正在加载',
  11. list: [],
  12. queryData: {
  13. createTime: null,
  14. communityId: null,
  15. page: page,
  16. pageSize: 20
  17. },
  18. status: ['待配送', '配送中', '已送达团长'],
  19. page: 1,
  20. searchKey: ""
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. this.data.queryData.createTime = null;
  27. this.getData();
  28. },
  29. /**
  30. * 获取数据
  31. */
  32. getData: function () {
  33. wx.showLoading({
  34. title: "加载中...",
  35. mask: true
  36. });
  37. this.setData({
  38. isHideLoadMore: true
  39. })
  40. this.data.no_list = 1
  41. let that = this;
  42. var token = wx.getStorageSync('token');
  43. app.util.request({
  44. 'url': 'entry/wxapp/index',
  45. 'data': {
  46. controller: 'community.get_head_deliverylist',
  47. date: that.data.date,
  48. searchKey: that.data.searchKey,
  49. token: token,
  50. page: that.data.page
  51. },
  52. dataType: 'json',
  53. success: function (res) {
  54. if (res.data.code == 0) {
  55. console.log(that.data.page);
  56. let rushList = that.data.list.concat(res.data.data);
  57. that.setData({
  58. list: rushList,
  59. hide_tip: true,
  60. no_list: 0
  61. });
  62. wx.hideLoading();
  63. } else {
  64. that.setData({
  65. isHideLoadMore: true
  66. })
  67. wx.hideLoading();
  68. return false;
  69. }
  70. }
  71. })
  72. },
  73. /**
  74. * 监控输入框
  75. */
  76. bindSearchChange: function (e) {
  77. this.setData({
  78. searchKey: e.detail.value
  79. });
  80. },
  81. /**
  82. * 搜索
  83. */
  84. searchByKey: function () {
  85. page = 1;
  86. this.setData({
  87. list: [],
  88. no_list: 0,
  89. page: 1
  90. });
  91. this.data.queryData.memberNickName = this.data.searchKey;
  92. this.getData();
  93. },
  94. /**
  95. * 取消
  96. */
  97. cancel: function () {
  98. page = 1;
  99. this.setData({
  100. searchKey: "",
  101. list: []
  102. });
  103. this.data.queryData.memberNickName = null;
  104. this.getData();
  105. },
  106. /**
  107. * 监控日期
  108. */
  109. bindDateChange: function (e) {
  110. page = 1;
  111. this.setData({
  112. date: e.detail.value,
  113. list: [],
  114. no_list: 0,
  115. page: 1
  116. });
  117. this.data.queryData.createTime = new Date(e.detail.value).getTime() - 28800000;
  118. this.getData();
  119. },
  120. /**
  121. * 清除日期
  122. */
  123. clearDate: function () {
  124. page = 1;
  125. this.setData({
  126. date: "",
  127. list: [],
  128. no_list: 0,
  129. page: 1
  130. });
  131. this.data.queryData.createTime = null;
  132. this.getData();
  133. },
  134. /**
  135. * 生命周期函数--监听页面初次渲染完成
  136. */
  137. onReady: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面显示
  141. */
  142. onShow: function () {
  143. },
  144. /**
  145. * 拨打电话
  146. */
  147. callTelphone: function (e) {
  148. var that = this;
  149. var phoneNumber = e.currentTarget.dataset.phone;
  150. if (phoneNumber != "未下单") {
  151. this.data.isCalling || (this.data.isCalling = true, wx.makePhoneCall({
  152. phoneNumber: phoneNumber,
  153. complete: function () {
  154. that.data.isCalling = false;
  155. }
  156. }));
  157. }
  158. },
  159. /**
  160. * 授权成功回调
  161. */
  162. authSuccess: function () {
  163. // todo
  164. },
  165. /**
  166. * 跳转详情
  167. */
  168. goDetails: function (e) {
  169. let state = e.currentTarget.dataset.state;
  170. let list_id = e.currentTarget.dataset.id;
  171. wx.navigateTo({
  172. url: '/lionfish_comshop/moduleA/groupCenter/listDetails?id=' + list_id + '&state=' + state,
  173. })
  174. },
  175. /**
  176. * 生命周期函数--监听页面隐藏
  177. */
  178. onHide: function () {
  179. },
  180. /**
  181. * 生命周期函数--监听页面卸载
  182. */
  183. onUnload: function () {
  184. },
  185. /**
  186. * 页面相关事件处理函数--监听用户下拉动作
  187. */
  188. onPullDownRefresh: function () {
  189. },
  190. /**
  191. * 页面上拉触底事件的处理函数
  192. */
  193. onReachBottom: function () {
  194. if (this.data.no_list == 1) return false;
  195. this.data.page += 1;
  196. this.getData();
  197. this.setData({
  198. isHideLoadMore: false
  199. })
  200. }
  201. })