From 932ee52441a50db88e4df31f4b04e8b3e9941a14 Mon Sep 17 00:00:00 2001 From: minimaxagent1 Date: Mon, 11 Aug 2025 11:18:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=80=E7=94=9F=E5=A4=A7=E6=AE=BF=E9=80=9D?= =?UTF-8?q?=E8=80=85=E8=AE=B0=E5=BD=954.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MEMORIAL_NAVIGATION_TEST.md | 125 ++++++++++++++++++++++++++++++++ pages/memorial/memorial.vue | 20 +++++ pages/memorial/memorialHall.vue | 13 ++-- 3 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 MEMORIAL_NAVIGATION_TEST.md diff --git a/MEMORIAL_NAVIGATION_TEST.md b/MEMORIAL_NAVIGATION_TEST.md new file mode 100644 index 0000000..fe89a8e --- /dev/null +++ b/MEMORIAL_NAVIGATION_TEST.md @@ -0,0 +1,125 @@ +# 往生殿页面跳转功能测试 + +## 功能描述 +从memorial页面点击"供奉"按钮后,跳转到memorialHall页面,并传递往生殿ID进行页面渲染。 + +## 跳转流程 + +### 1. 起始页面:memorial.vue +- **路径**: `/pages/memorial/memorial` +- **功能**: 往生殿列表页面 +- **触发方式**: 点击底部"供奉"按钮 + +### 2. 目标页面:memorialHall.vue +- **路径**: `/pages/memorial/memorialHall` +- **功能**: 往生大殿详情页面 +- **接收参数**: `id` - 往生殿ID + +## 实现细节 + +### memorial.vue 中的跳转逻辑 +```javascript +// 提交供奉 - 跳转到往生大殿页面 +submitPrayer() { + console.log('提交供奉,跳转到往生大殿页面,ID:', this.memorialId) + + // 跳转到往生大殿页面,传递往生殿ID + uni.navigateTo({ + url: `/pages/memorial/memorialHall?id=${this.memorialId}`, + success: () => { + console.log('跳转成功') + }, + fail: (error) => { + console.error('跳转失败:', error) + uni.showToast({ + title: '页面跳转失败', + icon: 'none' + }) + } + }) +} +``` + +### memorialHall.vue 中的参数接收 +```javascript +onLoad(options) { + console.log('memorialHall页面接收到的参数:', options) + // 从路由参数获取往生殿ID + if (options.id) { + this.memorialId = options.id + console.log('设置往生殿ID:', this.memorialId) + } else { + console.warn('未接收到往生殿ID,使用默认ID:', this.memorialId) + } + this.initPage() +} +``` + +## 测试步骤 + +### 1. 进入memorial页面 +```javascript +// 可以通过以下方式进入memorial页面 +uni.navigateTo({ + url: '/pages/memorial/memorial?id=16' +}) +``` + +### 2. 点击供奉按钮 +- 在memorial页面底部找到"供奉"按钮 +- 点击按钮触发跳转 + +### 3. 验证跳转结果 +- 页面应该跳转到memorialHall页面 +- 控制台应该显示接收到的参数 +- 页面应该根据传递的ID加载对应的往生殿信息 + +## 预期结果 + +### 成功跳转时: +1. 页面从memorial跳转到memorialHall +2. 控制台显示: + ``` + memorialHall页面接收到的参数: {id: "16"} + 设置往生殿ID: 16 + 往生殿页面初始化,ID: 16 + ``` +3. memorialHall页面根据ID加载对应的往生殿详情和往生者列表 + +### 跳转失败时: +1. 显示错误提示:"页面跳转失败" +2. 控制台显示具体错误信息 + +## 调试信息 + +### 控制台日志 +- `memorialHall页面接收到的参数:` - 显示接收到的所有参数 +- `设置往生殿ID:` - 显示设置的往生殿ID +- `往生殿页面初始化,ID:` - 显示页面初始化时的ID +- `往生殿详情响应:` - 显示API响应数据 +- `往生者列表数据:` - 显示往生者列表数据 + +### 网络请求 +- `GET /app/memorial/{id}` - 获取往生殿详情 +- `GET /app/deceased/list` - 获取往生者列表 + +## 注意事项 + +1. **ID传递**: 确保memorial页面的memorialId变量有正确的值 +2. **页面配置**: 确保pages.json中两个页面都已正确配置 +3. **API接口**: 确保后端API接口正常工作 +4. **网络连接**: 确保网络连接正常,能够访问API + +## 错误排查 + +### 常见问题: +1. **页面跳转失败**: 检查pages.json配置 +2. **ID未传递**: 检查memorial页面的memorialId变量 +3. **数据加载失败**: 检查API接口和网络连接 +4. **页面显示异常**: 检查memorialHall页面的模板和样式 + +### 调试方法: +1. 查看控制台日志 +2. 检查网络请求 +3. 验证API响应数据 +4. 检查页面参数传递 \ No newline at end of file diff --git a/pages/memorial/memorial.vue b/pages/memorial/memorial.vue index 7dec535..b37d07d 100644 --- a/pages/memorial/memorial.vue +++ b/pages/memorial/memorial.vue @@ -160,6 +160,26 @@ export default { }, + + // 提交供奉 - 跳转到往生大殿页面 + submitPrayer() { + console.log('提交供奉,跳转到往生大殿页面,ID:', this.selectedUnitId) + + // 跳转到往生大殿页面,传递往生殿ID + uni.navigateTo({ + url: `/pages/memorial/memorialHall?id=${this.selectedUnitId}`, + success: () => { + console.log('跳转成功') + }, + fail: (error) => { + console.error('跳转失败:', error) + uni.showToast({ + title: '页面跳转失败', + icon: 'none' + }) + } + }) + } } } diff --git a/pages/memorial/memorialHall.vue b/pages/memorial/memorialHall.vue index 5560c00..1b0a358 100644 --- a/pages/memorial/memorialHall.vue +++ b/pages/memorial/memorialHall.vue @@ -127,7 +127,6 @@ export default { CommonEnum, searchName: '', loading: false, - memorialId: '16', // 默认往生殿ID,可以从路由参数获取 // 楼层选择器默认值 defaultFloorId: '', defaultAreaId: '', @@ -152,9 +151,13 @@ export default { } }, onLoad(options) { + console.log('memorialHall页面接收到的参数:', options) // 从路由参数获取往生殿ID if (options.id) { - this.memorialId = options.id + this.selectedUnitId = options.id + console.log('区域ID:', this.selectedUnitId) + } else { + console.warn('未接收到区域ID,使用默认ID:', this.selectedUnitId) } this.initPage() }, @@ -168,7 +171,7 @@ export default { this.loading = true try { // 页面初始化逻辑 - console.log('往生殿页面初始化,ID:', this.memorialId) + console.log('往生大殿页面初始化,ID:', this.selectedUnitId) // 获取往生殿详情 await this.getMemorialDetail() // 获取往生者列表 @@ -187,7 +190,7 @@ export default { // 获取往生殿详情 async getMemorialDetail() { try { - const response = await getMemorialDetail(this.memorialId) + const response = await getMemorialDetail(this.selectedUnitId) console.log('往生殿详情响应:', response) if (response.code === 200) { @@ -213,7 +216,7 @@ export default { async getDeceasedList() { try { const params = { - memorialId: this.memorialId, + memorialId: this.selectedUnitId, pageNum: this.pageParams.pageNum, pageSize: this.pageParams.pageSize }