weatherList.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. discPortId: '',
  24. discPort: ''
  25. },
  26. selectDiscPort(e) {
  27. this.data.discPortId = e.detail.value
  28. this.data.discPort = e.detail.label
  29. this.getList()
  30. },
  31. async getList(isScroll) {
  32. if (!wx.getStorageSync('loginAccountId')) {
  33. wx.showToast({
  34. title: '尚未登录',
  35. icon: "error"
  36. })
  37. return
  38. }
  39. this.setData({
  40. isFreshing: true
  41. })
  42. let res = await postApi('/port/weather/list', {
  43. loginAccountId: wx.getStorageSync('loginAccountId'),
  44. portId: this.data.discPortId,
  45. currentPage: this.data.currentPage,
  46. size: this.data.size,
  47. })
  48. this.setData({
  49. currentPage: this.data.currentPage,
  50. isFreshing: false
  51. })
  52. if (res.data.status == 0) {
  53. if (isScroll) {
  54. this.setData({
  55. list: [...this.data.list, ...res.data.result],
  56. total: res.data.total
  57. })
  58. } else {
  59. this.setData({
  60. list: res.data.result,
  61. total: res.data.total
  62. })
  63. }
  64. } else {
  65. this.setData({
  66. list: [],
  67. total: 0
  68. })
  69. wx.showToast({
  70. icon: "none",
  71. title: res.data.msg,
  72. })
  73. }
  74. },
  75. goToDetail(e) {
  76. return
  77. let {
  78. id,
  79. } = e.currentTarget.dataset
  80. wx.navigateTo({
  81. url: `/pages/index/declarePort/detail?id=${id}`
  82. })
  83. },
  84. scrollList() {
  85. if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return
  86. this.data.currentPage += 1
  87. this.getList(true)
  88. },
  89. scrollDownList() {
  90. this.setData({
  91. total: 0,
  92. currentPage: 1,
  93. list: []
  94. })
  95. this.getList()
  96. },
  97. onLoad() {
  98. this.getList()
  99. },
  100. onShow() {}
  101. })