index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. goDetail(e){
  31. let id = e.currentTarget.dataset.id;
  32. wx.navigateTo({
  33. url: `/pages/task/info/b2bInfo?id=${id}`,
  34. })
  35. },
  36. getTaskList: function( newFrom, cb){
  37. let param = { from: newFrom, size:this.data.size }
  38. let list = this.data.list
  39. let that = this
  40. util.http("/wx/getTradeCenter", param, function (err, res) {
  41. if( err != 0) return;
  42. if (newFrom == 0) list = [];
  43. let newlist = res.list.map( item =>{
  44. item.finish_at = item.finish_at.substr(0,19).replace("T", " ");
  45. return item
  46. });
  47. that.setData({
  48. from: res.from || -1,
  49. list: list.concat(newlist)
  50. })
  51. cb && cb()
  52. });
  53. },
  54. loadData :function( ){
  55. this.getTaskList(0)
  56. },
  57. })