repair.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // pages/index/repair/repair.js
  2. import HTTP from "../../../../requestFn/Api";
  3. const app = getApp();
  4. Page({
  5. data: {
  6. garden_id: null,
  7. order_list: [],
  8. status: {
  9. 1: "未派单",
  10. 2: "已派单",
  11. 3: "已完结"
  12. },
  13. page: 1,
  14. page_size: 10,
  15. hasMore: true,
  16. },
  17. onLoad() {
  18. const that = this;
  19. const {
  20. garden_id
  21. } = app.globalData;
  22. if (garden_id) {
  23. that.setData({
  24. garden_id
  25. });
  26. }
  27. },
  28. onShow(options) {
  29. this.init()
  30. },
  31. goAddRepair() {
  32. wx.navigateTo({
  33. url: './addrepair/addrepair',
  34. })
  35. },
  36. init() {
  37. this.setData({
  38. page: 1,
  39. hasMore: true
  40. })
  41. this.getOrder_list(true);
  42. },
  43. async getOrder_list(flag = false) {
  44. const that = this;
  45. let {
  46. page,
  47. page_size,
  48. order_list,
  49. garden_id
  50. } = that.data
  51. let res = await HTTP.Repair_order({
  52. garden_id,
  53. page,
  54. page_size
  55. })
  56. that.setData({
  57. order_list: flag ? res.list : [...order_list, ...res.list],
  58. page: ++page,
  59. hasMore: res.list.length === page_size
  60. })
  61. },
  62. onReachBottom() {
  63. if (!this.data.hasMore) {
  64. wx.showToast({
  65. title: '没有更多数据了',
  66. icon: 'none'
  67. })
  68. return console.log('没有更多数据了');
  69. }
  70. this.getOrder_list()
  71. },
  72. goDetail(e) {
  73. const {
  74. id
  75. } = e.currentTarget
  76. wx.navigateTo({
  77. url: `./detail/detail?id=${id}`,
  78. })
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh: function () {
  84. app.onRefresh();
  85. this.init(true);
  86. },
  87. })