| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- const {
- postApi
- } = require("../../apis/api")
- const app = getApp()
- Page({
- data: {
- cargoOwnerId: 0,
- defaultParams: {
- loginAccountId: wx.getStorageSync('loginAccountId')
- },
- maintab: 3,
- status: 1,
- currentPage: 1,
- size: 20,
- list: [],
- total: 0,
- isFreshing: false,
- apiArr: ['/voyage/list', '/dayReport/list', '/bill/list']
- },
- selectCargoOwner(e) {
- this.setData({
- cargoOwnerId: e.detail.value,
- list: [],
- currentPage: 1,
- })
- this.getList()
- },
- changeMainTab(e) {
- this.setData({
- maintab: e.currentTarget.dataset.maintab,
- currentApi: e.currentTarget.dataset.api,
- status: 1,
- list: [],
- currentPage: 1
- })
- this.getList()
- },
- async getList(isScroll) {
- this.setData({
- isFreshing: true
- })
- let res = await postApi(this.data.apiArr[this.data.maintab - 1], {
- loginAccountId: wx.getStorageSync('loginAccountId'),
- cargoOwnerId: this.data.cargoOwnerId,
- 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,
- })
- }
- },
- changeStatus(e) {
- let {
- status
- } = e.currentTarget.dataset
- this.setData({
- status,
- currentPage: 1,
- size: 20,
- total: 0
- })
- this.getList()
- },
- goToDetail(e) {
- let {
- id
- } = 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
- }
- 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: {
- let {
- index
- } = e.currentTarget.dataset
- app.globalData.currentBillItem = this.data.list[index]
- if (this.data.list[index].shipownerUploadFiles.length == 1) {
- url = `/pages/voyageManage/myBills/examine/examine?id=${id}`
- } else {
- url = `/pages/voyageManage/myBills/myBills?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
- })
- },
- onLoad() {},
- onShow() {
- this.getList()
- }
- })
|