捐款动态界面

This commit is contained in:
minimaxagent1 2025-08-01 11:54:29 +08:00
parent eca711d745
commit f8909e10a7
4 changed files with 122 additions and 35 deletions

24
api/donor/donor.js Normal file
View File

@ -0,0 +1,24 @@
import { request } from '@/utils/request'
/**
* 获取捐款记录列表
* @param {Object} params 查询参数
* @param {string} params.formedId 建制id
* @param {number} params.pageNum 分页页码
* @param {number} params.pageSize 分页大小
* @param {number} params.minAmount 最小金额
* @param {number} params.maxAmount 最大金额
* @param {string} params.sortAmount 根据amount金额排序
* @param {string} params.orderAmount asc/desc排序方式
* @param {string} params.sortTime 根据time捐款时间排序
* @param {string} params.orderTime asc/desc排序方式
* @param {string} params.realName 根据姓名模糊搜索
* @returns {Promise} 返回捐款记录列表
*/
export function getDonorList(params) {
return request({
url: '/app/donor/listDonor',
method: 'get',
params
})
}

View File

@ -73,6 +73,7 @@ import TileGrid from "../../components/tile-grid/tile-grid.vue";
import CommonEnum from "../../enum/common"; import CommonEnum from "../../enum/common";
import StatusDisplay from "../../components/status-display/status-display.vue"; import StatusDisplay from "../../components/status-display/status-display.vue";
import SearchBox from "../../components/search-box/search-box.vue"; import SearchBox from "../../components/search-box/search-box.vue";
import { getDonorList } from '@/api/donor/donor.js';
export default { export default {
components: { components: {
@ -86,7 +87,12 @@ export default {
CommonEnum, CommonEnum,
loading: false, loading: false,
searchKeyword: '', searchKeyword: '',
donationList: [] donationList: [],
formedId: '', // ID
//
pageNum: 1,
pageSize: 10,
hasMore: true
} }
}, },
computed: { computed: {
@ -99,7 +105,11 @@ export default {
return this.donationList.length return this.donationList.length
} }
}, },
onLoad() { onLoad(options) {
//
if (options.formedId) {
this.formedId = options.formedId
}
// //
this.loadDonationRecords() this.loadDonationRecords()
}, },
@ -107,40 +117,60 @@ export default {
onSearch(val) { onSearch(val) {
// //
console.log('搜索内容:', val) console.log('搜索内容:', val)
this.pageNum = 1 //
this.loadDonationRecords(val) this.loadDonationRecords(val)
}, },
onFilter() { onFilter() {
// //
uni.showToast({ title: '筛选功能开发中', icon: 'none' }) uni.showToast({ title: '筛选功能开发中', icon: 'none' })
}, },
// API // API
async loadDonationRecords(keyword = '') { async loadDonationRecords(keyword = '') {
this.loading = true this.loading = true
try { try {
// API const params = {
await new Promise(resolve => setTimeout(resolve, 1000)) formedId: this.formedId,
pageNum: this.pageNum,
pageSize: this.pageSize,
minAmount: 1,
maxAmount: 10000,
sortAmount: 'amount',
orderAmount: 'asc',
sortTime: 'time',
orderTime: 'desc'
}
// //
const mockData = [
{ id: 9, name: '张珊珊', amount: 1000, time: '2025/03/11' },
{ id: 8, name: '李小明', amount: 500, time: '2025/03/09' },
{ id: 7, name: '王大力', amount: 2000, time: '2025/03/01' },
{ id: 6, name: '赵美丽', amount: 800, time: '2025/02/27' },
{ id: 5, name: '刘志强', amount: 1500, time: '2025/02/27' },
{ id: 4, name: '陈小红', amount: 1200, time: '2025/02/24' },
{ id: 3, name: '杨建国', amount: 3000, time: '2025/02/12' },
{ id: 2, name: '孙丽华', amount: 600, time: '2025/02/08' },
{ id: 1, name: '周志明', amount: 2500, time: '2025/02/01' }
]
//
if (keyword) { if (keyword) {
this.donationList = mockData.filter(item => params.realName = keyword
item.name.includes(keyword) || }
item.amount.toString().includes(keyword)
) const response = await getDonorList(params)
if (response.code === 200) {
//
const newData = response.data.map(item => ({
id: item.id,
name: item.realName,
amount: item.amount,
time: this.formatDate(item.donationDate)
}))
//
if (this.pageNum === 1) {
this.donationList = newData
} else {
//
this.donationList = [...this.donationList, ...newData]
}
//
this.hasMore = newData.length === this.pageSize
} else { } else {
this.donationList = mockData uni.showToast({
title: response.msg || '获取数据失败',
icon: 'none'
})
} }
} catch (error) { } catch (error) {
@ -152,6 +182,16 @@ export default {
} finally { } finally {
this.loading = false this.loading = false
} }
},
//
formatDate(dateStr) {
if (!dateStr) return ''
const date = new Date(dateStr)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}/${month}/${day}`
} }
} }
} }

View File

@ -80,10 +80,16 @@ export default {
// //
handleViewDetail(data) { handleViewDetail(data) {
console.log('查看详细:', data.item) console.log('查看详细:', data.item)
// // ID
uni.showToast({ uni.navigateTo({
title: '查看详细功能开发中', url: `/pages/institutionalStructure/donationRecord?formedId=${data.item.formedId}`,
icon: 'none' fail: (err) => {
console.error('跳转失败:', err);
uni.showToast({
title: '页面跳转失败',
icon: 'none'
});
}
}) })
} }
} }

View File

@ -25,7 +25,16 @@ export class InstitutionalDataFormatter {
* @returns {string} 格式化后的内容 * @returns {string} 格式化后的内容
*/ */
static formatTopLeft(year, projectName) { static formatTopLeft(year, projectName) {
if (!year || !projectName) return '暂无数据' // 如果年份和项目名称都为空,返回暂无数据
if (!year && !projectName) return '暂无数据'
// 如果只有年份,只显示年份
if (year && !projectName) return `${year}`
// 如果只有项目名称,只显示项目名称
if (!year && projectName) return projectName
// 如果都有,显示完整格式
return `${year}${projectName}` return `${year}${projectName}`
} }
@ -55,11 +64,19 @@ export class InstitutionalDataFormatter {
* @returns {Array} 转换后的数据 * @returns {Array} 转换后的数据
*/ */
static transformData(rows) { static transformData(rows) {
return rows.map(item => ({ console.log('原始数据:', rows) // 添加调试日志
topLeft: InstitutionalDataFormatter.formatTopLeft(item.startYear, item.proName),
topRight: InstitutionalDataFormatter.getStatusText(item.state), return rows.map(item => {
bottomLeft: `建造金额:${InstitutionalDataFormatter.formatAmount(item.totalAmount)}`, console.log('处理项目:', item) // 添加调试日志
bottomRight: `捐赠人数:${item.donorCount}`
})) return {
topLeft: InstitutionalDataFormatter.formatTopLeft(item.startYear || item.start_year || item.year, item.proName || item.pro_name || item.projectName),
topRight: InstitutionalDataFormatter.getStatusText(item.state),
bottomLeft: `建造金额:${InstitutionalDataFormatter.formatAmount(item.totalAmount || item.total_amount)}`,
bottomRight: `捐赠人数:${item.donorCount || item.donor_count || 0}`,
// 保存原始数据,用于跳转
formedId: item.id
}
})
} }
} }