voyageManage.js 4.0 KB

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