index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. bidTask: function( e ){
  22. let index = e.currentTarget.dataset.index;
  23. let item = this.data.list[index]
  24. util.http("/wx/applyWxTask", {id:item.id}, (err, res) =>{
  25. if( err != 0) return;
  26. item.is_bid = 1
  27. this.setData({ list: this.data.list})
  28. util.showMsg("抢单子成功");
  29. })
  30. },
  31. onReachBottom: function () {
  32. var that = this
  33. let newFrom = that.data.from
  34. if (newFrom == -1) {
  35. wx.stopPullDownRefresh();
  36. return;
  37. }
  38. this.getTaskList(newFrom, wx.stopPullDownRefresh);
  39. },
  40. getTaskList: function( newFrom, cb){
  41. let param = { from: newFrom, size:this.data.size }
  42. let list = this.data.list
  43. let that = this
  44. util.http("/wx/getSupplyCenter", param, function (err, res) {
  45. if( err != 0) return;
  46. if (newFrom == 0) list = [];
  47. let newlist = res.list.map( item =>{
  48. item.bid_end_at = item.bid_end_at.substr(0,10);
  49. return item
  50. });
  51. that.setData({
  52. from: res.from || -1,
  53. list: list.concat(newlist)
  54. })
  55. cb && cb()
  56. });
  57. },
  58. loadData :function( ){
  59. this.getTaskList(0)
  60. },
  61. })