const { postApi } = require("../../../../apis/api") // pages/voyageManage/myBills/myLab.js Page({ data: { currentPortId: -1, currentPage: 1, size: 20, isFreshing: false, total: 0, labList: [] }, async getVoyageDetail() { let res = await postApi('voyage/detail', { voyageId: this.data.voyageId }) let { voyage, } = res.data.result this.setData({ ...voyage, currentPortId: voyage?.voyageDetails[0].portId }) this.getLabList() }, changePort(e) { let currentPortId = e.target.dataset.id this.setData({ currentPortId, }) this.getLabList() }, scrollDownList() { this.setData({ total: 0, currentPage: 1, labList: [] }) this.getLabList() }, scrollList() { if (this.data.total == 0 || this.data.total <= this.data.size * this.data.currentPage) return this.data.currentPage += 1 this.getLabList(true) }, async getLabList(isScroll) { this.setData({ isFreshing: true }) let res = await postApi('voyage/getLabList', { voyageId: this.data.voyageId, portId: this.data.currentPortId, currentPage: this.data.currentPage, size: this.data.size }) this.setData({ currentPage: this.data.currentPage, isFreshing: false }) if (res.data.status == 0) { console.log(res.data.result) for (let i of res.data.result) { i.billingDate = i.billingDate.substring(0, 10) } if (isScroll) { this.setData({ labList: [...this.data.labList, ...res.data.result], total: res.data.total }) } else { this.setData({ labList: res.data.result, total: res.data.total }) } } else { this.setData({ labList: [], total: 0 }) wx.showToast({ icon: "none", title: res.data.msg, }) } }, onLoad(options) { let { id: voyageId } = options this.setData({ voyageId }) this.getVoyageDetail() }, })