orderList.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. let app = getApp();
  2. let host = app.globalData.servsers; // 请求的url
  3. Page({
  4. data: {
  5. host: host,
  6. isSelect: "", //默认全部
  7. dataStateArray: [{
  8. state: '',
  9. label: "全部",
  10. },
  11. {
  12. state: '1',
  13. label: "待付款",
  14. },
  15. {
  16. state: '3',
  17. label: "待发货",
  18. },
  19. {
  20. state: '4',
  21. label: "待收货",
  22. },
  23. {
  24. state: '5',
  25. label: "待评价",
  26. }
  27. ],
  28. goodsList: [],
  29. dividerState: false, //判断数据是否请求结束了,默认是false
  30. page: 1, //默认第一页
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function (options) {
  36. let that = this;
  37. if ('state' in options) {
  38. that.setData({
  39. isSelect: options.state
  40. })
  41. }
  42. that.getOrderList(that, that.data.isSelect)
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage: function () {
  78. },
  79. tab(e) { // tab切换
  80. this.setData({
  81. isSelect: e.currentTarget.dataset.state
  82. })
  83. this.getOrderList(this, e.currentTarget.dataset.state)
  84. },
  85. getOrderList(that, status) {
  86. wx.request({
  87. url: host + '/orderapi/orderlist',
  88. method: 'get',
  89. data: {
  90. user_id: app.globalData.user_id,
  91. status: status
  92. },
  93. success(res) {
  94. console.log(res, "orderItem")
  95. that.setData({
  96. goodsList: [...res.data]
  97. })
  98. }
  99. })
  100. }
  101. })