index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const app = getApp();
  2. const util = require("../../../util/util.js")
  3. Page({
  4. data: {
  5. StatusBar: app.globalData.StatusBar,
  6. CustomBar: app.globalData.CustomBar,
  7. loadModal:false,
  8. from:0,
  9. size:6,
  10. list:[
  11. ]
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function ( ) {
  17. app.checkLogin( ()=>{
  18. this.loadData()
  19. } )
  20. },
  21. onReachBottom: function () {
  22. var that = this
  23. let newFrom = that.data.from
  24. if (newFrom == -1) {
  25. wx.stopPullDownRefresh();
  26. return;
  27. }
  28. this.getTaskList(newFrom, wx.stopPullDownRefresh);
  29. },
  30. getTaskList: function( newFrom, cb){
  31. let param = { from: newFrom, size:this.data.size }
  32. let list = this.data.list
  33. let that = this
  34. util.http("/wx/getDemandCenter", param, function (err, res) {
  35. if( err != 0) return;
  36. if (newFrom == 0) list = [];
  37. let newlist = res.list.map( item =>{
  38. item.bid_end_at = item.bid_end_at.substr(0,10);
  39. return item
  40. });
  41. that.setData({
  42. from: res.from || -1,
  43. list: list.concat(newlist)
  44. })
  45. cb && cb()
  46. });
  47. },
  48. loadData :function( ){
  49. this.getTaskList(0)
  50. },
  51. })