| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- // 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()
- },
- })
|