// components/voyages/Voyages.js import { postApi } from "../../apis/api" Component({ properties: { height: { type: Number, value: 620, }, type: { type: String, value: '' } }, data: { term: '', status: 1, currentPage: 1, size: 20, list: [], total: 0, loginAccountId: 0, isFreshing: false }, methods: { async getVoyageList(isScroll) { let loginAccountId = wx.getStorageSync('loginAccountId') if (!loginAccountId) { this.setData({ list: [{ shipName: '体验船舶#1', loadPort: '南京', dischargePorts: "小池", cargo: '石油焦', tons: '10000', }, { shipName: '体验船舶#2', loadPort: '小池', dischargePorts: "武汉", cargo: '豆粕', tons: '15000', }, { shipName: '体验船舶#3', loadPort: '北仑港', dischargePorts: "小池", cargo: '煤炭', tons: '25000', }, { shipName: '体验船舶#4', loadPort: '张家港', dischargePorts: "汉口", cargo: '玉米', tons: '15000', }, { shipName: '体验船舶#5', loadPort: '武汉', dischargePorts: "小池", cargo: '大豆', tons: '3000', }], total: 1 }) return } else { this.setData({ loginAccountId, list: [] }) } this.setData({ isFreshing: true }) let res = await postApi('/voyage/wx/list', { loginAccountId: wx.getStorageSync('loginAccountId'), term: this.data.term, status: this.data.status, currentPage: this.data.currentPage, size: this.data.size, isClient: wx.getStorageSync('isClient'), }) this.setData({ currentPage: this.data.currentPage, isFreshing: false }) if (res.data.status == 0) { if (isScroll) { this.setData({ list: [...this.data.list, ...res.data.result], total: res.data.total }) } else { this.setData({ list: res.data.result, total: res.data.total }) } } else { this.setData({ list: [], total: 0 }) wx.showToast({ icon: "none", title: res.data.msg, }) } }, changeStatus(e) { let { status } = e.currentTarget.dataset this.setData({ status, currentPage: 1, size: 20, total: 0 }) this.getVoyageList() }, goToDetail(e) { let loginAccountId = wx.getStorageSync('loginAccountId') if (!loginAccountId) { wx.showToast({ icon: "none", title: '为了保证数据安全,请注册或登录', }) return } let rolePermission = wx.getStorageSync('rolePermission') if (rolePermission.indexOf('VOYAGEDETAIL') == -1) { 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(true) }, scrollDownList() { this.setData({ total: 0, currentPage: 1, list: [] }) this.getVoyageList() }, clearList() { this.setData({ currentPage: 1, list: [], total: 0 }) } } })