This commit is contained in:
18631081161 2025-06-22 16:52:09 +08:00
commit 30bbc09066
3 changed files with 52 additions and 10 deletions

View File

@ -116,7 +116,9 @@ const queryList = (pageNo, pageSize) => {
//
const refresh = () => {
console.log("refreshrefreshrefreshrefresh");
if (paging.value) {
console.log("refreshrefreshrefreshrefresh");
paging.value.reload();
}
};

View File

@ -11,7 +11,8 @@
<text>{{ publish_time }}</text>
</view>
<view class="news-details__time-right">
<image :src="follow_image" mode="aspectFill" style="width:36rpx; height:36rpx;" @click="onFollow"></image>
<image :src="follow_image" mode="aspectFill" style="width:36rpx; height:36rpx;"
@click="onFollow"></image>
</view>
</view>
<view class="news-details__content">
@ -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);

View File

@ -2,6 +2,7 @@
<z-paging-swiper>
<template #top>
<view class="" style="width: 100%; height: 225.19rpx; background-color: white; position: relative;">
<view class="tab">
<view class="tab-item" v-for="(item, i) in tabList" :key="i" :class="current == i ? 'act' : 'unact'"
@click="tabChange(i)">
@ -12,6 +13,15 @@
</template>
<swiper class="swiper" :current="current" @animationfinish="swiperAnimationfinish">
<swiper-item class="swiper-item" v-for="(item, index) in tabList" :key="index">
<view class="search-container">
<view class="search">
<text class="iconfont icon-search" style="margin-right: 10rpx; color: #999;"></text>
<input type="text" v-model="searchKeywords[index]" placeholder="搜索" confirm-type="search"
@confirm="() => onSearch(index)" />
<text class="iconfont icon-close" v-if="searchKeywords[index]" @click="() => clearSearch(index)"
style="margin-left: 10rpx; color: #999;"></text>
</view>
</view>
<news-list-item @clickItem="onClickItem" :responseCallback="queryList" ref="listItem" :tabIndex="index"
:currentIndex="current">
</news-list-item>
@ -28,18 +38,20 @@ import { navigateTo } from '@/common/system/router'
const tabList = ref(["热榜", "精选", "关注"])
const current = ref(1); // tabscurrenttab
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();
};
</script>
@ -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 {