|
|
@ -1,11 +1,9 @@ |
|
|
// pages/process/order-list/index.js
|
|
|
// pages/process/order-list/index.js
|
|
|
import { getAgentOrderList } from "../../../api/payment" |
|
|
import { getAgentOrderList } from "../../../api/payment" |
|
|
const event = require('../../../utils/event') |
|
|
|
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
|
|
|
|
|
|
Page({ |
|
|
Page({ |
|
|
// * 页面的初始数据
|
|
|
|
|
|
data: { |
|
|
data: { |
|
|
height: app.globalData.fragmentHeight - 90, |
|
|
height: app.globalData.fragmentHeight - 90, |
|
|
tabIndex: 0, |
|
|
tabIndex: 0, |
|
|
@ -24,20 +22,13 @@ Page({ |
|
|
pageNum: 1, |
|
|
pageNum: 1, |
|
|
pageSize: 10 |
|
|
pageSize: 10 |
|
|
}, |
|
|
}, |
|
|
title: '全部', |
|
|
|
|
|
lastTime: null |
|
|
lastTime: null |
|
|
}, |
|
|
}, |
|
|
// * 生命周期函数--监听页面加载
|
|
|
// * 生命周期函数--监听页面加载
|
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
event.on('OrderMessage', this, this.onEvent) |
|
|
|
|
|
this.setData({ height: app.globalData.fragmentHeight - 90, title: this.data.title }) |
|
|
|
|
|
|
|
|
this.setData({ height: app.globalData.fragmentHeight - 90 }) |
|
|
this.fetchOrderList() |
|
|
this.fetchOrderList() |
|
|
}, |
|
|
}, |
|
|
onEvent: function(message){ |
|
|
|
|
|
if (message.what == 12) { |
|
|
|
|
|
this.onRefreshList() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
onTabChange: function ({detail}) { |
|
|
onTabChange: function ({detail}) { |
|
|
if (this.data.tabIndex == Number(detail.index)) { |
|
|
if (this.data.tabIndex == Number(detail.index)) { |
|
|
return |
|
|
return |
|
|
@ -64,66 +55,48 @@ Page({ |
|
|
} else { |
|
|
} else { |
|
|
this.setData({ requesting: true }) |
|
|
this.setData({ requesting: true }) |
|
|
} |
|
|
} |
|
|
|
|
|
console.log('getAgentOrderList======67') |
|
|
getAgentOrderList(this.data.form).then(result => { |
|
|
getAgentOrderList(this.data.form).then(result => { |
|
|
this.handResult(result) |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
|
|
util.showToast(err) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
handResult: function(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) |
|
|
|
|
|
|
|
|
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 |
|
|
} |
|
|
} |
|
|
respList[i].tipsTime = this.data.lastTime |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
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 { |
|
|
} 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 |
|
|
|
|
|
|
|
|
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
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 { |
|
|
} else { |
|
|
this.setData({ |
|
|
|
|
|
[nowList]: respList, |
|
|
|
|
|
['form.pageNum']: (num + 1), |
|
|
|
|
|
finished, |
|
|
|
|
|
requesting: false, |
|
|
|
|
|
loading: false |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.setData({ finished: true, 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) { |
|
|
lookItem: function (e) { |
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
wx.navigateTo({ url: `/pages/process/order-info/index?agent=1&id=${item.orderId}` }) |
|
|
wx.navigateTo({ url: `/pages/process/order-info/index?agent=1&id=${item.orderId}` }) |
|
|
}, |
|
|
|
|
|
onUnload: function(){ |
|
|
|
|
|
event.remove('OrderMessage', this) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
}) |