const { postApi } = require("../../apis/api") Page({ data: { cargoOwnerId: 0, defaultParams: { loginAccountId: wx.getStorageSync('loginAccountId') }, maintab: 1, status: 1, currentPage: 1, size: 20, list: [], total: 0, isFreshing: false, currentApi: "/voyage/list" }, selectCargoOwner(e) { this.setData({ cargoOwnerId: e.detail.value, list: [], currentPage: 1, }) this.getList() }, changeMainTab(e) { this.setData({ maintab: e.currentTarget.dataset.maintab, currentApi: e.currentTarget.dataset.api, status: 1, list: [], currentPage: 1 }) this.getList() }, async getList(isScroll) { this.setData({ isFreshing: true }) let res = await postApi(this.data.currentApi, { loginAccountId: wx.getStorageSync('loginAccountId'), cargoOwnerId: this.data.cargoOwnerId, status: this.data.status, currentPage: this.data.currentPage, size: this.data.size, }) 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.getList() }, goToDetail(e) { let { id } = e.currentTarget.dataset let path = '' switch (this.data.maintab) { case 1: { path = "/voyages/detail/detail" break } case 2: { if (this.data.status == 2) { wx.showToast({ title: '请联系船东拍照', icon: "error" }) return } path = "/voyageManage/myDaily/myDaily" break } case 3: { path = "/voyageManage/myBills/myBills" break } } wx.navigateTo({ url: `/pages${path}?id=${id}`, }) }, scrollList() { if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return this.data.currentPage += 1 this.getList(true) }, scrollDownList() { this.setData({ total: 0, currentPage: 1, list: [] }) this.getList() }, call(e) { wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.phone }) }, onLoad() { } })