listDetails.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. var app =getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. isIpx: app.globalData.isIpx,
  8. list: [],
  9. state: 0,
  10. loadText: "加载中...",
  11. noData: 0,
  12. loadMore: true
  13. },
  14. list_id: '',
  15. page: 1,
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. let list_id = options.id || '';
  21. let state = options.state || 0;
  22. if (list_id) {
  23. this.setData({ state });
  24. wx.showLoading();
  25. this.list_id = list_id;
  26. this.getData();
  27. } else {
  28. wx.redirectTo({
  29. url: '/lionfish_comshop/moduleA/groupCenter/list',
  30. })
  31. }
  32. },
  33. getData: function () {
  34. let that = this;
  35. let list_id = this.list_id;
  36. var token = wx.getStorageSync('token');
  37. app.util.request({
  38. url: 'entry/wxapp/index',
  39. data: {
  40. controller: 'community.get_head_deliverygoods',
  41. token,
  42. list_id,
  43. page: this.page
  44. },
  45. dataType: 'json',
  46. success: function (res) {
  47. wx.hideLoading();
  48. if (res.data.code == 0) {
  49. let h = {};
  50. let list = res.data.data;
  51. if (list.length < 20) h.noMore = true;
  52. let oldList = that.data.list;
  53. list = oldList.concat(list);
  54. that.page++;
  55. that.setData({
  56. list,
  57. ...h
  58. })
  59. } else {
  60. // 无数据
  61. if (that.page == 1) that.setData({
  62. noData: 1
  63. })
  64. that.setData({
  65. loadMore: false,
  66. noMore: false,
  67. loadText: "没有更多记录了~"
  68. })
  69. }
  70. },
  71. fail: (err)=> {
  72. console.log(err);
  73. wx.hideLoading();
  74. }
  75. })
  76. },
  77. signAll: function () {
  78. let that = this;
  79. let token = wx.getStorageSync('token');
  80. let list_id = this.list_id;
  81. app.util.request({
  82. 'url': 'entry/wxapp/index',
  83. 'data': {
  84. controller: 'community.sub_head_delivery',
  85. token: token,
  86. list_id: list_id
  87. },
  88. dataType: 'json',
  89. success: function (res) {
  90. wx.hideLoading();
  91. console.log(res);
  92. if (res.data.code == 0) {
  93. wx.showToast({
  94. title: '收货成功',
  95. icon: false
  96. })
  97. setTimeout(()=>{
  98. wx.redirectTo({
  99. url: '/lionfish_comshop/moduleA/groupCenter/list',
  100. })
  101. }, 2000);
  102. } else {
  103. wx.showToast({
  104. title: '签收失败,请重试!',
  105. icon: false
  106. })
  107. }
  108. },
  109. fail: (err) => {
  110. console.log(err);
  111. wx.hideLoading();
  112. }
  113. })
  114. },
  115. /**
  116. * 页面相关事件处理函数--监听用户下拉动作
  117. */
  118. onPullDownRefresh: function () {
  119. },
  120. /**
  121. * 页面上拉触底事件的处理函数
  122. */
  123. onReachBottom: function () {
  124. if (!this.data.loadMore) return false;
  125. this.getData();
  126. }
  127. })