voyageManage.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. this.getList()
  36. },
  37. async getList(isScroll) {
  38. this.setData({
  39. isFreshing: true
  40. })
  41. let res = await postApi(this.data.currentApi, {
  42. loginAccountId: wx.getStorageSync('loginAccountId'),
  43. cargoOwnerId: this.data.cargoOwnerId,
  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. let path = ''
  92. switch (this.data.maintab) {
  93. case 1: {
  94. path = "/voyages/detail/detail"
  95. break
  96. }
  97. case 2: {
  98. if (this.data.status == 2) {
  99. wx.showToast({
  100. title: '请联系船东拍照',
  101. icon: "error"
  102. })
  103. return
  104. }
  105. path = "/voyageManage/myDaily/myDaily"
  106. break
  107. }
  108. case 3: {
  109. path = "/voyageManage/myBills/myBills"
  110. break
  111. }
  112. }
  113. wx.navigateTo({
  114. url: `/pages${path}?id=${id}`,
  115. })
  116. },
  117. scrollList() {
  118. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  119. this.data.currentPage += 1
  120. this.getList(true)
  121. },
  122. scrollDownList() {
  123. this.setData({
  124. total: 0,
  125. currentPage: 1,
  126. list: []
  127. })
  128. this.getList()
  129. },
  130. call(e) {
  131. wx.makePhoneCall({
  132. phoneNumber: e.currentTarget.dataset.phone
  133. })
  134. },
  135. onLoad() {
  136. }
  137. })