Compare commits
2 Commits
9a92705f4b
...
182ebd0e17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
182ebd0e17 | ||
|
|
50a0cf1e2e |
@ -1,58 +1,180 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
function createHotItemBox(data = {}) {
|
// 使用更清晰的类型定义
|
||||||
return {
|
// const hotItem = {
|
||||||
num: data.num || 1,
|
// num: 1,
|
||||||
title: data.title || '',
|
// title: '外卖员吐槽殡仪馆深夜有人点外卖,警方已介入,这是真实订单还是恶作剧?平台如何平衡配送要求与骑手心理安全?',
|
||||||
content: data.content || '',
|
// content: '6 月 25 日,一位外卖小哥吐槽殡仪馆员工深夜点外卖的视频引发网友热议...',
|
||||||
imgUrl: data.imgUrl || '',
|
// imgUrl: 'https://pic4.zhimg.com/50/v2-2fe83b271083fa4fa2db251931dea8fd_400x224.jpg',
|
||||||
hotValue: data.hotValue || 0
|
// url: '#', // 添加默认链接
|
||||||
}
|
// hotValue: 200,
|
||||||
}
|
// isNew: true
|
||||||
|
// }
|
||||||
|
|
||||||
var hotItemBox = createHotItemBox({
|
// 或者使用响应式数据
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const hotItemBox = ref({
|
||||||
num: 1,
|
num: 1,
|
||||||
title: 'test',
|
title:
|
||||||
content: 'test content',
|
'外卖员吐槽殡仪馆深夜有人点外卖,警方已介入,这是真实订单还是恶作剧?平台如何平衡配送要求与骑手心理安全?',
|
||||||
imgUrl: 'test img url',
|
content: '6 月 25 日,一位外卖小哥吐槽殡仪馆员工深夜点外卖的视频引发网友热议...',
|
||||||
hotValue: 200
|
imgUrl: 'https://pic4.zhimg.com/50/v2-2fe83b271083fa4fa2db251931dea8fd_400x224.jpg',
|
||||||
|
link: '#', // 添加默认链接
|
||||||
|
hotValue: 200,
|
||||||
|
isNew: true
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="hot-item-box">
|
<div id="hot-item">
|
||||||
<div id="hot-item-header">
|
<div id="hot-item-header">
|
||||||
<span>{{ hotItemBox.num }}</span>
|
<div class="hot-item-rank" :class="{ 'hot-item-hot': hotItemBox.num < 3 }">
|
||||||
|
{{ hotItemBox.num }}
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="hot-item-label"
|
||||||
|
v-if="hotItemBox.isNew"
|
||||||
|
style="background-color: rgb(255, 150, 7)"
|
||||||
|
>
|
||||||
|
新
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="hot-item-body">
|
<div id="hot-item-body">
|
||||||
<h1>{{ hotItemBox.title }}</h1>
|
<a :href="hotItemBox.link" :title="hotItemBox.title" target="_blank"
|
||||||
<div id="content">{{ hotItemBox.content }}</div>
|
><h1>{{ hotItemBox.title }}</h1></a
|
||||||
<div id="ext">
|
>
|
||||||
<span>✨{{ hotItemBox.hotValue }}</span>
|
<a :href="hotItemBox.link" :title="hotItemBox.title" target="_blank">
|
||||||
<span>✈分享</span>
|
<div class="content">{{ hotItemBox.content }}</div>
|
||||||
|
</a>
|
||||||
|
<div class="ext">
|
||||||
|
<span>✨{{ hotItemBox.hotValue }}热度</span>
|
||||||
|
<span><button>✈分享</button></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="hot-item-footer">
|
<a class="hot-item-img" :href="hotItemBox.link" :title="hotItemBox.title" target="_blank"
|
||||||
<img :src="hotItemBox.imgUrl" alt="测试" />
|
><img :src="hotItemBox.imgUrl" alt="测试"
|
||||||
</div>
|
/></a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
#hot-item-box {
|
#hot-item {
|
||||||
width: 600px;
|
width: 600px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
border: solid 1px red;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 16px 0;
|
padding: 16px 0;
|
||||||
|
box-shadow:
|
||||||
|
0 -1px 0 0 rgba(0, 0, 0, 0.1),
|
||||||
|
/* 上方阴影 */ 0 1px 0 0 rgba(0, 0, 0, 0.1); /* 下方阴影 */
|
||||||
|
border: none; /* 去除默认边框 */
|
||||||
}
|
}
|
||||||
|
|
||||||
#hot-item-header {
|
#hot-item-header {
|
||||||
width: 10%;
|
margin-right: 24px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
.hot-item-rank {
|
||||||
|
color: #9196a1;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.6;
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hot-item-hot {
|
||||||
|
color: #f77a31;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hot-item-label {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 16px;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
color: #ffffff;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#hot-item-body {
|
#hot-item-body {
|
||||||
width: 60%;
|
flex: 1;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
width: 100%;
|
||||||
|
display: -webkit-box;
|
||||||
|
line-clamp: 2;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: black;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
width: 100%;
|
||||||
|
display: -webkit-box;
|
||||||
|
line-clamp: 1;
|
||||||
|
-webkit-line-clamp: 1;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ext {
|
||||||
|
line-height: 24px;
|
||||||
|
height: 24px;
|
||||||
|
margin-top: 6px;
|
||||||
|
position: absolute;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
span {
|
||||||
|
display: block;
|
||||||
|
width: 100px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
display: block;
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#hot-item-footer {
|
|
||||||
width: 30%;
|
.hot-item-img {
|
||||||
|
margin-left: 16px;
|
||||||
|
height: 105px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
height: 105px;
|
||||||
|
width: 190px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hot-item-img:after {
|
||||||
|
content: ''; /* 必须设置 content */
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(25, 27, 31, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
#hot-item-footer img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -4,6 +4,10 @@ import HotItemBox from '@/components/HotItemBox.vue'
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<HotItemBox />
|
<HotItemBox />
|
||||||
|
<HotItemBox />
|
||||||
|
<HotItemBox />
|
||||||
|
<HotItemBox />
|
||||||
|
<HotItemBox />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user