diff --git a/api/donor/donor.js b/api/donor/donor.js index ae17dc6..41db859 100644 --- a/api/donor/donor.js +++ b/api/donor/donor.js @@ -16,5 +16,7 @@ import { get, post } from '@/utils/request' * @returns {Promise} 返回捐款记录列表 */ export function getDonorList(params) { - return get('/app/donor/listDonor', params) + return get('/app/donor/listDonor', params, { + showLoading: false // 使用页面级别的loading管理 + }) } \ No newline at end of file diff --git a/api/institutionalStructure/institutionalStructureDetail.js b/api/institutionalStructure/institutionalStructureDetail.js index c9e6c2c..90aa2c3 100644 --- a/api/institutionalStructure/institutionalStructureDetail.js +++ b/api/institutionalStructure/institutionalStructureDetail.js @@ -7,7 +7,9 @@ import { get, put, del } from '@/utils/request' * @returns {Promise} 返回建制详情 */ export function getInstitutionalDetail(formedId) { - return get('/app/formed/formedDetail', { formedId }) + return get('/app/formed/formedDetail', { formedId }, { + showLoading: false // 使用页面级别的loading管理 + }) } /** diff --git a/api/monk/monkDetail.js b/api/monk/monkDetail.js index e326e1e..d1de6c8 100644 --- a/api/monk/monkDetail.js +++ b/api/monk/monkDetail.js @@ -1,7 +1,7 @@ /** * 高僧详情相关API */ -import { request } from '../../utils/request.js'; +import { get, post, put, del } from '../../utils/request.js'; /** * 获取高僧详情 @@ -9,10 +9,8 @@ import { request } from '../../utils/request.js'; * @returns {Promise} 返回高僧详情数据 */ export function getMonkDetail(monkId) { - return request({ - url: '/app/monk/monkById', - method: 'GET', - params: { monkId } + return get('/app/monk/monkById', { monkId }, { + showLoading: false // 使用页面级别的loading管理 }); } @@ -25,14 +23,12 @@ export function getMonkDetail(monkId) { * @returns {Promise} 返回高僧列表数据 */ export function getMonkList(params = {}) { - return request({ - url: '/app/monk/listMonk', - method: 'GET', - params: { - pageNum: 1, - pageSize: 10, - ...params - } + return get('/app/monk/listMonk', { + pageNum: 1, + pageSize: 10, + ...params + }, { + showLoading: false // 使用页面级别的loading管理 }); } @@ -42,11 +38,7 @@ export function getMonkList(params = {}) { * @returns {Promise} 返回创建结果 */ export function createMonk(data) { - return request({ - url: '/app/monk/createMonk', - method: 'POST', - data - }); + return post('/app/monk/createMonk', data); } /** @@ -55,11 +47,7 @@ export function createMonk(data) { * @returns {Promise} 返回更新结果 */ export function updateMonk(data) { - return request({ - url: '/app/monk/updateMonk', - method: 'PUT', - data - }); + return put('/app/monk/updateMonk', data); } /** @@ -68,9 +56,5 @@ export function updateMonk(data) { * @returns {Promise} 返回删除结果 */ export function deleteMonk(id) { - return request({ - url: '/app/monk/deleteMonk', - method: 'DELETE', - params: { id } - }); + return del('/app/monk/deleteMonk', { id }); } \ No newline at end of file diff --git a/pages/institutionalStructure/donationRecord.vue b/pages/institutionalStructure/donationRecord.vue index 0bf5ea3..27b5a7b 100644 --- a/pages/institutionalStructure/donationRecord.vue +++ b/pages/institutionalStructure/donationRecord.vue @@ -51,6 +51,7 @@ import ProjectInfo from "./components/project-info.vue"; import DonationSummary from "./components/donation-summary.vue"; import DonationList from "./components/donation-list.vue"; import { donationMixin } from "./mixins/donation-mixin.js"; +import { PageLoadingManager } from "../../utils/request.js"; export default { mixins: [donationMixin], @@ -69,10 +70,19 @@ export default { } }, onLoad(options) { + // 初始化页面loading管理器 + this.pageLoading = new PageLoadingManager() + // 获取页面参数 if (options.formedId) { this.initData(options.formedId) } + }, + onUnload() { + // 页面卸载时清除loading + if (this.pageLoading) { + this.pageLoading.destroy() + } } } diff --git a/pages/institutionalStructure/mixins/donation-mixin.js b/pages/institutionalStructure/mixins/donation-mixin.js index db5eb4e..0e61c8d 100644 --- a/pages/institutionalStructure/mixins/donation-mixin.js +++ b/pages/institutionalStructure/mixins/donation-mixin.js @@ -44,9 +44,27 @@ export const donationMixin = { try { const response = await getInstitutionalDetail(this.formedId) + console.log('项目详情API响应:', response) if (response.code === 200) { - this.projectInfo = response.data + // 根据实际后端数据结构获取项目信息 + console.log('项目详情数据结构:', { + hasData: !!response.data, + hasRows: !!response.rows, + dataType: typeof response.data, + rowsType: typeof response.rows + }) + + if (response.data) { + this.projectInfo = response.data + console.log('使用 response.data 作为项目信息') + } else if (response.rows) { + this.projectInfo = response.rows + console.log('使用 response.rows 作为项目信息') + } else { + this.projectInfo = {} + console.log('未找到项目信息,使用空对象') + } console.log('项目信息:', this.projectInfo) } else { console.error('获取项目信息失败:', response.msg) @@ -89,10 +107,44 @@ export const donationMixin = { } const response = await getDonorList(params) + console.log('捐款记录API响应:', response) if (response.code === 200) { + // 根据实际后端数据结构获取数据数组 + let dataArray = [] + + console.log('解析数据结构:', { + hasData: !!response.data, + hasDataList: !!(response.data && response.data.list), + hasDataListRows: !!(response.data && response.data.list && response.data.list.rows), + dataIsArray: Array.isArray(response.data), + hasRows: !!response.rows, + rowsIsArray: Array.isArray(response.rows) + }) + + if (response.data && response.data.list && response.data.list.rows) { + // 标准结构:response.data.list.rows + dataArray = response.data.list.rows + console.log('使用标准结构: response.data.list.rows') + } else if (response.data && Array.isArray(response.data)) { + // 备用结构:response.data 直接是数组 + dataArray = response.data + console.log('使用备用结构: response.data') + } else if (response.rows && Array.isArray(response.rows)) { + // 备用结构:response.rows 是数组 + dataArray = response.rows + console.log('使用备用结构: response.rows') + } else { + console.error('无法找到数据数组,API响应结构:', response) + uni.showToast({ + title: '数据格式错误', + icon: 'none' + }) + return + } + // 转换数据格式 - const newData = response.data.map(item => ({ + const newData = dataArray.map(item => ({ id: item.id, name: item.realName, amount: item.amount, @@ -162,10 +214,32 @@ export const donationMixin = { * 初始化数据 * @param {string} formedId 建制ID */ - initData(formedId) { - this.formedId = formedId - this.loadProjectInfo() - this.loadDonationRecords() + async initData(formedId) { + console.log('初始化捐款记录数据, formedId:', formedId) + + // 显示页面loading + if (this.pageLoading) { + this.pageLoading.show('努力加载中~') + } + + try { + this.formedId = formedId + await this.loadProjectInfo() + await this.loadDonationRecords() + console.log('捐款记录数据初始化完成') + } catch (error) { + console.error('初始化捐款记录数据失败:', error) + uni.showToast({ + title: '初始化数据失败', + icon: 'none' + }) + } finally { + // 隐藏页面loading + if (this.pageLoading) { + this.pageLoading.hide() + console.log('页面loading已隐藏') + } + } } } } \ No newline at end of file diff --git a/pages/monk/monkDetail.vue b/pages/monk/monkDetail.vue index 58bc0c7..650f9c6 100644 --- a/pages/monk/monkDetail.vue +++ b/pages/monk/monkDetail.vue @@ -50,6 +50,7 @@ import MonkEnum from "../../enum/monk"; import {getMonkDetail} from "../../api/monk/monkDetail.js"; import CustomNavbar from "../../components/custom-navbar/custom-navbar.vue"; import BaseBackground from "../../components/base-background/base-background.vue"; +import { PageLoadingManager } from "../../utils/request.js"; export default { components: { @@ -72,11 +73,20 @@ export default { } }, onLoad(options) { + // 初始化页面loading管理器 + this.pageLoading = new PageLoadingManager() + // 获取传递的参数 if (options.id) { this.fetchMonkDetail(options.id); } }, + onUnload() { + // 页面卸载时清除loading + if (this.pageLoading) { + this.pageLoading.destroy() + } + }, methods: { // 切换标签 switchTab(index) { @@ -84,13 +94,24 @@ export default { }, // 获取高僧详情 async fetchMonkDetail(monkId) { + console.log('开始获取高僧详情, monkId:', monkId) + + // 显示页面loading + if (this.pageLoading) { + this.pageLoading.show('努力加载中~') + } + try { const res = await getMonkDetail(monkId); + console.log('高僧详情API响应:', res) + if (res.code === 200 && res.data) { this.monkInfo = res.data; // 更新标签内容 this.updateTabsContent(); + console.log('高僧详情加载完成:', this.monkInfo) } else { + console.error('API响应异常:', res) uni.showToast({ title: res.msg || '获取详情失败', icon: 'none' @@ -102,6 +123,12 @@ export default { title: '网络错误', icon: 'none' }); + } finally { + // 隐藏页面loading + if (this.pageLoading) { + this.pageLoading.hide() + console.log('页面loading已隐藏') + } } }, // 更新标签内容 diff --git a/pages/test/data-structure-test.vue b/pages/test/data-structure-test.vue new file mode 100644 index 0000000..3e3e10a --- /dev/null +++ b/pages/test/data-structure-test.vue @@ -0,0 +1,167 @@ + + + + + \ No newline at end of file diff --git a/pages/test/donation-test.vue b/pages/test/donation-test.vue new file mode 100644 index 0000000..af1f263 --- /dev/null +++ b/pages/test/donation-test.vue @@ -0,0 +1,100 @@ + + + + + \ No newline at end of file diff --git a/pages/test/monk-detail-test.vue b/pages/test/monk-detail-test.vue new file mode 100644 index 0000000..41cd0a9 --- /dev/null +++ b/pages/test/monk-detail-test.vue @@ -0,0 +1,94 @@ + + + + + \ No newline at end of file