// pages/voyages/detail/detail.js import { postApi } from "../../../apis/api" Page({ data: { id: '', tab: 1, recordCurrentPage: 1, dischargeCurrentPage: 1, coordinates: [], medias: [], policys: [], voyage: [], waybills: [], infoType: 'ship', shipDischargeList: [], truckLoadList: [], polyline: {} }, changeTab(e) { let { tab } = e.currentTarget.dataset this.setData({ tab }) }, async getVoyageDetail() { let res = await postApi("/voyage/detail", { voyageId: this.data.id, }) let { coordinates, medias, policys, voyage, waybills } = res.data.result let points = [] for (let i of coordinates) { points.push({ latitude: i.latitude, longitude: i.longitude }) } let polyline = { points, color: "#ff454d" } this.setData({ coordinates, medias, policys, voyage, waybills, polyline }) }, async getCarLoadRecordList(isScroll) { if (isScroll) { this.data.recordCurrentPage += 1 } else { this.data.recordCurrentPage = 1 } let res = await postApi("/voyage/getCarLoadRecordList", { voyageId: this.data.id, size: 50, currentPage: this.data.recordCurrentPage }) if (0 == res.data.status) { if (isScroll) { let truckLoadList = [...this.data.truckLoadList, ...res.data.result] for (let i of truckLoadList) { i.weighTime = this.cutTimeString(i.weighTime) } this.setData({ truckLoadList }) } else { let truckLoadList = res.data.result for (let i of truckLoadList) { i.weighTime = this.cutTimeString(i.weighTime) } this.setData({ truckLoadList }) } } else { this.setData({ truckLoadList: [] }) } }, async getDischargeList(isScroll) { if (isScroll) { this.data.dischargeCurrentPage += 1 } else { this.data.dischargeCurrentPage = 1 } let res = await postApi("/voyage/getDischargeList", { voyageId: this.data.id, size: 50, currentPage: this.data.dischargeCurrentPage }) if (0 == res.data.status) { if (isScroll) { let shipDischargeList = [...this.data.shipDischargeList, ...res.data.result] for (let i of shipDischargeList) { i.dischargeTime = this.cutTimeString(i.dischargeTime) } this.setData({ shipDischargeList }) } else { let shipDischargeList = res.data.result for (let i of shipDischargeList) { i.dischargeTime = this.cutTimeString(i.dischargeTime) } this.setData({ shipDischargeList }) } } else { this.setData({ shipDischargeList: [] }) } }, previewImage(e) { let { src } = e.currentTarget.dataset wx.previewImage({ current: src, // 当前显示图片的http链接 urls: [src] // 需要预览的图片http链接列表 }) }, changeInfoType(e) { let { type } = e.currentTarget.dataset this.setData({ infoType: type }) }, cutTimeString(str) { let index = str.indexOf(' ') return index == -1 ? str : str.substring(0, index) }, changeBottomPage() { if (this.data.infoType == "ship") { this.getDischargeList(true) } else { this.getCarLoadRecordList(true) } }, onLoad(options) { this.setData({ id: options.id }) this.getVoyageDetail() this.getCarLoadRecordList() this.getDischargeList() }, })