feat(资讯页面): 实现资讯列表分页加载和搜索功能

- 添加分页加载逻辑,支持上拉加载更多
- 重构搜索功能,整合搜索和自定义搜索事件
- 优化资讯列表显示,使用格式化后的时间字符串
- 调整退出登录按钮样式和位置
This commit is contained in:
34701892@qq.com 2025-11-20 13:46:35 +08:00
parent 8c3b5c825f
commit 6a0db7df63
1 changed files with 78 additions and 69 deletions

View File

@ -4,7 +4,6 @@
<view class="all"> <view class="all">
<text class="top_menu_text">海外资讯</text> <text class="top_menu_text">海外资讯</text>
<view class="banner"> <view class="banner">
<img :src="bannerImg" class="banner_bk" /> <img :src="bannerImg" class="banner_bk" />
<view class="r_banner_title"> <view class="r_banner_title">
<img :src="bannerTitle2" class="banner_title" /> <img :src="bannerTitle2" class="banner_title" />
@ -16,7 +15,7 @@
<!-- 搜索 start --> <!-- 搜索 start -->
<view class="r_sreach"> <view class="r_sreach">
<view class="sreach"> <view class="sreach">
<u-search v-model="form.keyword" placeholder="搜索资讯" @search="getData" /> <u-search v-model="form.keyword" placeholder="搜索资讯" @search="onSreach" @custom="onSreach" />
<!-- <view class="sreach_icon"> <!-- <view class="sreach_icon">
<image :src="icon_search"></image> <image :src="icon_search"></image>
</view> </view>
@ -46,7 +45,7 @@
<view class="card_right"> <view class="card_right">
<view v-for="item in item.list" :key="item.time"> <view v-for="item in item.list" :key="item.time">
<view class="item_time"> <view class="item_time">
<text>{{ item.time }}</text> <text>{{ item.timeStr }}</text>
<text class="item_source_title">来自 <text class="item_source">中国证券报</text></text> <text class="item_source_title">来自 <text class="item_source">中国证券报</text></text>
</view> </view>
<view class="item_title"> <view class="item_title">
@ -56,28 +55,28 @@
<text>{{ item.summary }}</text> <text>{{ item.summary }}</text>
</view> </view>
<view class="item_etf"> <view class="item_etf">
<view v-for="etf in item.etfs" :key="etf.code" class="item_etf_item"> <view v-for="etf in item.etfs" :key="etf.code" class="item_etf_item">
<text>{{ etf.name }}</text> <text>{{ etf.name }}</text>
<div class="btn-play"> <div class="btn-play"></div>
</div>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="logout" @click="loginOut" v-if="Session.get('token')">退出登录</view> <view class="r_logout">
<view class="logout" @click="loginOut" v-if="Session.get('token')">退出登录</view>
</view>
<LoginPopup :show="LoginShow" @handlePopupClose="handlePopupClose" <LoginPopup
@handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" /> :show="LoginShow"
@handlePopupClose="handlePopupClose"
@handlePopupSuccessCallback="handlePopupSuccessCallback"
@handlePopupErrorCallback="handlePopupErrorCallback"
/>
</view> </view>
</template> </template>
@ -92,42 +91,44 @@ import time_icon from "@/assets/zixun/time_icon.png";
import LoginPopup from "@/components/loginPopup/index.vue"; import LoginPopup from "@/components/loginPopup/index.vue";
import { Session } from "@/utils/storage"; import { Session } from "@/utils/storage";
import dayjs from "dayjs/esm/index"; import dayjs from "dayjs/esm/index";
import { onReachBottom } from "@dcloudio/uni-app";
import { getEtfIndexList } from "@/api/index";
import { const listData = ref([
getEtfIndexList, {
} from "@/api/index"; day: "2026-10-26",
list: [
{
const listData = ref( time: "11:30:56",
[ title: "刚果延长禁令后,中国钴价和库存飙升刚果延长禁令后,中国钴价和库存飙升",
{ summary: "刚果民主共和国将钴出口禁令延长至9月导致全球约四分之三的钴供应受到影响。这一消息引…",
"day": "2026-10-26", etfs: [
"list": [ {
{ name: "医药 ETF",
"time": "11:30:56", code: "string",
"title": "刚果延长禁令后,中国钴价和库存飙升刚果延长禁令后,中国钴价和库存飙升", },
"summary": "刚果民主共和国将钴出口禁令延长至9月导致全球约四分之三的钴供应受到影响。这一消息引…", ],
"etfs": [ },
{ ],
"name": "医药 ETF", },
"code": "string" ]);
}
]
}
]
}
]
)
const form = ref({ const form = ref({
keyword: "" page: 1,
}) keyword: null,
});
async function getData() { async function getData() {
let { code, data } = await getEtfIndexList({ let { code, data } = await getEtfIndexList({
...form.value ...form.value,
}) size: 20,
});
if (code == 200) { if (code == 200) {
listData.value = data if (form.value.page == 1) {
listData.value = [];
listData.value = data.list;
} else {
listData.value = [...listData.value, ...data.list];
}
} }
} }
@ -148,6 +149,7 @@ const handlePopupErrorCallback = () => {
console.log("登录失败"); console.log("登录失败");
}; };
import { doLogout } from "@/api"; import { doLogout } from "@/api";
import { onPullDownRefresh } from "@dcloudio/uni-app";
function loginOut() { function loginOut() {
doLogout({ doLogout({
financialAccount: Session.get("userPhone"), financialAccount: Session.get("userPhone"),
@ -156,11 +158,15 @@ function loginOut() {
window.location.reload(); window.location.reload();
} }
function goSreach() { onReachBottom(() => {
form.value.page++;
getData();
});
function onSreach() {
if (Session.get("token")) { if (Session.get("token")) {
uni.navigateTo({ form.value.page = 1;
url: "/pages/sreachReq/index", getData();
});
} else { } else {
LoginShow.value = true; LoginShow.value = true;
} }
@ -170,7 +176,7 @@ onMounted(async () => {
if (!Session.get("token")) { if (!Session.get("token")) {
LoginShow.value = true; LoginShow.value = true;
} }
getData() getData();
}); });
</script> </script>
@ -190,12 +196,11 @@ onMounted(async () => {
font-family: PingFangSC, PingFang SC; font-family: PingFangSC, PingFang SC;
font-weight: 500; font-weight: 500;
font-size: 34rpx; font-size: 34rpx;
color: #FFFFFF; color: #ffffff;
line-height: 36rpx; line-height: 36rpx;
text-align: center; text-align: center;
font-style: normal; font-style: normal;
} }
} }
.banner { .banner {
@ -221,14 +226,23 @@ onMounted(async () => {
text { text {
font-family: AlibabaPuHuiTiM; font-family: AlibabaPuHuiTiM;
font-size: 32rpx; font-size: 32rpx;
color: #FFFFFF; color: #ffffff;
line-height: 44rpx; line-height: 44rpx;
text-align: left; text-align: left;
font-style: normal; font-style: normal;
} }
} }
.r_logout {
position: fixed;
bottom: 0rpx;
right: 0rpx;
z-index: 9999;
background-color: white;
width: 100vw;
height: auto;
box-shadow: 0 -10rpx 20rpx rgba(73, 73, 73, 0.1);
}
.logout { .logout {
// width: 100%; // width: 100%;
@ -239,14 +253,13 @@ onMounted(async () => {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
color: white; color: white;
margin-top: 50rpx; margin-top: 20rpx;
border-radius: 20rpx; border-radius: 20rpx;
margin-left: 20rpx; margin-left: 20rpx;
margin-right: 20rpx; margin-right: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.logo_text { .logo_text {
width: 88rpx; width: 88rpx;
height: 40rpx; height: 40rpx;
@ -261,12 +274,12 @@ onMounted(async () => {
position: relative; position: relative;
z-index: 9999; z-index: 9999;
background: linear-gradient(180deg, #FFFFFF 0%, #F3F5F8 100%); background: linear-gradient(180deg, #ffffff 0%, #f3f5f8 100%);
border-radius: 24rpx 24rpx 0rpx 0rpx; border-radius: 24rpx 24rpx 0rpx 0rpx;
margin-top: -70px; margin-top: -70px;
padding: 10rpx 30rpx; padding: 10rpx 30rpx;
background: linear-gradient(180deg, #FFFFFF 0%, #F3F5F8 100%); background: linear-gradient(180deg, #ffffff 0%, #f3f5f8 100%);
// min-height: 80vh; // min-height: 80vh;
.r_sreach { .r_sreach {
@ -285,7 +298,7 @@ onMounted(async () => {
border-radius: 100rpx; border-radius: 100rpx;
width: 100%; width: 100%;
height: 100%; height: 100%;
background: #F3F5F8; background: #f3f5f8;
border-radius: 36rpx; border-radius: 36rpx;
// box-shadow: 0 0 10rpx rgba(97, 97, 97, 0.1); // box-shadow: 0 0 10rpx rgba(97, 97, 97, 0.1);
} }
@ -313,8 +326,6 @@ onMounted(async () => {
} }
} }
.item_day { .item_day {
font-family: PingFangSC, PingFang SC; font-family: PingFangSC, PingFang SC;
font-weight: bold; font-weight: bold;
@ -324,7 +335,6 @@ onMounted(async () => {
font-style: normal; font-style: normal;
margin-top: -10rpx; margin-top: -10rpx;
margin-left: 10rpx; margin-left: 10rpx;
} }
.item_top { .item_top {
@ -341,25 +351,24 @@ onMounted(async () => {
.item_point { .item_point {
width: 12rpx; width: 12rpx;
height: 12rpx; height: 12rpx;
background: #EB5D46; background: #eb5d46;
border-radius: 100rpx; border-radius: 100rpx;
} }
.item_line { .item_line {
width: 1rpx; width: 1rpx;
height: 35rpx; height: 35rpx;
border-left: 2px dashed #D9D7D7; border-left: 2px dashed #d9d7d7;
} }
} }
.list_card { .list_card {
display: flex; display: flex;
height: 334rpx; // height: 334rpx;
background: #FFFFFF; background: #ffffff;
border-radius: 24rpx; border-radius: 24rpx;
padding: 20rpx 30rpx; padding: 20rpx 30rpx;
.card_left { .card_left {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -373,7 +382,7 @@ onMounted(async () => {
.left_line { .left_line {
width: 1rpx; width: 1rpx;
height: 100%; height: 100%;
border-left: 2px dashed #D9D7D7; border-left: 2px dashed #d9d7d7;
margin-top: 10rpx; margin-top: 10rpx;
} }
} }
@ -446,7 +455,7 @@ onMounted(async () => {
font-family: PingFangSC, PingFang SC; font-family: PingFangSC, PingFang SC;
font-weight: 400; font-weight: 400;
font-size: 24rpx; font-size: 24rpx;
color: #B3B3B3; color: #b3b3b3;
line-height: 33rpx; line-height: 33rpx;
text-align: left; text-align: left;
font-style: normal; font-style: normal;
@ -456,7 +465,7 @@ onMounted(async () => {
font-family: PingFangSC, PingFang SC; font-family: PingFangSC, PingFang SC;
font-weight: 400; font-weight: 400;
font-size: 24rpx; font-size: 24rpx;
color: #5978B2; color: #5978b2;
line-height: 33rpx; line-height: 33rpx;
text-align: left; text-align: left;
font-style: normal; font-style: normal;
@ -472,7 +481,7 @@ onMounted(async () => {
.item_etf_item { .item_etf_item {
// width: 168rpx; // width: 168rpx;
height: 48rpx; height: 48rpx;
background: #EDF1F5; background: #edf1f5;
border-radius: 125rpx; border-radius: 125rpx;
padding: 5rpx 25rpx; padding: 5rpx 25rpx;
display: flex; display: flex;