纸通宝小程序
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.
 

127 lines
3.8 KiB

// pages/bidding/index/index.js
import { getProxyOrderList } from "../../../api/ztb"
const util = require('../../../utils/util')
const event = require('../../../utils/event.js')
const tdsdk = require('../../../libs/tdweapp')
const app = getApp()
const status = ['', 50, 51, 53, 54, 55]
Page({
data: {
height: app.globalData.fragmentHeight,
loading: true,
requesting: false,
finished: false,
tabList: ['全部', '待预约', '待送货', '结算中', '已完成', '已关闭'],
tabIndex: 0,
top: 0,
orderList: [],
form: {
status: '',
pageNum: 1,
pageSize: 15
},
isOnece:''
},
onLoad: function (options) {
this.setData({
height: app.globalData.fragmentHeight - 90,
CustomBar: app.globalData.CustomBar,
// ['form.status']: options.status ? statusList[parseInt(options.status)] : '',
['form.status']: options.status ? options.status : '',
// tabIndex: options.status ? parseInt(options.status) : 0
tabIndex: options.tabIndex ? parseInt(options.tabIndex) : 0
})
event.on('ProxyMessage', this, this.onEvent)
this.fetchOrderList()
},
onEvent: function (message) {
if (message.what == 400) {
this.onRefreshList()
}
},
onRefreshList: function () {
if (this.data.requesting) {
return
}
this.setData({ orderList: [], ['form.status']: this.data.form.status, ['form.pageNum']: 1, loading: true, finished: false })
this.fetchOrderList()
},
fetchOrderList: function () {
if (this.data.requesting || this.data.finished) {
return
}
if (this.data.loading) {
this.data.requesting = true
} else {
this.setData({ requesting: true })
}
getProxyOrderList(this.data.form).then(result => {
if (result.data.records.length) {
var respList = result.data.records
let nowList = `orderList[${this.data.orderList.length}]`
var num = this.data.form.pageNum
var finished = this.data.form.pageNum >= result.data.pages
if (this.data.form.pageNum == 1) {
respList.forEach(element => {
if (element.createTime.substring(0, 10) === this.data.isOnece) {
element.isShowDateQd = false
} else {
element.isShowDateQd = true
this.data.isOnece = element.createTime.substring(0, 10)
}
});
this.setData({
[nowList]: respList,
total: result.data.total,
['form.pageNum']: (num + 1),
top: 0,
finished,
requesting: false,
loading: false
})
} else {
respList.forEach(element => {
if (element.createTime.substring(0, 10) === this.data.isOnece && this.data.isOnece!=='') {
element.isShowDateQd = false
} else {
element.isShowDateQd = true
this.data.isOnece = element.createTime.substring(0, 10)
}
});
this.setData({
[nowList]: respList,
total: result.data.total,
['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)
})
},
onTabChange: function ({ detail }) {
if (this.data.tabIndex == detail.index) {
return
}
this.data.tabIndex = detail.index
this.data.form.status = status[this.data.tabIndex]
this.onRefreshList()
},
onShow: function () {
tdsdk.Page.onShow()
},
onHide: function(){
tdsdk.Page.onHide()
},
onUnload: function () {
tdsdk.Page.onUnload()
event.remove('ProxyMessage', this)
}
})