index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. name:'',
  11. list:[
  12. ]
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function ( ) {
  18. app.checkLogin( ()=>{
  19. this.loadData()
  20. this.getuserInfo()
  21. } )
  22. },
  23. getuserInfo( cb ){
  24. app.getMakerInfo( (userInfo)=>{
  25. this.setData({userInfo})
  26. } )
  27. },
  28. bidTask: function( e ){
  29. let index = e.currentTarget.dataset.index;
  30. let item = this.data.list[index]
  31. util.http("/wx/applyWxB2B", {id:item.id}, (err, res) =>{
  32. if( err != 0) return;
  33. item.target_id = this.data.userInfo.ID
  34. this.setData({ list: this.data.list})
  35. util.showSuccess("抢单子成功");
  36. })
  37. },
  38. onReachBottom: function () {
  39. var that = this
  40. let newFrom = that.data.from
  41. if (newFrom == -1) {
  42. wx.stopPullDownRefresh();
  43. return;
  44. }
  45. this.getTaskList(newFrom, wx.stopPullDownRefresh);
  46. },
  47. goDetail(e){
  48. let id = e.currentTarget.dataset.id;
  49. wx.navigateTo({
  50. url: `/pages/task/info/b2bInfo?id=${id}`,
  51. })
  52. },
  53. search(e){
  54. let {name} = e.detail.value;
  55. this.setData({name})
  56. this.getTaskList( 0 )
  57. },
  58. getTaskList: function( newFrom, cb){
  59. let param = { from: newFrom, size:this.data.size,name: this.data.name}
  60. let list = this.data.list
  61. let that = this
  62. util.http("/wx/getSupplyCenter", param, function (err, res) {
  63. if( err != 0) return;
  64. if (newFrom == 0) list = [];
  65. let newlist = res.list.map( item =>{
  66. item.bid_end_at = item.bid_end_at.substr(0,10);
  67. return item
  68. });
  69. that.setData({
  70. from: res.from || -1,
  71. list: list.concat(newlist)
  72. })
  73. cb && cb()
  74. });
  75. },
  76. loadData :function( ){
  77. this.getTaskList(0)
  78. },
  79. })