You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.2 KiB
100 lines
3.2 KiB
// pages/process/order-list/index.js
|
|
import Scene from '../../index/scene'
|
|
import { getProxyOrderList } from "../../../api/ztb"
|
|
const event = require('../../../utils/event')
|
|
const util = require('../../../utils/util')
|
|
const app = getApp()
|
|
|
|
Scene({
|
|
// * 页面的初始数据
|
|
data: {
|
|
height: app.globalData.fragmentHeight - 90,
|
|
tabIndex: 0,
|
|
tabList: [
|
|
{id: 0, name: '全部', badge: 0, status: '' },
|
|
{id: 1, name: '待预约', badge: 0, status: 50 },
|
|
{id: 2, name: '待送货', badge: 0, status: 51 },
|
|
{id: 3, name: '结算中', badge: 0, status: 53 },
|
|
{id: 4, name: '已完成', badge: 0, status: 54 },
|
|
{id: 5, name: '已关闭', badge: 0, status: 55 }
|
|
// {id: 8, name: '已取消', badge: 0, status: 6 }
|
|
],
|
|
loading: true,
|
|
requesting: false,
|
|
finished: false,
|
|
top: 0,
|
|
orderList: [],
|
|
form: {
|
|
pageNum: 1,
|
|
pageSize: 10
|
|
},
|
|
title: '全部',
|
|
lastTime: null
|
|
},
|
|
// * 生命周期函数--监听页面加载
|
|
onLoad: function (options) {
|
|
if(!util.isEmpty(options.status) || Number(options.status) == 0){
|
|
this.data.form.status = Number(options.status)
|
|
for (let index = 0; index < this.data.tabList.length; index++) {
|
|
if(this.data.tabList[index].status === Number(options.status)){
|
|
this.data.tabIndex = index
|
|
break
|
|
}
|
|
}
|
|
this.setData({ height: app.globalData.fragmentHeight - 90, tabIndex: this.data.tabIndex })
|
|
} else {
|
|
this.setData({ height: app.globalData.fragmentHeight - 90 })
|
|
}
|
|
event.on('OrderMessage', this, this.onEvent)
|
|
this.fetchOrderList()
|
|
},
|
|
onEvent: function(message){
|
|
if (message.what == 21) {
|
|
this.onRefreshList()
|
|
}
|
|
},
|
|
onTabChange: function ({detail}) {
|
|
if (this.data.tabIndex == Number(detail.index)) {
|
|
return
|
|
}
|
|
this.setData({ tabIndex: detail.index, requesting: false })
|
|
this.data.form.status = this.data.tabList[detail.index].status
|
|
this.onRefreshList()
|
|
},
|
|
onRefreshList: function () {
|
|
if (this.data.requesting) {
|
|
return
|
|
}
|
|
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false })
|
|
this.data.lastTime = null
|
|
this.fetchOrderList()
|
|
},
|
|
//1:待定价,2:待过皮重,3:待过磅审核,4:待付款,5:已完成
|
|
fetchOrderList: function () {
|
|
if (this.data.requesting || this.data.finished) {
|
|
return
|
|
}
|
|
this.data.requesting = true
|
|
getProxyOrderList(this.data.form).then(result => {
|
|
var respList = result.data.records
|
|
if (respList && respList.length) {
|
|
let nowList = `orderList[${this.data.orderList.length}]`
|
|
var num = this.data.form.pageNum
|
|
var finished = this.data.form.pageNum >= result.data.pages
|
|
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false })
|
|
} else {
|
|
this.setData({ finished: true, requesting: false, loading: false })
|
|
}
|
|
}).catch(err => {
|
|
this.setData({ requesting: false, loading: false })
|
|
util.showToast(err)
|
|
}).then(() => {
|
|
this.refresh = this.refresh || this.selectComponent('#refresh')
|
|
this.refresh.setRefresh(false)
|
|
})
|
|
},
|
|
onUnload: function(){
|
|
event.remove('OrderMessage', this)
|
|
}
|
|
|
|
})
|