// components/voyages/Voyages.js import { postApi } from "../../apis/api" Component({ properties: { height: { type: Number, value: 620, } }, data: { term: '', status: 1, currentPage: 1, size: 20, list: [], total: 0, bottomText: '点击或滑动加载更多...', cargoOwnerId:0 }, methods: { async getVoyageList() { let cargoOwnerId = wx.getStorageSync('cargoOwnerId') if (!cargoOwnerId) { this.setData({ list: [{ shipName: '体验船舶#1', loadPort: '南京', dischargeProt: "小池", cargo: '石油焦', tons: '10000', }, { shipName: '体验船舶#2', loadPort: '小池', dischargeProt: "武汉", cargo: '豆粕', tons: '15000', }, { shipName: '体验船舶#3', loadPort: '北仑港', dischargeProt: "小池", cargo: '煤炭', tons: '25000', }, { shipName: '体验船舶#4', loadPort: '张家港', dischargeProt: "汉口", cargo: '玉米', tons: '15000', }, { shipName: '体验船舶#5', loadPort: '武汉', dischargeProt: "小池", cargo: '大豆', tons: '3000', }], total: 1 }) return }else{ this.setData({ cargoOwnerId }) } let res = await postApi('/voyage/list', { cargoOwnerId: wx.getStorageSync('cargoOwnerId'), term: this.data.term, status: this.data.status, currentPage: this.data.currentPage, size: this.data.size }) if (res.data.status == 0) { this.setData({ list: res.data.result, total: res.data.total }) } else { this.setData({ list: [], total: 0, }) } }, changeStatus(e) { let { status } = e.currentTarget.dataset this.setData({ status, currentPage: 1, size: 20, total: 0 }) this.getVoyageList() }, goToDetail(e) { let cargoOwnerId = wx.getStorageSync('cargoOwnerId') if (!cargoOwnerId) { wx.showToast({ icon: "none", title: '为了保证数据安全,请注册或登录', }) return } let { id } = e.currentTarget.dataset wx.navigateTo({ url: `/pages/voyages/detail/detail?id=${id}`, }) }, scrollList() { if (this.data.total == 0 || this.data.total < this.data.size * this.data.currentPage) return this.data.currentPage += 1 this.getVoyageList() } } })