feat(新闻信息): 添加日期选择功能并更新API

在新闻信息页面添加日期选择器组件,允许用户选择日期查询新闻
新增getTopNewsAllRelease API接口,支持按日期查询新闻数据
更新页面样式和交互逻辑以支持日期选择功能
This commit is contained in:
zzp 2026-01-31 11:25:58 +08:00
parent a00988529d
commit 455aa810c2
2 changed files with 77 additions and 6 deletions

View File

@ -29,6 +29,12 @@ export const getTopNews = (data: any) => {
// 概念标签贴标
export const getTopNewsAll = (data: any) => {
return request.get("/top_news_release_h5_all", data);
// return request.get("/news_release_ratingrank_h5_d", data);
};
// 概念标签贴标 release
export const getTopNewsAllRelease = (data: any) => {
return request.get("/news_release_ratingrank_h5_d?input_date=" + data.input_date + "&limit_num=10");
};
// 热门行业top10

View File

@ -79,6 +79,7 @@
<view style="background-color: white; padding-top: 40rpx">
<view style="width: 100vw; display: flex; justify-content: space-between; align-items: center">
<indexMenuTitle title="编辑精选" style="margin-top: 10rpx"></indexMenuTitle>
<view class="r_sreach">
<!-- <image class="top_bk" src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/top_bg.png"></image> -->
<!-- <image class="logo_text" src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/logo_text_icon.png"> </image> -->
@ -93,11 +94,31 @@
</view>
</view>
<view style="width: 100%; display: flex; justify-content: flex-end">
<view style="display: flex; align-items: center; margin-right: 15rpx; font-size: 30rpx; gap: 10rpx; margin-top: 10rpx" @click="showCalendar">
{{ chooseDate.startDate.split(" ")[0] }}
<u-icon name="calendar" size="26" style="margin-right: 10rpx"></u-icon>
</view>
</view>
<RankList hasTag :newsList="newsList" :needExp="false"></RankList>
</view>
<view class="logout" @click="loginOut" v-if="Session.get('token')">退出登录</view>
<u-calendar
:show="calendarShow"
min-date="2025-01-01"
closeOnClickOverlay
:max-date="maxDate"
:default-date="chooseDate.startDate"
monthNum="12"
:key="chooseDate.startDate"
@confirm="calendarConfirm"
@close="calendarShow = false"
>
</u-calendar>
<LoginPopup
:show="LoginShow"
@handlePopupClose="handlePopupClose"
@ -133,6 +154,7 @@ import {
getTopConceptPeriod,
getTopIndustryPeriod,
getTopSourcePeriod,
getTopNewsAllRelease,
} from "@/api/newsInfo";
import countTo from "@/components/count-to/vue-countTo.vue";
import RankList from "@/components/RankList.vue"; //
@ -157,6 +179,35 @@ const handleViewAll = () => {
const topNum = ref({});
const d = new Date();
const year = d.getFullYear();
let month = d.getMonth() + 1;
month = month < 10 ? `0${month}` : month;
const date = d.getDate();
const maxDate = ref(`${year}-${month}-${date} 23:59:59`);
const minDate = ref(`${year}-${month}-${date}`);
const calendarShow = ref(false);
const chooseDate = reactive({
startDate: `${year}-${month}-${date}`,
endDate: null,
});
function showCalendar() {
calendarShow.value = true;
}
function calendarConfirm(dateList) {
console.log("🚀 ~ calendarConfirm ~ dateList:", dateList);
if (dateList && dateList.length > 0) {
chooseDate.startDate = dateList[0] + " 00:00:00";
chooseDate.endDate = dateList[dateList.length - 1] + " 23:59:59";
}
getNewsList();
calendarShow.value = false;
console.log("🚀 ~ calendarConfirm ~ chooseDate:", chooseDate);
}
//
async function getTopNum() {
let res1 = await getindustryCount({});
@ -170,7 +221,11 @@ async function getTopNum() {
//
async function getNewsList() {
newsList.value = await getTopNewsAll({});
console.log(`🚀 ~ getNewsList ~ chooseDate.startDate.split(" ")[0]:`, chooseDate.startDate.split(" ")[0]);
newsList.value = await getTopNewsAllRelease({
input_date: chooseDate.startDate.split(" ")[0],
});
}
// top10
@ -350,7 +405,9 @@ onMounted(async () => {
}
text {
font-family: PingFangSC, PingFang SC;
font-family:
PingFangSC,
PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.8);
@ -393,7 +450,9 @@ onMounted(async () => {
}
.tag_title {
font-family: PingFangSC, PingFang SC;
font-family:
PingFangSC,
PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: #222222;
@ -401,7 +460,9 @@ onMounted(async () => {
}
.tag_num {
font-family: PingFangSC, PingFang SC;
font-family:
PingFangSC,
PingFang SC;
font-weight: bold;
font-size: 38rpx;
color: #222222;
@ -409,7 +470,9 @@ onMounted(async () => {
}
.tag_status {
font-family: PingFangSC, PingFang SC;
font-family:
PingFangSC,
PingFang SC;
font-weight: 400;
font-size: 22rpx;
color: #999999;
@ -532,7 +595,9 @@ onMounted(async () => {
}
.sreach_text {
font-family: PingFangSC, PingFang SC;
font-family:
PingFangSC,
PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: #999999;