data: {
orderProgress:1,
active:0,
pageNum:1,
pageSize:15,
hasMoreData: true,//有更多数据
orderList:[],
waitList:[], //待付款
serviceList:[], //服务中
finshList:[], //已完成
refundList:[] //退款/售后
},
// 点击上方得栏目,切换内容
onTabsClick(event){
console.log(event)
var that = this;
let title = event.detail.title;
switch(title){
case '待付款':
that.setData({
orderProgress:1,
pageNum:1
})
this.getOrderCard(that.data.orderProgress);
break;
case '服务中':
that.setData({
orderProgress:2,
pageNum: 1
})
this.getOrderCard(that.data.orderProgress);
break;
case '已完成':
that.setData({
orderProgress:3,
pageNum: 1
})
this.getOrderCard(that.data.orderProgress);
break;
case '退款/售后':
that.setData({
orderProgress:4,
pageNum: 1
})
this.getOrderCard(that.data.orderProgress)
}
},
//调用后端分页接口
getOrderCard(orderProgress){
var that=this;
var params={
orderStatus: orderProgress,
pageNum: that.data.pageNum,
pageSize:that.data.pageSize
}
app.requestLoading(app.globalData.ow + `/my/resume/orders`,
"GET", params, "加载中......",
function (res) {
console.log(res)
console.log("success res", res);
switch (orderProgress) {
case 1:
var newList = that.data.waitList;
break;
case 2:
var newList = that.data.serviceList;
break;
case 3:
var newList = that.data.finshList;
break;
case 4:
var newList = that.data.refundList;
break;
}
if (res.status == '200') {
if(that.data.pageNum==1){
newList=[]
}
let resList = res.data.list;
let totalPages = res.data.pages;
switch (orderProgress) {
case 1:
if (that.data.pageNum >= totalPages) {
that.setData({
waitList: newList.concat(resList),
hasMoreData: false
})
} else {
that.setData({
waitList: newList.concat(resList),
hasMoreData: true,
pageNum: that.data.pageNum + 1
})
}
break;
case 2:
if (that.data.pageNum >= totalPages) {
that.setData({
serviceList: newList.concat(resList),
hasMoreData: false
})
} else {
that.setData({
serviceList: newList.concat(resList),
hasMoreData: true,
pageNum: that.data.pageNum + 1
})
}
break;
case 3:
if (that.data.pageNum >= totalPages) {
that.setData({
finshList: newList.concat(resList),
hasMoreData: false
})
} else {
that.setData({
finshList: newList.concat(resList),
hasMoreData: true,
pageNum: that.data.pageNum + 1
})
}
break;
case 4:
if (that.data.pageNum >= totalPages) {
that.setData({
refundList: newList.concat(resList),
hasMoreData: false
})
} else {
that.setData({
refundList: newList.concat(resList),
hasMoreData: true,
pageNum: that.data.pageNum + 1
})
}
break;
}
}
},
function (res) {
console.log("res", res);
},
)
},
微信小程序-后台翻页
最新推荐文章于 2023-04-10 11:12:41 发布