voyageManage.js 4.2 KB

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