distributionList.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. var app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. currentTab: 0,
  8. pageSize: 10,
  9. navList: [{
  10. name: "全部",
  11. status: "0"
  12. }, {
  13. name: "待确认",
  14. status: "1"
  15. }, {
  16. name: "已确认",
  17. status: "2"
  18. },
  19. {
  20. name: "无效",
  21. status: "3"
  22. }
  23. ],
  24. distributionList: [],
  25. loadText: "没有更多记录了~",
  26. containerHeight: 0,
  27. chooseDate: "",
  28. chooseDateTime: "",
  29. data: "",
  30. estimate: "",
  31. permoney: 0,
  32. communnityId: "",
  33. loadText: "",
  34. disUserId: "",
  35. no_order: 0,
  36. page: 1,
  37. hide_tip: true,
  38. order: [],
  39. tip: '正在加载',
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad: function(options) {
  45. var sysInfo = wx.getSystemInfoSync();
  46. this.setData({
  47. containerHeight: sysInfo.windowHeight - Math.round(sysInfo.windowHeight / 375 * 55)
  48. });
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function() {
  54. var dayTime = new Date(),
  55. year = dayTime.getFullYear(),
  56. mon = dayTime.getMonth() + 1,
  57. dateTime = Date.parse(dayTime);
  58. this.setData({
  59. page: 1,
  60. order: [],
  61. chooseDate: year + "年" + mon + "月",
  62. chooseDateTime: dateTime
  63. }), this.getData();
  64. this.get_month_money();
  65. },
  66. get_month_money: function() {
  67. var chooseDate = this.data.chooseDate;
  68. var that = this;
  69. var token = wx.getStorageSync('token');
  70. app.util.request({
  71. 'url': 'entry/wxapp/index',
  72. 'data': {
  73. controller: 'order.order_commission',
  74. token: token,
  75. chooseDate: chooseDate
  76. },
  77. method: 'post',
  78. dataType: 'json',
  79. success: function(res) {
  80. if (res.data.code == 0) {
  81. that.setData({
  82. permoney: res.data.money
  83. })
  84. } else {
  85. that.setData({
  86. permoney: 0
  87. })
  88. }
  89. }
  90. })
  91. },
  92. /**
  93. * 获取数据
  94. */
  95. getData: function() {
  96. wx.showLoading({
  97. title: "加载中...",
  98. mask: true
  99. });
  100. this.setData({
  101. isHideLoadMore: true
  102. })
  103. this.data.no_order = 1
  104. let that = this;
  105. var chooseDate = this.data.chooseDate;
  106. var token = wx.getStorageSync('token');
  107. var currentTab = this.data.currentTab;
  108. var order_status = -1;
  109. if (currentTab == 0) {
  110. order_status = -1;
  111. } else if (currentTab == 1) {
  112. order_status = 22;
  113. } else if (currentTab == 2) {
  114. order_status = 6;
  115. } else if (currentTab == 3) {
  116. order_status = 357;
  117. }
  118. //currentTab
  119. app.util.request({
  120. 'url': 'entry/wxapp/index',
  121. 'data': {
  122. controller: 'order.orderlist',
  123. is_tuanz: 1,
  124. token: token,
  125. chooseDate: chooseDate,
  126. page: that.data.page,
  127. order_status: order_status
  128. },
  129. method: 'post',
  130. dataType: 'json',
  131. success: function(res) {
  132. if (res.data.code == 0) {
  133. console.log(that.data.page);
  134. let data = res.data.data;
  135. let rushList = that.data.order.concat(data);
  136. that.setData({
  137. order: rushList,
  138. hide_tip: true,
  139. 'no_order': 0
  140. });
  141. wx.hideLoading();
  142. } else {
  143. that.setData({
  144. isHideLoadMore: true
  145. })
  146. wx.hideLoading();
  147. return false;
  148. }
  149. }
  150. })
  151. },
  152. /**
  153. * 刷新
  154. */
  155. refresh: function() {
  156. this.setData({
  157. page: 1,
  158. order: [],
  159. }, ()=>{
  160. this.getData();
  161. });
  162. },
  163. /**
  164. * 生命周期函数--监听页面隐藏
  165. */
  166. onHide: function() {
  167. },
  168. bindChange: function(t) {
  169. this.setData({
  170. currentTab: 1 * t.detail.current
  171. });
  172. this.setData({
  173. order: [],
  174. page: 1,
  175. no_order: 0
  176. }, () => {
  177. console.log('我变啦');
  178. this.getData();
  179. })
  180. },
  181. /**
  182. * 切换导航
  183. */
  184. switchNav: function(e) {
  185. if (this.data.currentTab === 1 * e.target.dataset.current) return false;
  186. this.setData({
  187. currentTab: 1 * e.target.dataset.current
  188. });
  189. },
  190. /**
  191. * 生命周期函数--监听页面卸载
  192. */
  193. onUnload: function() {
  194. },
  195. /**
  196. * 页面相关事件处理函数--监听用户下拉动作
  197. */
  198. onPullDownRefresh: function() {
  199. this.getData();
  200. },
  201. /**
  202. * 监控日期改变
  203. */
  204. bindDateChange: function(t) {
  205. console.log("picker发送选择改变,携带值为", t.detail.value), this.setData({
  206. date: t.detail.value
  207. });
  208. var a = this.data.date.split("-"),
  209. e = Date.parse(this.data.date);
  210. this.setData({
  211. chooseDate: a[0] + "年" + a[1] + "月",
  212. chooseDateTime: e,
  213. order: [],
  214. page: 1,
  215. no_order: 0
  216. }), this.getData();
  217. this.get_month_money();
  218. },
  219. getCurrentList: function() {
  220. console.log(this.data.no_order);
  221. if (this.data.no_order == 1) return false;
  222. this.data.page += 1;
  223. this.getData();
  224. this.setData({
  225. isHideLoadMore: false
  226. })
  227. },
  228. /**
  229. * 页面上拉触底事件的处理函数
  230. */
  231. onReachBottom: function() {
  232. console.log(this.data.no_order);
  233. if (this.data.no_order == 1) return false;
  234. this.data.page += 1;
  235. this.getData();
  236. this.setData({
  237. isHideLoadMore: false
  238. })
  239. },
  240. handleTipDialog: function(){
  241. this.setData({
  242. showTipDialog: !this.data.showTipDialog
  243. })
  244. },
  245. /**
  246. * 用户点击右上角分享
  247. */
  248. onShareAppMessage: function() {
  249. }
  250. })