voyageManage.js 3.8 KB

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