detail.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // pages/voyages/detail/detail.js
  2. import {
  3. postApi
  4. } from "../../../apis/api"
  5. Page({
  6. data: {
  7. id: '',
  8. tab: 1,
  9. recordCurrentPage: 1,
  10. dischargeCurrentPage: 1,
  11. coordinates: [],
  12. medias: [],
  13. policys: [],
  14. voyage: [],
  15. waybills: [],
  16. infoType: 'ship',
  17. shipDischargeList: [],
  18. truckLoadList: []
  19. },
  20. changeTab(e) {
  21. let {
  22. tab
  23. } = e.currentTarget.dataset
  24. this.setData({
  25. tab
  26. })
  27. },
  28. async getVoyageDetail() {
  29. let res = await postApi("/voyage/detail", {
  30. voyageId: this.data.id,
  31. })
  32. let {
  33. coordinates,
  34. medias,
  35. policys,
  36. voyage,
  37. waybills
  38. } = res.data.result
  39. this.setData({
  40. coordinates,
  41. medias,
  42. policys,
  43. voyage,
  44. waybills
  45. })
  46. },
  47. async getCarLoadRecordList(isScroll) {
  48. if (isScroll) {
  49. this.data.recordCurrentPage += 1
  50. } else {
  51. this.data.recordCurrentPage = 1
  52. }
  53. let res = await postApi("/voyage/getCarLoadRecordList", {
  54. voyageId: this.data.id,
  55. size: 10,
  56. currentPage: this.data.recordCurrentPage
  57. })
  58. if (0 == res.data.status) {
  59. if (isScroll) {
  60. let truckLoadList = [...this.data.truckLoadList, ...res.data.result]
  61. for (let i of truckLoadList) {
  62. i.weighTime = this.cutTimeString(i.weighTime)
  63. }
  64. this.setData({
  65. truckLoadList
  66. })
  67. } else {
  68. let truckLoadList = res.data.result
  69. for (let i of truckLoadList) {
  70. i.weighTime = this.cutTimeString(i.weighTime)
  71. }
  72. this.setData({
  73. truckLoadList
  74. })
  75. }
  76. } else {
  77. this.setData({
  78. truckLoadList: []
  79. })
  80. }
  81. },
  82. async getDischargeList(isScroll) {
  83. if (isScroll) {
  84. this.data.dischargeCurrentPage += 1
  85. } else {
  86. this.data.dischargeCurrentPage = 1
  87. }
  88. let res = await postApi("/voyage/getDischargeList", {
  89. voyageId: this.data.id,
  90. size: 10,
  91. currentPage: this.data.dischargeCurrentPage
  92. })
  93. if (0 == res.data.status) {
  94. if (isScroll) {
  95. let shipDischargeList = [...this.data.shipDischargeList, ...res.data.result]
  96. for (let i of shipDischargeList) {
  97. i.dischargeTime = this.cutTimeString(i.dischargeTime)
  98. }
  99. this.setData({
  100. shipDischargeList
  101. })
  102. } else {
  103. let shipDischargeList = res.data.result
  104. for (let i of shipDischargeList) {
  105. i.dischargeTime = this.cutTimeString(i.dischargeTime)
  106. }
  107. this.setData({
  108. shipDischargeList
  109. })
  110. }
  111. } else {
  112. this.setData({
  113. shipDischargeList: []
  114. })
  115. }
  116. },
  117. previewImage(e) {
  118. let {
  119. src
  120. } = e.currentTarget.dataset
  121. wx.previewImage({
  122. current: src, // 当前显示图片的http链接
  123. urls: [src] // 需要预览的图片http链接列表
  124. })
  125. },
  126. changeInfoType(e) {
  127. let {
  128. type
  129. } = e.currentTarget.dataset
  130. this.setData({
  131. infoType: type
  132. })
  133. },
  134. cutTimeString(str) {
  135. let index = str.indexOf(' ')
  136. return index == -1 ? str : str.substring(0, index)
  137. },
  138. test() {
  139. console.log('test')
  140. },
  141. onLoad(options) {
  142. this.setData({
  143. id: options.id
  144. })
  145. this.getVoyageDetail()
  146. this.getCarLoadRecordList()
  147. this.getDischargeList()
  148. },
  149. })