From 62dfc9109a89ad5683bdaef0fa13f91d01b1028a Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 22 Jun 2025 15:22:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B0=E9=97=BB=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../youdas-container/news-list-item.vue | 2 + pages/news/news-details.vue | 8 ++- pages/news/news.vue | 52 ++++++++++++++++--- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/components/youdas-container/news-list-item.vue b/components/youdas-container/news-list-item.vue index 5e16b2e..8e19e9d 100644 --- a/components/youdas-container/news-list-item.vue +++ b/components/youdas-container/news-list-item.vue @@ -116,7 +116,9 @@ const queryList = (pageNo, pageSize) => { // 添加刷新数据方法 const refresh = () => { + console.log("refreshrefreshrefreshrefresh"); if (paging.value) { + console.log("refreshrefreshrefreshrefresh"); paging.value.reload(); } }; diff --git a/pages/news/news-details.vue b/pages/news/news-details.vue index 23d5739..4961806 100644 --- a/pages/news/news-details.vue +++ b/pages/news/news-details.vue @@ -11,7 +11,8 @@ {{ publish_time }} - + @@ -79,7 +80,6 @@ export default { } }, async onLoad(options) { - console.log("optionsoptionsoptionsoptions", options); this.options = options; this.title = ""; this.getNewsDetail(options.id, options.current); @@ -87,6 +87,10 @@ export default { }, methods: { async onFollow() { + if (!yds.userInfo.isAccountLogin()) { + yds.showToast("请登录后在收藏!"); + return; + } this.follow = !this.follow; if (this.follow) { await addFavorite(this.options.id); diff --git a/pages/news/news.vue b/pages/news/news.vue index ab23a5c..706c34e 100644 --- a/pages/news/news.vue +++ b/pages/news/news.vue @@ -2,6 +2,7 @@ + + + + + + + @@ -28,18 +38,20 @@ import { navigateTo } from '@/common/system/router' const tabList = ref(["热榜", "精选", "关注"]) const current = ref(1); // tabs组件的current值,表示当前活动的tab选项 const listItem = ref(null); +// 为每个标签页创建独立的搜索关键词 +const searchKeywords = ref(['', '', '']); + //加载数据 const queryList = async (params) => { let { pageNo, pageSize, type } = params; - console.log("type", type); if (type == 0) { - const res = await getHotNewsList(pageNo, pageSize); + const res = await getHotNewsList(pageNo, pageSize, searchKeywords.value[0]); return res; } else if (type == 1) { - const res = await getFeaturedNewsList(pageNo, pageSize); + const res = await getFeaturedNewsList(pageNo, pageSize, searchKeywords.value[1]); return res; } else if (type == 2) { - const res = await getFollowNewsList(pageNo, pageSize); + const res = await getFollowNewsList(pageNo, pageSize, searchKeywords.value[2]); return res; } return { list: [] }; @@ -58,7 +70,18 @@ const swiperAnimationfinish = (e) => { }; // 如果要通知当前展示的z-paging刷新,请调用此方法 const reloadCurrentList = () => { - listItem.value[current.value].reset(); + listItem.value[current.value].refresh(); +}; +const onSearch = (index) => { + // 实现搜索功能 + console.log('搜索关键词:', searchKeywords.value[index]); + // 刷新当前列表 + reloadCurrentList(); +}; +const clearSearch = (index) => { + searchKeywords.value[index] = ''; + // 清空搜索词后重新加载数据 + reloadCurrentList(); }; @@ -67,14 +90,27 @@ const reloadCurrentList = () => { height: 100%; } +.search-container { + padding: 20rpx; + width: 100%; + box-sizing: border-box; +} + .search { - height: 50rpx; + height: 70rpx; background-color: #F7F7F7; - border-radius: 10rpx; + border-radius: 35rpx; padding: 0 20rpx; - margin: 0 20rpx; display: flex; align-items: center; + width: 100%; + box-sizing: border-box; + + input { + flex: 1; + height: 100%; + font-size: 28rpx; + } } .tab {