voyageManage.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. const {
  2. postApi
  3. } = require("../../apis/api")
  4. const app = getApp()
  5. Page({
  6. data: {
  7. cargoOwnerId: 0,
  8. defaultParams: {
  9. loginAccountId: wx.getStorageSync('loginAccountId')
  10. },
  11. maintab: 2,
  12. status: 1,
  13. currentPage: 1,
  14. size: 20,
  15. list: [],
  16. total: 0,
  17. isFreshing: false,
  18. currentApi: "/dayReport/list"
  19. // currentApi: "/voyage/list"
  20. },
  21. selectCargoOwner(e) {
  22. this.setData({
  23. cargoOwnerId: e.detail.value,
  24. list: [],
  25. currentPage: 1,
  26. })
  27. this.getList()
  28. },
  29. changeMainTab(e) {
  30. this.setData({
  31. maintab: e.currentTarget.dataset.maintab,
  32. currentApi: e.currentTarget.dataset.api,
  33. status: 1,
  34. list: [],
  35. currentPage: 1
  36. })
  37. this.getList()
  38. },
  39. async getList(isScroll) {
  40. this.setData({
  41. isFreshing: true
  42. })
  43. let res = await postApi(this.data.currentApi, {
  44. loginAccountId: wx.getStorageSync('loginAccountId'),
  45. cargoOwnerId: this.data.cargoOwnerId,
  46. status: this.data.status,
  47. currentPage: this.data.currentPage,
  48. size: this.data.size,
  49. })
  50. this.setData({
  51. currentPage: this.data.currentPage,
  52. isFreshing: false
  53. })
  54. if (res.data.status == 0) {
  55. if (isScroll) {
  56. this.setData({
  57. list: [...this.data.list, ...res.data.result],
  58. total: res.data.total
  59. })
  60. } else {
  61. this.setData({
  62. list: res.data.result,
  63. total: res.data.total
  64. })
  65. }
  66. } else {
  67. this.setData({
  68. list: [],
  69. total: 0
  70. })
  71. wx.showToast({
  72. icon: "none",
  73. title: res.data.msg,
  74. })
  75. }
  76. },
  77. changeStatus(e) {
  78. let {
  79. status
  80. } = e.currentTarget.dataset
  81. this.setData({
  82. status,
  83. currentPage: 1,
  84. size: 20,
  85. total: 0
  86. })
  87. this.getList()
  88. },
  89. goToDetail(e) {
  90. let {
  91. id
  92. } = e.currentTarget.dataset
  93. let url = ''
  94. switch (this.data.maintab) {
  95. case 1: {
  96. url = `/pages/voyages/detail/detail?id=${id}`
  97. break
  98. }
  99. case 2: {
  100. if (this.data.status == 2) {
  101. wx.showToast({
  102. title: '请联系船东拍照',
  103. icon: "error"
  104. })
  105. return
  106. }
  107. let {
  108. medias,
  109. trans
  110. } = e.currentTarget.dataset
  111. if (medias.length == 1) {
  112. app.globalData.currentExamineMedia = medias[0]
  113. url = `/pages/voyageManage/myDaily/examine/examine?id=${id}&trans=${trans}`
  114. } else {
  115. url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  116. }
  117. break
  118. }
  119. case 3: {
  120. url = `/pages/voyageManage/myBills/myBills?id=${id}`
  121. break
  122. }
  123. }
  124. wx.navigateTo({
  125. url
  126. })
  127. },
  128. scrollList() {
  129. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  130. this.data.currentPage += 1
  131. this.getList(true)
  132. },
  133. scrollDownList() {
  134. this.setData({
  135. total: 0,
  136. currentPage: 1,
  137. list: []
  138. })
  139. this.getList()
  140. },
  141. call(e) {
  142. wx.makePhoneCall({
  143. phoneNumber: e.currentTarget.dataset.phone
  144. })
  145. },
  146. onLoad() {},
  147. onShow() {
  148. this.getList()
  149. }
  150. })