|
|
|
@ -165,7 +165,8 @@ |
|
|
|
} |
|
|
|
|
|
|
|
.supply-list.expanded { |
|
|
|
max-height: 2000px; |
|
|
|
max-height: none; |
|
|
|
overflow: visible; |
|
|
|
} |
|
|
|
|
|
|
|
.supply-item { |
|
|
|
@ -1588,7 +1589,21 @@ |
|
|
|
draftSupplies: [], |
|
|
|
searchKeyword: '', |
|
|
|
partnerstatus: 'approved', |
|
|
|
uploadedImages: [] |
|
|
|
uploadedImages: [], |
|
|
|
// 分页相关属性 |
|
|
|
pagination: { |
|
|
|
published: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }, |
|
|
|
pending: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }, |
|
|
|
rejected: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }, |
|
|
|
draft: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false } |
|
|
|
}, |
|
|
|
// 分状态存储分页数据 |
|
|
|
paginatedSupplies: { |
|
|
|
published: [], |
|
|
|
pending: [], |
|
|
|
rejected: [], |
|
|
|
draft: [] |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 编辑相关全局变量 |
|
|
|
@ -2957,18 +2972,31 @@ |
|
|
|
const userInfo = checkLogin(); |
|
|
|
if (!userInfo) return; |
|
|
|
|
|
|
|
// 构建查询参数,添加sellerId,并设置较大的pageSize,确保获取所有记录 |
|
|
|
// 设置page=1,pageSize=100,确保获取所有记录 |
|
|
|
// 重置所有状态的分页数据 |
|
|
|
supplyData.pagination = { |
|
|
|
published: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }, |
|
|
|
pending: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }, |
|
|
|
rejected: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false }, |
|
|
|
draft: { currentPage: 1, pageSize: 20, total: 0, hasMore: true, isLoading: false } |
|
|
|
}; |
|
|
|
|
|
|
|
// 清空所有状态的分页数据 |
|
|
|
supplyData.paginatedSupplies = { |
|
|
|
published: [], |
|
|
|
pending: [], |
|
|
|
rejected: [], |
|
|
|
draft: [] |
|
|
|
}; |
|
|
|
|
|
|
|
// 构建查询参数,获取所有数据 |
|
|
|
const queryParams = new URLSearchParams({ |
|
|
|
sellerId: userInfo.userId, |
|
|
|
page: 1, |
|
|
|
pageSize: 100 // 设置较大的pageSize,确保获取所有记录 |
|
|
|
pageSize: 1000 // 设置较大的pageSize,确保获取所有记录 |
|
|
|
}); |
|
|
|
|
|
|
|
const apiUrl = `/api/supplies?${queryParams}`; |
|
|
|
console.log('当前登录用户信息:', userInfo); |
|
|
|
console.log('加载货源列表API请求:', apiUrl); |
|
|
|
console.log('使用的sellerId:', userInfo.userId); |
|
|
|
|
|
|
|
const response = await fetch(apiUrl); |
|
|
|
const result = await response.json(); |
|
|
|
@ -3057,7 +3085,16 @@ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 只在首次渲染或没有分页数据时初始化分页数据 |
|
|
|
if (!supplyData.paginatedSupplies[type] || supplyData.paginatedSupplies[type].length === 0) { |
|
|
|
updatePaginatedSupplies(type, supplies); |
|
|
|
} |
|
|
|
|
|
|
|
const pagination = supplyData.pagination[type]; |
|
|
|
const paginatedSupplies = supplyData.paginatedSupplies[type] || []; |
|
|
|
|
|
|
|
let html = ''; |
|
|
|
// 显示所有货源,不分页 |
|
|
|
supplies.forEach(supply => { |
|
|
|
html += generateSupplyItemHTML(supply); |
|
|
|
}); |
|
|
|
@ -3065,6 +3102,70 @@ |
|
|
|
listElement.innerHTML = html; |
|
|
|
} |
|
|
|
|
|
|
|
// 加载更多货源 |
|
|
|
function loadMoreSupplies(type) { |
|
|
|
const pagination = supplyData.pagination[type]; |
|
|
|
const allSupplies = getSuppliesByType(type); |
|
|
|
|
|
|
|
if (pagination.isLoading || !pagination.hasMore) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
pagination.isLoading = true; |
|
|
|
|
|
|
|
// 更新加载状态文本 |
|
|
|
const loadMoreText = document.getElementById(`loadMoreText_${type}`); |
|
|
|
if (loadMoreText) { |
|
|
|
loadMoreText.textContent = '加载中...'; |
|
|
|
} |
|
|
|
|
|
|
|
// 模拟加载延迟 |
|
|
|
setTimeout(() => { |
|
|
|
// 计算下一页数据 |
|
|
|
const nextPage = pagination.currentPage + 1; |
|
|
|
const startIndex = pagination.pageSize * pagination.currentPage; |
|
|
|
const endIndex = startIndex + pagination.pageSize; |
|
|
|
const newSupplies = allSupplies.slice(startIndex, endIndex); |
|
|
|
|
|
|
|
// 更新分页数据 |
|
|
|
supplyData.paginatedSupplies[type] = [...supplyData.paginatedSupplies[type], ...newSupplies]; |
|
|
|
pagination.currentPage = nextPage; |
|
|
|
pagination.hasMore = endIndex < allSupplies.length; |
|
|
|
|
|
|
|
// 重新渲染列表 |
|
|
|
renderSupplyList(type, allSupplies); |
|
|
|
|
|
|
|
// 重置加载状态 |
|
|
|
pagination.isLoading = false; |
|
|
|
}, 500); |
|
|
|
} |
|
|
|
|
|
|
|
// 根据类型获取完整的货源列表 |
|
|
|
function getSuppliesByType(type) { |
|
|
|
switch(type) { |
|
|
|
case 'published': return supplyData.publishedSupplies; |
|
|
|
case 'pending': return supplyData.pendingSupplies; |
|
|
|
case 'rejected': return supplyData.rejectedSupplies; |
|
|
|
case 'draft': return supplyData.draftSupplies; |
|
|
|
default: return []; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 更新分页数据 |
|
|
|
function updatePaginatedSupplies(status, supplies) { |
|
|
|
const pagination = supplyData.pagination[status]; |
|
|
|
|
|
|
|
// 重置分页状态 |
|
|
|
pagination.currentPage = 1; |
|
|
|
pagination.total = supplies.length; |
|
|
|
pagination.hasMore = supplies.length > pagination.pageSize; |
|
|
|
|
|
|
|
// 初始只显示第一页数据 |
|
|
|
supplyData.paginatedSupplies[status] = supplies.slice(0, pagination.pageSize); |
|
|
|
|
|
|
|
console.log(`更新分页数据 - ${status}: 总数=${pagination.total}, 每页=${pagination.pageSize}, 有更多=${pagination.hasMore}`); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取列表标题 |
|
|
|
function getSectionTitle(type) { |
|
|
|
switch(type) { |
|
|
|
|