From d8bb3953baa1342f94e39853677185e91e990366 Mon Sep 17 00:00:00 2001 From: minimaxagent1 Date: Tue, 12 Aug 2025 09:23:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=A0=8F=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=9F=A5=E8=AF=A2=20=E5=BE=80=E7=94=9F?= =?UTF-8?q?=E6=AE=BF=E9=A1=B5=E9=9D=A2=E8=AF=A6=E7=BB=86=E9=87=8D=E5=AE=9A?= =?UTF-8?q?=E5=90=91=E5=88=B0hall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/search-box/search-box.vue | 6 +++++- pages/memorial/compositons/enshrinedList.vue | 15 ++++++++------- .../compositons/enshrinedListIndex.vue | 15 ++++++++------- pages/memorial/deceasedSearch.vue | 14 ++++++++++++++ pages/memorial/memorial.vue | 16 +++++++++++++++- pages/memorial/memorialHall.vue | 19 +++++++++++++++---- 6 files changed, 65 insertions(+), 20 deletions(-) diff --git a/components/search-box/search-box.vue b/components/search-box/search-box.vue index ac5c1f4..f1c10f6 100644 --- a/components/search-box/search-box.vue +++ b/components/search-box/search-box.vue @@ -43,10 +43,14 @@ export default { }, methods: { onInput(e) { + // 只更新输入值,不触发搜索 this.$emit('input', e.detail.value) }, onSearch() { - this.$emit('search', this.value) + // 只在点击搜索按钮或按回车时触发搜索 + if (this.value.trim()) { + this.$emit('search', this.value) + } } } } diff --git a/pages/memorial/compositons/enshrinedList.vue b/pages/memorial/compositons/enshrinedList.vue index b728e16..f9a8505 100644 --- a/pages/memorial/compositons/enshrinedList.vue +++ b/pages/memorial/compositons/enshrinedList.vue @@ -67,13 +67,14 @@ export default { } }, watch: { - searchKeyword: { - handler(newVal) { - this.resetList() - this.loadData() - }, - immediate: false - } + // 移除对searchKeyword的自动监听,避免输入时自动刷新 + // searchKeyword: { + // handler(newVal) { + // this.resetList() + // this.loadData() + // }, + // immediate: false + // } }, mounted() { this.loadData() diff --git a/pages/memorial/compositons/enshrinedListIndex.vue b/pages/memorial/compositons/enshrinedListIndex.vue index 3bf1fa3..44e8ffc 100644 --- a/pages/memorial/compositons/enshrinedListIndex.vue +++ b/pages/memorial/compositons/enshrinedListIndex.vue @@ -67,13 +67,14 @@ export default { } }, watch: { - searchKeyword: { - handler(newVal) { - this.resetList() - this.loadData() - }, - immediate: false - } + // 移除对searchKeyword的自动监听,避免输入时自动刷新 + // searchKeyword: { + // handler(newVal) { + // this.resetList() + // this.loadData() + // }, + // immediate: false + // } }, mounted() { this.loadData() diff --git a/pages/memorial/deceasedSearch.vue b/pages/memorial/deceasedSearch.vue index c8094da..d0c03c1 100644 --- a/pages/memorial/deceasedSearch.vue +++ b/pages/memorial/deceasedSearch.vue @@ -96,6 +96,20 @@ export default { hasSearched: false } }, + onLoad(options) { + console.log('deceasedSearch页面接收到的参数:', options) + + // 从路由参数获取搜索关键词 + if (options.keyword) { + this.searchName = decodeURIComponent(options.keyword) + console.log('接收到搜索关键词:', this.searchName) + + // 自动执行搜索 + this.$nextTick(() => { + this.handleSearch(this.searchName) + }) + } + }, methods: { // 处理搜索 async handleSearch(value) { diff --git a/pages/memorial/memorial.vue b/pages/memorial/memorial.vue index b17a781..8c042f3 100644 --- a/pages/memorial/memorial.vue +++ b/pages/memorial/memorial.vue @@ -125,7 +125,21 @@ export default { handleSearch(value) { console.log('搜索内容:', value) this.searchName = value - // 搜索逻辑由 enshrinedList 组件处理 + + // 跳转到往生者搜索页面并传递搜索关键词 + uni.navigateTo({ + url: `/pages/memorial/deceasedSearch?keyword=${encodeURIComponent(value)}`, + 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 50d4f80..893405e 100644 --- a/pages/memorial/memorialHall.vue +++ b/pages/memorial/memorialHall.vue @@ -271,10 +271,21 @@ export default { async handleSearch(value) { console.log('搜索内容:', value) this.searchName = value - // 重置页码 - this.pageParams.pageNum = 1 - // 重新获取数据 - await this.getDeceasedList() + + // 跳转到往生者搜索页面并传递搜索关键词 + uni.navigateTo({ + url: `/pages/memorial/deceasedSearch?keyword=${encodeURIComponent(value)}`, + success: () => { + console.log('跳转到搜索页面成功') + }, + fail: (error) => { + console.error('跳转失败:', error) + uni.showToast({ + title: '页面跳转失败', + icon: 'none' + }) + } + }) }, // 处理查看详情