| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- // components/voyages/Voyages.js
- import {
- postApi
- } from "../../apis/api"
- Component({
- properties: {
- height: {
- type: Number,
- value: 620,
- }
- },
- data: {
- term: '',
- status: 1,
- currentPage: 1,
- size: 20,
- list: [],
- total: 0,
- bottomText: '点击或滑动加载更多...'
- },
- methods: {
- async getVoyageList() {
- let cargoOwnerId = wx.getStorageSync('cargoOwnerId')
- if (!cargoOwnerId) {
- this.setData({
- list: [{
- shipName: '体验船舶#1',
- loadPort: '南京',
- dischargeProt: "小池",
- cargo: '石油焦',
- tons: '10000',
- }, {
- shipName: '体验船舶#2',
- loadPort: '小池',
- dischargeProt: "武汉",
- cargo: '豆粕',
- tons: '15000',
- }, {
- shipName: '体验船舶#3',
- loadPort: '北仑港',
- dischargeProt: "小池",
- cargo: '煤炭',
- tons: '25000',
- }, {
- shipName: '体验船舶#4',
- loadPort: '张家港',
- dischargeProt: "汉口",
- cargo: '玉米',
- tons: '15000',
- }, {
- shipName: '体验船舶#5',
- loadPort: '武汉',
- dischargeProt: "小池",
- cargo: '大豆',
- tons: '3000',
- }],
- total: 1
- })
- return
- }
- let res = await postApi('/voyage/list', {
- cargoOwnerId: wx.getStorageSync('cargoOwnerId'),
- term: this.data.term,
- status: this.data.status,
- currentPage: this.data.currentPage,
- size: this.data.size
- })
- if (res.data.status == 0) {
- this.setData({
- list: res.data.result,
- total: res.data.total
- })
- } else {
- this.setData({
- list: [],
- total: 0,
- })
- }
- },
- changeStatus(e) {
- let {
- status
- } = e.currentTarget.dataset
- this.setData({
- status,
- currentPage: 1,
- size: 20,
- total: 0
- })
- this.getVoyageList()
- },
- goToDetail(e) {
- let cargoOwnerId = wx.getStorageSync('cargoOwnerId')
- if (!cargoOwnerId) {
- wx.showToast({
- icon: "none",
- title: '为了保证数据安全,请注册或登录',
- })
- return
- }
- let {
- id
- } = e.currentTarget.dataset
- wx.navigateTo({
- url: `/pages/voyages/detail/detail?id=${id}`,
- })
- },
- scrollList() {
- if (this.data.total == 0 || this.data.total < this.data.size * this.data.currentPage) return
- this.data.currentPage += 1
- this.getVoyageList()
- }
- }
- })
|