detailsList.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. loadText: "正在加载",
  8. LoadingComplete: true,
  9. currentTab: 1,
  10. no_order: 0,
  11. page: 1,
  12. hide_tip: true,
  13. order: [],
  14. tip: '正在加载',
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. var s_type = options.type;
  21. this.setData({
  22. currentTab: s_type
  23. })
  24. this.getData();
  25. },
  26. getData: function () {
  27. wx.showLoading({
  28. title: "加载中...",
  29. mask: true
  30. });
  31. this.setData({
  32. isHideLoadMore: true
  33. })
  34. this.data.no_order = 1
  35. let that = this;
  36. var chooseDate = this.data.chooseDate;
  37. var token = wx.getStorageSync('token');
  38. var currentTab = this.data.currentTab;
  39. var order_status = 1;
  40. if (currentTab == 1) {
  41. order_status = 1;
  42. } else if (currentTab == 2) {
  43. order_status = 2;
  44. }
  45. //currentTab
  46. app.util.request({
  47. 'url': 'entry/wxapp/index',
  48. 'data': {
  49. controller: 'community.headorderlist',
  50. token: token,
  51. page: that.data.page,
  52. order_status: order_status
  53. },
  54. method: 'post',
  55. dataType: 'json',
  56. success: function (res) {
  57. if (res.data.code == 0) {
  58. console.log(that.data.page);
  59. let rushList = that.data.order.concat(res.data.data);
  60. that.setData({
  61. order: rushList,
  62. hide_tip: true,
  63. 'no_order': 0
  64. });
  65. wx.hideLoading();
  66. } else {
  67. that.setData({
  68. isHideLoadMore: true
  69. })
  70. wx.hideLoading();
  71. return false;
  72. }
  73. }
  74. })
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. },
  86. /**
  87. * 导航切换
  88. */
  89. switchTab: function(e){
  90. let currentTab = e.currentTarget.dataset.type || 1;
  91. this.setData({
  92. currentTab: currentTab,
  93. page:1,
  94. order:[]
  95. })
  96. this.getData();
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload: function () {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh: function () {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom: function () {
  117. if (this.data.no_order == 1) return false;
  118. this.data.page += 1;
  119. this.getData();
  120. this.setData({
  121. isHideLoadMore: false
  122. })
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage: function () {
  128. }
  129. })