voyageList.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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: 0,
  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 res = await postApi('/port/report/list', {
  59. loginAccountId: wx.getStorageSync('loginAccountId'),
  60. // cargoOwnerId: this.data.cargoOwnerId,
  61. term: this.data.term,
  62. type: 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. wx.navigateTo({
  110. url: `/pages/index/declarePort/detail?id=${id}`
  111. })
  112. },
  113. scrollList() {
  114. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  115. this.data.currentPage += 1
  116. this.getList(true)
  117. },
  118. scrollDownList() {
  119. this.setData({
  120. total: 0,
  121. currentPage: 1,
  122. list: []
  123. })
  124. this.getList()
  125. },
  126. call(e) {
  127. wx.makePhoneCall({
  128. phoneNumber: e.currentTarget.dataset.phone
  129. })
  130. },
  131. inputSearch(e) {
  132. this.setData({
  133. currentPage: 1
  134. })
  135. this.getList()
  136. },
  137. onLoad() {
  138. },
  139. onShow() {
  140. this.setData({
  141. maintab: app.globalData.maintab || 1,
  142. todayDate: datetimeFormat("年月月日日"),
  143. loginAccountId: wx.getStorageSync('loginAccountId')
  144. })
  145. this.getList()
  146. }
  147. })