const { postApi } = require("../../apis/api") import { datetimeFormat } from "../../utils/utils" const app = getApp() Page({ data: { cargoOwnerId: 0, defaultParams: { loginAccountId: wx.getStorageSync('loginAccountId') }, maintab: 1, status: 1, currentPage: 1, size: 20, list: [], total: 0, term: "", isFreshing: false, apiArr: ['/voyage/wx/list', '/dayReport/list', '/bill/list'] }, selectCargoOwner(e) { this.setData({ cargoOwnerId: e.detail.value, list: [], currentPage: 1, }) this.getList() }, changeMainTab(e) { let { maintab, api: currentApi } = e.currentTarget.dataset app.globalData.maintab = maintab this.setData({ maintab, currentApi, status: 1, list: [], currentPage: 1 }) this.getList() }, async getList(isScroll) { if (!wx.getStorageSync('loginAccountId')) { wx.showToast({ title: '尚未登录', icon: "error" }) return } this.setData({ isFreshing: true }) let url if (this.data.maintab == 3 && this.data.status == 2) { url = '/voyage/wx/lab/list' } else { url = this.data.apiArr[this.data.maintab - 1] } let res = await postApi(url, { loginAccountId: wx.getStorageSync('loginAccountId'), // cargoOwnerId: this.data.cargoOwnerId, term: this.data.term, 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, }) } }, async getLabList(isScroll) { if (!wx.getStorageSync('loginAccountId')) { wx.showToast({ title: '尚未登录', icon: "error" }) return } this.setData({ isFreshing: true }) let res = await postApi('/voyage/wx/lab/list', { loginAccountId: wx.getStorageSync('loginAccountId'), term: this.data.term, 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, islab } = e.currentTarget.dataset this.setData({ status, currentPage: 1, size: 20, total: 0 }) this.getList() return if (islab) { this.getLabList() } else { this.getList() } }, goToDetail(e) { let { id, trans } = e.currentTarget.dataset let url = '' switch (this.data.maintab) { case 1: { url = `/pages/voyages/detail/detail?id=${id}` break } case 2: { if (this.data.status == 2) { wx.showToast({ title: '请联系船东拍照', icon: "error" }) return } url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}` // let { // medias, // trans, // index // } = e.currentTarget.dataset // if (medias.length == 1) { // app.globalData.currentExamineMedia = medias[0] // url = `/pages/voyageManage/myDaily/examine/examine?id=${id}&trans=${trans}` // } else { // url = `/pages/voyageManage/myDaily/myDaily?id=${id}&trans=${trans}` // } break } case 3: { if (this.data.status == 1) { let { index } = e.currentTarget.dataset if (this.data.list[index].shipownerUploadFiles.length == 1) { this.data.list[index].shipownerUploadFiles[0].checked = true app.globalData.currentBillItem = this.data.list[index] url = `/pages/voyageManage/myBills/examine/examine?id=${id}` } else { app.globalData.currentBillItem = this.data.list[index] url = `/pages/voyageManage/myBills/myBills?id=${id}` } } else { url = `/pages/voyageManage/myBills/myLab/myLab?id=${id}` } break } } wx.navigateTo({ url }) }, 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 }) }, inputSearch(e) { this.setData({ currentPage: 1 }) this.getList() }, onLoad(option) { }, onShow(option) { this.setData({ maintab: app.globalData.maintab || 1, todayDate: datetimeFormat("年月月日日"), loginAccountId: wx.getStorageSync('loginAccountId') }) this.getList() } })