需求列表状态刷新优化
This commit is contained in:
@@ -282,6 +282,8 @@ Page({
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
wx.hideLoading();
|
wx.hideLoading();
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
|
//先回详情页再回列表,列表页需要单独标记刷新
|
||||||
|
wx.$util.markDemandRefresh(this.data.demandId);
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Page({
|
|||||||
actualAccount: 0,
|
actualAccount: 0,
|
||||||
activeValues: [0, 1, 2, 3, 4],
|
activeValues: [0, 1, 2, 3, 4],
|
||||||
demandInfo: null,
|
demandInfo: null,
|
||||||
|
freshPage: false, // 返回本页时是否需要重新拉取详情(签约/发货/支付后置为 true)
|
||||||
copyUrl: '' // 剪贴板复制失败时,弹出可长按选择的链接
|
copyUrl: '' // 剪贴板复制失败时,弹出可长按选择的链接
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@ Page({
|
|||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
wx.setStorageSync('bidDemandId', this.data.id);
|
wx.$util.markDemandRefresh(this.data.id);
|
||||||
wx.requestSubscribeMessage({
|
wx.requestSubscribeMessage({
|
||||||
tmplIds: ['JGQJ3a-enop3Jfrcb7av4e5bX8p0Cah_5txloDHhBNw', 'fuSe71gltzwYTjNrc6N2bWg4cuO4qlhYjgo-09D3Gg8'],
|
tmplIds: ['JGQJ3a-enop3Jfrcb7av4e5bX8p0Cah_5txloDHhBNw', 'fuSe71gltzwYTjNrc6N2bWg4cuO4qlhYjgo-09D3Gg8'],
|
||||||
complete(re) {
|
complete(re) {
|
||||||
@@ -296,14 +297,13 @@ Page({
|
|||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
|
wx.$util.markDemandRefresh(this.data.id);
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
content: agree ? '确认接单成功,请通过联系方式与客户沟通开发细节' : '已拒绝成功',
|
content: agree ? '确认接单成功,请通过联系方式与客户沟通开发细节' : '已拒绝成功',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
//标记该需求需要刷新,返回列表时同步最新状态与按钮
|
|
||||||
wx.$util.markDemandRefresh(this.data.id);
|
|
||||||
if (agree) {
|
if (agree) {
|
||||||
//刷新当前页面,等沟通群二维码渲染完成后再回到顶部,方便直接看到
|
//刷新当前页面,等沟通群二维码渲染完成后再回到顶部,方便直接看到
|
||||||
this.loadDemandDetail(this.data.id).then(() => {
|
this.loadDemandDetail(this.data.id).then(() => {
|
||||||
@@ -369,6 +369,7 @@ Page({
|
|||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
|
wx.$util.markDemandRefresh(this.data.id);
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
@@ -430,6 +431,7 @@ Page({
|
|||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
|
wx.$util.markDemandRefresh(this.data.id);
|
||||||
wx.requestSubscribeMessage({
|
wx.requestSubscribeMessage({
|
||||||
// 验收结果 + 工单结算 + 订单发货提醒(客户支付尾款后提醒开发者发货)
|
// 验收结果 + 工单结算 + 订单发货提醒(客户支付尾款后提醒开发者发货)
|
||||||
tmplIds: ['0H4GVHXI9G8RtZ1FuS_BuWN8yzOiBQ0-47ym6f08X_I', 'Xpqqk4si-Jh6HqfD-1VS9IH2AtlgVgGJLzgVS7RRMFk', 'jGxNQ11on1yD0d5tGwk4S8jP_CEdddfAkrp9-xVeeZY'],
|
tmplIds: ['0H4GVHXI9G8RtZ1FuS_BuWN8yzOiBQ0-47ym6f08X_I', 'Xpqqk4si-Jh6HqfD-1VS9IH2AtlgVgGJLzgVS7RRMFk', 'jGxNQ11on1yD0d5tGwk4S8jP_CEdddfAkrp9-xVeeZY'],
|
||||||
@@ -491,6 +493,9 @@ Page({
|
|||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
|
wx.$util.markDemandRefresh(this.data.id);
|
||||||
|
//支付页成功后 redirectTo 结果页,返回本页时需重新拉取详情
|
||||||
|
this.setData({ freshPage: true });
|
||||||
wx.requestSubscribeMessage({
|
wx.requestSubscribeMessage({
|
||||||
// 合同付款提醒 + 确认收货通知(开发者发货后提醒客户确认收货)
|
// 合同付款提醒 + 确认收货通知(开发者发货后提醒客户确认收货)
|
||||||
tmplIds: ['RxZ1VlzI5cFl_q8fF-WfQlkUqMKp1HGhDCGzAYcmRtk', 'Utj3mlCNu0uiwshpoCeTPVMggXWYC6hVGqFBgGm9TFk'],
|
tmplIds: ['RxZ1VlzI5cFl_q8fF-WfQlkUqMKp1HGhDCGzAYcmRtk', 'Utj3mlCNu0uiwshpoCeTPVMggXWYC6hVGqFBgGm9TFk'],
|
||||||
@@ -545,6 +550,7 @@ Page({
|
|||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
|
wx.$util.markDemandRefresh(this.data.id);
|
||||||
wx.requestSubscribeMessage({
|
wx.requestSubscribeMessage({
|
||||||
tmplIds: ['Gl_t3R5a_NoAvmVaDLeERCfFmTLiHURv9eIixtnOKYI'],
|
tmplIds: ['Gl_t3R5a_NoAvmVaDLeERCfFmTLiHURv9eIixtnOKYI'],
|
||||||
complete: (re) => {
|
complete: (re) => {
|
||||||
@@ -605,6 +611,7 @@ Page({
|
|||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
|
wx.$util.markDemandRefresh(this.data.id);
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
|
|||||||
@@ -170,9 +170,10 @@ Page({
|
|||||||
opType
|
opType
|
||||||
});
|
});
|
||||||
const nextList = res.data.data || [];
|
const nextList = res.data.data || [];
|
||||||
//只替换数据,不动 page / hasMore,保持原有的分页进度
|
//不动 page,保持原有的分页进度;条目流转出当前标签后总数会变,需同步 hasMore
|
||||||
this.setData({
|
this.setData({
|
||||||
demandList: nextList,
|
demandList: nextList,
|
||||||
|
hasMore: res.data.current_page < res.data.last_page,
|
||||||
isEmpty: nextList.length === 0
|
isEmpty: nextList.length === 0
|
||||||
});
|
});
|
||||||
wx.nextTick(() => {
|
wx.nextTick(() => {
|
||||||
@@ -269,30 +270,13 @@ Page({
|
|||||||
this.setData({ fromPreview: false });
|
this.setData({ fromPreview: false });
|
||||||
return;
|
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 app = getApp();
|
||||||
const refreshDemandId = app && app.globalData ? app.globalData.refreshDemandId : 0;
|
const refreshDemandId = app && app.globalData ? app.globalData.refreshDemandId : 0;
|
||||||
if (refreshDemandId) {
|
if (refreshDemandId) {
|
||||||
//先清除标记,避免同一条被重复处理
|
//同时清掉 backAndRefresh 打的 freshPage,避免下次返回时又整页重载回到顶部
|
||||||
app.globalData.refreshDemandId = 0;
|
app.globalData.refreshDemandId = 0;
|
||||||
|
this.setData({ freshPage: false });
|
||||||
this.refreshListKeepPosition();
|
this.refreshListKeepPosition();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user