cankao-h5/src/components/HotIndustryList.vue

225 lines
5.5 KiB
Vue
Raw Normal View History

2025-08-10 16:44:02 +08:00
<template>
<view class="hot-industry-container">
2025-08-13 11:53:14 +08:00
<u-skeleton rows="5" title loading style="margin-bottom: 30rpx" v-if="loading"></u-skeleton>
2025-08-10 16:44:02 +08:00
<!-- 行业列表 -->
<view class="industry-list" v-else>
2025-08-13 11:53:14 +08:00
<view v-for="(item, index) in industryList" :key="index" class="industry-item" :style="getItemBgStyle(index)"
@click="goDetail(item, index)">
2025-08-10 16:44:02 +08:00
<!-- 这里预留图标位置可自行补充 <image :src="item.icon" class="industry-icon" /> -->
2025-08-13 11:53:14 +08:00
<view style="
2025-08-10 16:44:02 +08:00
position: absolute;
top: 0;
z-index: 999;
display: flex;
align-items: center;
height: 100%;
2025-08-13 11:53:14 +08:00
">
<img src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/ranking_icon_1_1.png" class="top3numbk"
v-if="index < 3 && index == 0" />
<img src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/ranking_icon_2_2.png" class="top3numbk"
v-else-if="index < 3 && index == 1" />
<img src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/ranking_icon_3_3.png" class="top3numbk"
v-else-if="index < 3 && index == 2" />
2025-08-10 16:44:02 +08:00
<text class="rank" v-else>{{ index + 1 }}</text>
<text class="industry-name">{{ item.content }}</text>
</view>
2025-08-13 11:53:14 +08:00
<img src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/ranking_bg_1.png" class="top3bk"
v-if="index < 3 && index == 0" />
<img src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/ranking_bg_2.png" class="top3bk"
v-if="index < 3 && index == 1" />
<img src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/zixun/ranking_bg_3.png" class="top3bk"
v-if="index < 3 && index == 2" />
2025-08-10 16:44:02 +08:00
</view>
</view>
2025-08-13 11:53:14 +08:00
<LoginPopup :show="LoginShow" @handlePopupClose="handlePopupClose"
@handlePopupSuccessCallback="handlePopupSuccessCallback" @handlePopupErrorCallback="handlePopupErrorCallback" />
2025-08-10 16:44:02 +08:00
</view>
</template>
<script setup>
import { defineProps, defineEmits, watch, ref } from "vue";
import LoginPopup from "@/components/loginPopup/index.vue";
import { Session } from "@/utils/storage";
// 定义接收的行业列表数据 props每个元素包含 name 字段
const props = defineProps({
industryList: {
type: Array,
required: true,
default: () => [],
},
// 0:热门行业池 1风口概念池
type: {
type: String,
default: () => 0,
},
});
const loading = ref(true);
watch(
() => props.industryList,
(newValue, oldValue) => {
loading.value = false;
}
);
// 定义触发的事件,点击“查看全部”时通知父组件
const emit = defineEmits(["viewAll"]);
const onViewAll = () => {
emit("viewAll");
};
// 根据排名设置背景样式这里前3名可设置不同背景可根据实际需求调整
const getItemBgStyle = (index) => {
if (index === 0) {
return {
backgroundColor: "#fff",
filter: Session.get("token") ? "" : "blur(5px)",
}; // 第1名背景示例
} else if (index === 1) {
return {
backgroundColor: "#fff",
filter: Session.get("token") ? "" : "blur(5px)",
}; // 第2名背景示例
} else if (index === 2) {
return {
backgroundColor: "#fff",
filter: Session.get("token") ? "" : "blur(5px)",
}; // 第3名背景示例
}
return {
backgroundColor: "#F2F6FE",
filter: Session.get("token") ? "" : "blur(5px)",
}; // 其他名次背景
};
const clickItem = ref({});
const clickIndex = ref({});
function goDetail(item, index) {
clickItem.value = item;
clickIndex.value = index;
if (Session.get("token")) {
uni.navigateTo({
url:
"/pages/realtimeInfo/rankDetail?value=" +
item.value +
"&type=" +
props.type +
"&index=" +
index,
});
} else {
LoginShow.value = true;
}
}
const LoginShow = ref(false);
const isLoginStatus = ref();
// 关闭弹框
const handlePopupClose = () => {
LoginShow.value = false;
};
// 登录成功之后的回调
const handlePopupSuccessCallback = () => {
isLoginStatus.value = true;
// uni.navigateTo({
// url:
// "/pages/realtimeInfo/rankDetail?value=" +
// clickItem.value.value +
// "&type=" +
// props.type +
// "&index=" +
// clickIndex.value,
// });
};
// 登录失败之后的回调
const handlePopupErrorCallback = () => {
console.log("登录失败");
};
</script>
<style scoped>
.hot-industry-container {
padding: 10px;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.title {
font-size: 16px;
font-weight: bold;
color: #333;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.view-all {
font-size: 14px;
color: #999;
text-decoration: underline;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.industry-list {
display: flex;
flex-direction: column;
gap: 8px;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.industry-item {
display: flex;
align-items: center;
border-radius: 6px;
position: relative;
height: 74rpx;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.industry-icon {
width: 24px;
height: 24px;
margin-right: 8px;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.rank {
margin-left: 30rpx;
font-family: PingFangSC, PingFang SC;
font-weight: 500;
font-size: 30rpx;
color: #868b98;
line-height: 42rpx;
text-align: left;
font-style: normal;
margin-right: 40rpx;
}
2025-08-13 11:53:14 +08:00
2025-08-10 16:44:02 +08:00
.industry-name {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 28rpx;
color: #222222;
line-height: 40rpx;
text-align: left;
font-style: normal;
}
.top3bk {
width: 100%;
height: 74rpx;
}
.top3numbk {
width: 42rpx;
height: 50rpx;
margin-right: 25rpx;
margin-left: 20rpx;
}
</style>