需求列表状态刷新优化
This commit is contained in:
@@ -170,9 +170,10 @@ Page({
|
||||
opType
|
||||
});
|
||||
const nextList = res.data.data || [];
|
||||
//只替换数据,不动 page / hasMore,保持原有的分页进度
|
||||
//不动 page,保持原有的分页进度;条目流转出当前标签后总数会变,需同步 hasMore
|
||||
this.setData({
|
||||
demandList: nextList,
|
||||
hasMore: res.data.current_page < res.data.last_page,
|
||||
isEmpty: nextList.length === 0
|
||||
});
|
||||
wx.nextTick(() => {
|
||||
@@ -269,30 +270,13 @@ Page({
|
||||
this.setData({ fromPreview: false });
|
||||
return;
|
||||
}
|
||||
const bidDemandId = wx.getStorageSync('bidDemandId');
|
||||
if (bidDemandId) {
|
||||
// 先清除标记,避免同一条被重复处理
|
||||
wx.removeStorageSync('bidDemandId');
|
||||
const index = this.data.demandList.findIndex(item => item.id === Number(bidDemandId));
|
||||
if (index < 0) {
|
||||
// 当前列表里没有这条(例如「我投标的需求」页),交给接口重新拉取
|
||||
this.loadDemandList(true);
|
||||
} else {
|
||||
this.setData({
|
||||
[`demandList[${index}].is_bid`]: true,
|
||||
// 按钮渲染的是 item.button.name,只改 btnName 不会刷新文案
|
||||
[`demandList[${index}].button`]: { name: '已投标', theme: 'light' },
|
||||
[`demandList[${index}].demand_biddings_count`]: this.data.demandList[index].demand_biddings_count + 1,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
//详情页/签约页操作完成后会写入该标记,回到列表时刷新对应条目的状态与按钮
|
||||
//详情页/签约页/发货页操作成功后会写入该标记,回到列表时以接口数据刷新状态与按钮
|
||||
const app = getApp();
|
||||
const refreshDemandId = app && app.globalData ? app.globalData.refreshDemandId : 0;
|
||||
if (refreshDemandId) {
|
||||
//先清除标记,避免同一条被重复处理
|
||||
//同时清掉 backAndRefresh 打的 freshPage,避免下次返回时又整页重载回到顶部
|
||||
app.globalData.refreshDemandId = 0;
|
||||
this.setData({ freshPage: false });
|
||||
this.refreshListKeepPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user