voyageManage.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const {
  2. postApi
  3. } = require("../../apis/api")
  4. Page({
  5. data: {
  6. cargoOwnerId: 0,
  7. defaultParams: {
  8. loginAccountId: wx.getStorageSync('loginAccountId')
  9. },
  10. maintab: 1,
  11. status: 1,
  12. currentPage: 1,
  13. size: 20,
  14. list: [],
  15. total: 0,
  16. isFreshing: false,
  17. currentApi: "/voyage/list"
  18. },
  19. selectCargoOwner(e) {
  20. this.setData({
  21. cargoOwnerId: e.detail.value,
  22. list: [],
  23. currentPage: 1,
  24. })
  25. this.getList()
  26. },
  27. changeMainTab(e) {
  28. this.setData({
  29. maintab: e.currentTarget.dataset.maintab,
  30. currentApi: e.currentTarget.dataset.api,
  31. status: 1,
  32. list: [],
  33. currentPage: 1
  34. })
  35. if (!this.data.cargoOwnerId) return
  36. this.getList()
  37. },
  38. async getList(isScroll) {
  39. this.setData({
  40. isFreshing: true
  41. })
  42. let res = await postApi(this.data.currentApi, {
  43. loginAccountId: wx.getStorageSync('loginAccountId'),
  44. status: this.data.status,
  45. currentPage: this.data.currentPage,
  46. size: this.data.size,
  47. })
  48. this.setData({
  49. currentPage: this.data.currentPage,
  50. isFreshing: false
  51. })
  52. if (res.data.status == 0) {
  53. if (isScroll) {
  54. this.setData({
  55. list: [...this.data.list, ...res.data.result],
  56. total: res.data.total
  57. })
  58. } else {
  59. this.setData({
  60. list: res.data.result,
  61. total: res.data.total
  62. })
  63. }
  64. } else {
  65. this.setData({
  66. list: [],
  67. total: 0
  68. })
  69. wx.showToast({
  70. icon: "none",
  71. title: res.data.msg,
  72. })
  73. }
  74. },
  75. changeStatus(e) {
  76. let {
  77. status
  78. } = e.currentTarget.dataset
  79. this.setData({
  80. status,
  81. currentPage: 1,
  82. size: 20,
  83. total: 0
  84. })
  85. this.getList()
  86. },
  87. goToDetail(e) {
  88. let {
  89. id
  90. } = e.currentTarget.dataset
  91. wx.navigateTo({
  92. url: `/pages/voyages/detail/detail?id=${id}`,
  93. })
  94. },
  95. scrollList() {
  96. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  97. this.data.currentPage += 1
  98. this.getList(true)
  99. },
  100. scrollDownList() {
  101. this.setData({
  102. total: 0,
  103. currentPage: 1,
  104. list: []
  105. })
  106. this.getList()
  107. },
  108. onLoad() {
  109. }
  110. })