分配客户群二维码
This commit is contained in:
@@ -17,6 +17,7 @@ Page({
|
||||
freshPage: false,
|
||||
fromPreview: false, // 预览锁
|
||||
hasMore: true, // 新增字段,标记是否还有更多数据
|
||||
refreshing: false, // 刷新按钮是否处于加载中
|
||||
tabList: [
|
||||
{ text: '全部', key: -1 },
|
||||
{ text: '招标中', key: 1 },
|
||||
@@ -59,6 +60,13 @@ Page({
|
||||
}
|
||||
this.loadDemandList(true);
|
||||
},
|
||||
// 点击右侧刷新按钮
|
||||
async onRefreshTap() {
|
||||
if (this.data.refreshing) return;
|
||||
this.setData({ refreshing: true });
|
||||
await this.loadDemandList(true);
|
||||
this.setData({ refreshing: false });
|
||||
},
|
||||
//图片预览
|
||||
onImageView(e) {
|
||||
const { images, index } = e.currentTarget.dataset;
|
||||
@@ -77,7 +85,8 @@ Page({
|
||||
},
|
||||
|
||||
// 加载需求列表数据
|
||||
async loadDemandList(fresh = false) {
|
||||
async loadDemandList(fresh = false, options = {}) {
|
||||
const { silent = false } = options;
|
||||
if (fresh) {
|
||||
this.setData({
|
||||
page: 1,
|
||||
@@ -95,14 +104,19 @@ Page({
|
||||
try {
|
||||
const { page, status, keywords, opType } = this.data;
|
||||
let params = { page, status, keywords, opType };
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
});
|
||||
// 下拉刷新自带 loading 指示,不再叠加 showLoading
|
||||
if (!silent) {
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
});
|
||||
}
|
||||
const res = await fetchDemandList(params);
|
||||
const nextList = res.data.data;
|
||||
console.log(res)
|
||||
console.log(nextList)
|
||||
wx.hideLoading();
|
||||
if (!silent) {
|
||||
wx.hideLoading();
|
||||
}
|
||||
|
||||
// 判断是否还有更多数据
|
||||
const { current_page, last_page } = res.data;
|
||||
@@ -218,22 +232,26 @@ Page({
|
||||
return;
|
||||
}
|
||||
const bidDemandId = wx.getStorageSync('bidDemandId');
|
||||
console.log('bidDemandId:', bidDemandId);
|
||||
if (bidDemandId) {
|
||||
const index = this.data.demandList.findIndex(item => item.id === Number(bidDemandId));
|
||||
console.log('bidDemandId-index:', index);
|
||||
index >= 0 && this.setData({
|
||||
[`demandList[${index}].is_bid`]: true,
|
||||
[`demandList[${index}].btnName`]: '已投标',
|
||||
[`demandList[${index}].demand_biddings_count`]: this.data.demandList[index].demand_biddings_count + 1
|
||||
});
|
||||
// 先清除标记,避免同一条被重复处理
|
||||
wx.removeStorageSync('bidDemandId');
|
||||
} else {
|
||||
if (this.data.freshPage) {
|
||||
this.setData({ freshPage: false });
|
||||
console.log('freshing');
|
||||
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;
|
||||
}
|
||||
if (this.data.freshPage) {
|
||||
this.setData({ freshPage: false });
|
||||
this.loadDemandList(true);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -254,8 +272,9 @@ Page({
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
this.loadDemandList(true);
|
||||
async onPullDownRefresh() {
|
||||
await this.loadDemandList(true, { silent: true });
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user