| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- 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 res = await postApi(this.data.apiArr[this.data.maintab - 1], {
- 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
- })
- 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() {
- },
- onShow() {
- this.setData({
- maintab: app.globalData.maintab || 1,
- todayDate: datetimeFormat("年月月日日"),
- loginAccountId: wx.getStorageSync('loginAccountId')
- })
- this.getList()
- }
- })
|