voyageManage.js 3.5 KB

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