dailyVoyageList.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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: 2,
  15. status: 1,
  16. currentPage: 1,
  17. size: 20,
  18. list: [],
  19. total: 0,
  20. term: "",
  21. isFreshing: false,
  22. apiArr: ['/voyage/wx/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 url
  59. if (this.data.maintab == 3 && this.data.status == 2) {
  60. url = '/voyage/wx/lab/list'
  61. } else {
  62. url = this.data.apiArr[this.data.maintab - 1]
  63. }
  64. let res = await postApi(url, {
  65. loginAccountId: wx.getStorageSync('loginAccountId'),
  66. // cargoOwnerId: this.data.cargoOwnerId,
  67. term: this.data.term,
  68. status: this.data.status,
  69. currentPage: this.data.currentPage,
  70. size: this.data.size,
  71. })
  72. this.setData({
  73. currentPage: this.data.currentPage,
  74. isFreshing: false
  75. })
  76. if (res.data.status == 0) {
  77. if (isScroll) {
  78. this.setData({
  79. list: [...this.data.list, ...res.data.result],
  80. total: res.data.total
  81. })
  82. } else {
  83. this.setData({
  84. list: res.data.result,
  85. total: res.data.total
  86. })
  87. }
  88. } else {
  89. this.setData({
  90. list: [],
  91. total: 0
  92. })
  93. wx.showToast({
  94. icon: "none",
  95. title: res.data.msg,
  96. })
  97. }
  98. },
  99. async getLabList(isScroll) {
  100. if (!wx.getStorageSync('loginAccountId')) {
  101. wx.showToast({
  102. title: '尚未登录',
  103. icon: "error"
  104. })
  105. return
  106. }
  107. this.setData({
  108. isFreshing: true
  109. })
  110. let res = await postApi('/voyage/wx/lab/list', {
  111. loginAccountId: wx.getStorageSync('loginAccountId'),
  112. term: this.data.term,
  113. currentPage: this.data.currentPage,
  114. size: this.data.size,
  115. })
  116. this.setData({
  117. currentPage: this.data.currentPage,
  118. isFreshing: false
  119. })
  120. if (res.data.status == 0) {
  121. if (isScroll) {
  122. this.setData({
  123. list: [...this.data.list, ...res.data.result],
  124. total: res.data.total
  125. })
  126. } else {
  127. this.setData({
  128. list: res.data.result,
  129. total: res.data.total
  130. })
  131. }
  132. } else {
  133. this.setData({
  134. list: [],
  135. total: 0
  136. })
  137. wx.showToast({
  138. icon: "none",
  139. title: res.data.msg,
  140. })
  141. }
  142. },
  143. changeStatus(e) {
  144. let {
  145. status,
  146. islab
  147. } = e.currentTarget.dataset
  148. this.setData({
  149. status,
  150. currentPage: 1,
  151. size: 20,
  152. total: 0
  153. })
  154. this.getList()
  155. return
  156. if (islab) {
  157. this.getLabList()
  158. } else {
  159. this.getList()
  160. }
  161. },
  162. goToDetail(e) {
  163. let {
  164. id,
  165. trans
  166. } = e.currentTarget.dataset
  167. wx.setStorageSync('currentDailyId', id)
  168. let url = ''
  169. switch (this.data.maintab) {
  170. case 1: {
  171. url = `/pages/voyages/detail/detail?id=${id}`
  172. break
  173. }
  174. case 2: {
  175. if (this.data.status == 2) {
  176. wx.showToast({
  177. title: '请联系船东拍照',
  178. icon: "error"
  179. })
  180. return
  181. }
  182. url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  183. // let {
  184. // medias,
  185. // trans,
  186. // index
  187. // } = e.currentTarget.dataset
  188. // if (medias.length == 1) {
  189. // app.globalData.currentExamineMedia = medias[0]
  190. // url = `/pages/voyageManage/myDaily/examine/examine?id=${id}&trans=${trans}`
  191. // } else {
  192. // url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}`
  193. // }
  194. break
  195. }
  196. case 3: {
  197. if (this.data.status == 1) {
  198. let {
  199. index
  200. } = e.currentTarget.dataset
  201. if (this.data.list[index].shipownerUploadFiles.length == 1) {
  202. this.data.list[index].shipownerUploadFiles[0].checked = true
  203. app.globalData.currentBillItem = this.data.list[index]
  204. url = `/pages/voyageManage/myBills/examine/examine?id=${id}`
  205. } else {
  206. app.globalData.currentBillItem = this.data.list[index]
  207. url = `/pages/voyageManage/myBills/myBills?id=${id}`
  208. }
  209. } else {
  210. url = `/pages/voyageManage/myBills/myLab/myLab?id=${id}`
  211. }
  212. break
  213. }
  214. }
  215. wx.navigateTo({
  216. url
  217. })
  218. },
  219. scrollList() {
  220. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  221. this.data.currentPage += 1
  222. this.getList(true)
  223. },
  224. scrollDownList() {
  225. this.setData({
  226. total: 0,
  227. currentPage: 1,
  228. list: []
  229. })
  230. this.getList()
  231. },
  232. call(e) {
  233. wx.makePhoneCall({
  234. phoneNumber: e.currentTarget.dataset.phone
  235. })
  236. },
  237. inputSearch(e) {
  238. this.setData({
  239. currentPage: 1
  240. })
  241. this.getList()
  242. },
  243. onLoad(option) {
  244. wx.removeStorageSync('currentDailyId')
  245. },
  246. onShow(option) {
  247. this.setData({
  248. loginAccountId: wx.getStorageSync('loginAccountId'),
  249. currentDailyId: wx.getStorageSync('currentDailyId')
  250. })
  251. this.getList()
  252. }
  253. })