voyageManage.js 3.8 KB

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