cankao-h5/src/pages/realtimeInfo/components/ConceptNewsView/index.vue

165 lines
3.5 KiB
Vue
Raw Normal View History

2026-01-28 15:09:58 +08:00
<template>
<view class="hot-section">
<view class="hot-top" @click="navigateTo">
2026-01-28 15:09:58 +08:00
<view class="title">风口概念</view>
<view class="time">近一个月热门</view>
</view>
<view class="tag-box">
<view v-for="(item, index) in topConceptList" :key="index" class="tag">
{{ item.content.split("-")[1] }}
</view>
2026-01-28 15:09:58 +08:00
</view>
<view class="tag-content">
<view class="content" @click="goDetail(oneData)">{{ oneData?.title }} </view>
2026-01-28 15:09:58 +08:00
</view>
</view>
</template>
<script setup lang="ts">
import { getListByTag } from "@/api/detail";
import { getTopConceptPeriod } from "@/api/newsInfo";
import { useUserStore } from "@/stores/user";
import dayjs from "dayjs";
import { computed, onMounted, ref } from "vue";
const emit = defineEmits(["onShow"]);
const active = ref(0);
const topConceptList = ref([]);
const oneData = ref({});
const userStore = useUserStore();
const start_time = dayjs().subtract(1, "month").format("YYYY-MM-DD");
const end_time = dayjs().format("YYYY-MM-DD");
const limit_num = 4;
// 热门行业top10
async function getTopConcept_dFn() {
topConceptList.value = await getTopConceptPeriod({
start_time: start_time,
end_time: end_time,
limit_num: limit_num,
});
}
async function getList() {
const name = topConceptList.value[active.value].content;
// 概念标签
let { code, data } = await getListByTag({ name });
if (code == 200) {
oneData.value = data[0];
}
}
// 跳转详情
function goDetail(item: any) {
if (!userStore.isLogin) {
emit("onShow");
return;
}
uni.navigateTo({
url: `/pages/detail/indexNewsInfo?id=${item.id}`,
});
}
// 跳转子页
function navigateTo() {
if (!userStore.isLogin) {
emit("onShow");
return;
}
// 试用账号
if (!userStore.isUserType) {
uni.showToast({
title: "暂未开通本栏目",
icon: "none",
});
return;
}
uni.navigateTo({
url: `/pages/industry/index`,
});
}
onMounted(async () => {
// 热门行业top10
await getTopConcept_dFn();
await getList();
});
2026-01-28 15:09:58 +08:00
</script>
<style scoped lang="scss">
.hot-section {
width: 710rpx;
height: 257rpx;
margin: 0 20rpx 20rpx;
padding: 30rpx 30rpx 0 30rpx;
background-image: url("@/assets/images/page/5_pic@2x.png");
background-repeat: no-repeat;
background-size: 100% auto;
box-sizing: border-box;
}
.hot-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
.title {
font-family: "AlimamaShuHeiTi, AlimamaShuHeiTi";
font-weight: bold;
font-size: 32rpx;
color: #111111;
line-height: 45rpx;
}
.time {
font-family: "PingFangSC, PingFang SC";
font-weight: 400;
font-size: 24rpx;
color: #666666;
line-height: 33rpx;
}
}
.tag-box {
display: flex;
align-items: center;
gap: 10rpx;
margin-bottom: 20rpx;
.tag {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 2rpx 8rpx;
border-radius: 4rpx;
border: 1px solid #bb875d;
font-size: 22rpx;
color: #c18252;
line-height: 30rpx;
text-align: left;
font-style: normal;
}
}
.tag-content {
width: 100%;
.content {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
font-family: "PingFangSC, PingFang SC";
font-weight: 500;
font-size: 28rpx;
color: #111111;
line-height: 40rpx;
}
}
</style>