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.
129 lines
3.9 KiB
129 lines
3.9 KiB
// pages/client/order-list/index.js
|
|
import { getFactoryOrderList } from "../../../api/saas"
|
|
const util = require('../../../utils/util')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
height: app.globalData.fragmentHeight - 90,
|
|
tabIndex: 0,
|
|
tabList: [
|
|
{id: 0, name: '全部', badge: 0, status: '' },
|
|
{id: 1, name: '待定价', badge: 0, status: 1 },
|
|
{id: 2, name: '过磅审核', badge: 0, status: 2 },
|
|
{id: 3, name: '待付款', badge: 0, status: 3 },
|
|
{id: 4, name: '已付款', badge: 0, status: 4 }
|
|
],
|
|
loading: true,
|
|
requesting: false,
|
|
finished: false,
|
|
top: 0,
|
|
orderList: [],
|
|
form: {
|
|
funcType: 0,
|
|
pageNum: 1,
|
|
pageSize: 10
|
|
},
|
|
lastTime: null
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if(options.index){
|
|
this.setData({ tabIndex: Number(options.index), height: app.globalData.fragmentHeight - 90 })
|
|
} else {
|
|
this.setData({ height: app.globalData.fragmentHeight - 90 })
|
|
}
|
|
this.fetchOrderList()
|
|
},
|
|
onTabChange: function ({detail}) {
|
|
if (this.data.tabIndex == Number(detail.index)) {
|
|
return
|
|
}
|
|
this.setData({ tabIndex: detail.index})
|
|
this.data.form.status = this.data.tabList[detail.index].status
|
|
this.onRefreshList()
|
|
},
|
|
onRefreshList: function () {
|
|
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
|
|
}
|
|
if (this.data.loading) {
|
|
this.data.requesting = true
|
|
} else {
|
|
this.setData({ requesting: true })
|
|
}
|
|
getFactoryOrderList(this.data.form).then(result => {
|
|
if (result.data && result.data.records.length) {
|
|
var respList = result.data.records
|
|
// 对返回的消息列表进行处理,将同一天的消息显示在一起
|
|
for (let i = 0; i < respList.length; i++) {
|
|
if (util.isEmpty(this.data.lastTime)) {
|
|
this.data.lastTime = respList[i].createTime
|
|
if (this.data.lastTime.length > 10) {
|
|
this.data.lastTime = this.data.lastTime.substring(0, 10)
|
|
}
|
|
respList[i].tipsTime = this.data.lastTime
|
|
} else {
|
|
var itemTime = respList[i].createTime
|
|
if (itemTime.length > 10) {
|
|
itemTime = itemTime.substring(0, 10)
|
|
}
|
|
if (this.data.lastTime !== itemTime) {
|
|
respList[i].tipsTime = itemTime
|
|
}
|
|
this.data.lastTime = itemTime
|
|
}
|
|
}
|
|
let nowList = `orderList[${this.data.orderList.length}]`
|
|
var num = this.data.form.pageNum
|
|
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total
|
|
if(this.data.form.pageNum == 1){
|
|
this.setData({
|
|
[nowList]: respList,
|
|
['form.pageNum']: (num + 1),
|
|
top: 0,
|
|
finished,
|
|
requesting: false,
|
|
loading: false
|
|
})
|
|
} else {
|
|
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)
|
|
})
|
|
},
|
|
lookItem: function (e) {
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
|
|
if(item.status == 2 || item.status == 3 || item.status == 4 || item.status == 5){
|
|
wx.navigateTo({ url: '/pages/process/order-info/index?id=' + item.id })
|
|
}
|
|
}
|
|
|
|
})
|