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.
123 lines
4.1 KiB
123 lines
4.1 KiB
// pages/process/order-list/index.js
|
|
import Scene from '../../index/scene'
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { getFactoryOrderList } from "../../../api/saas"
|
|
const util = require('../../../utils/util')
|
|
const app = getApp()
|
|
|
|
Scene({
|
|
// * 页面的初始数据
|
|
data: {
|
|
height: app.globalData.fragmentHeight,
|
|
loading: true,
|
|
requesting: false,
|
|
finished: false,
|
|
top: 0,
|
|
orderList: [],
|
|
form: {
|
|
status: 4,
|
|
funcType: 0,
|
|
isSameCustomer: 0,
|
|
pageNum: 1,
|
|
pageSize: 15
|
|
},
|
|
lastTime: null
|
|
},
|
|
// * 生命周期函数--监听页面加载
|
|
onLoad: function (options) {
|
|
this.setData({ height: app.globalData.fragmentHeight, admin: app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0 })
|
|
this.fetchOrderList()
|
|
},
|
|
checkSame: function(){
|
|
this.onRefreshList(this.data.form.isSameCustomer ? 0 : 1)
|
|
},
|
|
onRefreshList: function (isame) {
|
|
if (this.data.requesting) {
|
|
return
|
|
}
|
|
this.setData({ orderList: [], ['form.pageNum']: 1, ['form.isSameCustomer']: isame == 1 ? 1 : 0, 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
|
|
getFactoryOrderList(this.data.form).then(result => {
|
|
if (result.data && result.data.records && 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)
|
|
}
|
|
if(this.data.form.pageNum == 1 && i == 0){
|
|
respList[i].vcheck = true
|
|
}
|
|
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
|
|
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)
|
|
})
|
|
},
|
|
cancelOrder: function(e){
|
|
Dialog.confirm({ title: '温馨提示', message: '确定取消该订单?' }).then(() => {
|
|
wx.showLoading({ title: '正在获取', mask: true })
|
|
cancelOrder(e.currentTarget.dataset.id).then(result => {
|
|
wx.hideLoading()
|
|
util.showToast('订单已经消该')
|
|
this.onRefreshList()
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
})
|
|
},
|
|
lookItem: function (e) {
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
|
|
if(!this.data.admin) {
|
|
wx.navigateTo({ url: `/pages/process/order-info/index?id=${item.id}` })
|
|
return
|
|
}
|
|
const that = this
|
|
wx.navigateTo({
|
|
url: `/pages/process/payment/index?channel=1`,
|
|
events: {
|
|
onOrderChange: (data) => {
|
|
if (data.what == 12) {
|
|
that.onRefreshList(that.data.form.isSameCustomer)
|
|
}
|
|
}
|
|
},
|
|
success: function(res) {
|
|
res.eventChannel.emit('onParam', item)
|
|
}
|
|
})
|
|
}
|
|
|
|
})
|