weatherList.js 2.4 KB

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