<template>
|
<view class="search-page">
|
<!-- 搜索框 -->
|
<view class="search-bar">
|
<up-search v-model="searchValue" placeholder="新疆本地小团" show-action @search="onSearch" />
|
</view>
|
|
<!-- 历史记录 -->
|
<view class="section">
|
<view class="section-title">
|
<text>历史记录</text>
|
<up-icon name="trash" size="20" @click="onClearHistory" class="delete-icon" />
|
|
</view>
|
<view class="tag-list">
|
<up-tag v-for="(item, index) in historyTags" :key="index" plain size="mini" class="tag" shape="circle"
|
borderColor="#E9E9E9" color="#333333" textSize="20rpx">{{ item }}</up-tag>
|
</view>
|
</view>
|
|
<!-- 猜你想搜 -->
|
<view class="section">
|
<view class="section-title">
|
<text>猜你想搜</text>
|
<view class="icon-list">
|
<up-icon name="reload" size="20" @click="onClearHistory" />
|
<up-icon name="more-dot-fill" size="20" @click="onClearHistory" />
|
</view>
|
</view>
|
<view class="suggest-list">
|
<view class="suggest-column">
|
<text v-for="(item, index) in guessList.filter((_, i) => i % 2 === 0)" :key="'left-' + index"
|
class="suggest">
|
{{ item }}
|
</text>
|
</view>
|
<view class="suggest-column">
|
<text v-for="(item, index) in guessList.filter((_, i) => i % 2 === 1)" :key="'right-' + index"
|
class="suggest">
|
{{ item }}
|
</text>
|
</view>
|
</view>
|
</view>
|
|
<!-- 热门榜单 -->
|
<view class="section">
|
<view class="section-title hot-title">
|
🔥 热点
|
</view>
|
<view class="hot-list">
|
<view v-for="(item, index) in hotList" :key="index" class="hot-item">
|
<view>
|
<text class="hot-index" :class="[
|
index === 0 ? 'gradient-red' :
|
index === 1 ? 'gradient-orange' :
|
index === 2 ? 'gradient-yellow' : ''
|
]">{{ index + 1 }}</text>
|
<text class="hot-text">{{ item.title }}</text>
|
<up-tag v-if="item.tag"
|
:type="item.tag === '热' ? 'error' : item.tag === '荐' ? 'warning' : 'primary'" size="mini"
|
class="tag">
|
{{ item.tag }}
|
</up-tag>
|
</view>
|
<text class="hot-views">{{ item.views }}</text>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script setup lang="ts">
|
import { ref } from 'vue'
|
import { onShow, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
|
|
const searchValue = ref('')
|
|
const historyTags = ref<string[]>([
|
'新疆靠谱旅行社', '重庆往返乌鲁木齐', '旅游行程安排文案', '旅游行程安排表'
|
])
|
|
|
const guessList = [
|
'新疆本地小团', '旺旺就是朱旺旺离职',
|
'新疆北疆路线攻略', '职称评审'
|
]
|
|
const hotList = [
|
{ title: '在最穷的时候遇上了最想买的皮肤', tag: '热', views: '922.3万' },
|
{ title: '陈奕迅辟谣去世传闻后首露面', views: '716万' },
|
{ title: '你不认识我们但一定见过我们画的猫', tag: '荐', views: '683.1万' },
|
{ title: '迪丽热巴 蓝玫瑰油画妆', tag: '热', views: '664.9万' },
|
{ title: '起猛了看到小狗的朋友圈了', views: '653万' },
|
{ title: '藏海传让我来演', tag: '荐', views: '652.9万' },
|
{ title: '郑晓龙拍戏 眼泪往上擦', tag: '热', views: '648万' },
|
{ title: '我的小红书被小乔包围了', tag: '独家', views: '612.3万' },
|
{ title: '小米15周年新品发布会', views: '605.5万' },
|
{ title: '你可能不认识汪 but 一定看过汪', tag: '荐', views: '603.5万' }
|
]
|
|
function onSearch(val: string) {
|
console.log('搜索内容:', val)
|
}
|
|
function onClearHistory() {
|
console.log('清除历史记录')
|
// 这里可以清空 historyTags 或调用实际删除逻辑
|
historyTags.value.length = 0
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
.search-page {
|
padding: 20rpx;
|
|
.search-bar {
|
margin-bottom: 20rpx;
|
}
|
|
.section {
|
margin-top: 30rpx;
|
|
.section-title {
|
font-size: 28rpx;
|
font-weight: bold;
|
margin-bottom: 16rpx;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
|
.delete-icon {
|
color: #999;
|
}
|
|
.icon-list {
|
display: flex;
|
gap: 10rpx;
|
}
|
}
|
|
.hot-title {
|
color: #f43f3b;
|
}
|
|
.tag-list {
|
display: flex;
|
flex-wrap: wrap;
|
gap: 10rpx;
|
|
.tag {
|
padding: 6rpx 20rpx;
|
}
|
}
|
|
.suggest-list {
|
display: flex;
|
flex-direction: row;
|
justify-content: space-between;
|
padding: 0 20rpx;
|
|
.suggest-column {
|
display: flex;
|
flex-direction: column;
|
gap: 20rpx; // 每行间距
|
|
.suggest {
|
font-size: 28rpx;
|
color: #333;
|
}
|
}
|
}
|
|
.hot-list {
|
.hot-item {
|
display: flex;
|
align-items: center;
|
margin-bottom: 20rpx;
|
justify-content: space-between;
|
|
|
.hot-index {
|
font-size: 30rpx;
|
font-weight: bold;
|
width: 40rpx;
|
}
|
|
.hot-text {
|
font-weight: bold;
|
font-size: 28rpx;
|
margin-left: 10rpx;
|
max-width: 400rpx;
|
display: inline-block;
|
vertical-align: middle;
|
white-space: nowrap;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
}
|
|
.gradient-red {
|
background: linear-gradient(to right, #f43f5e, #fb7185);
|
-webkit-background-clip: text;
|
color: transparent;
|
}
|
|
.gradient-orange {
|
background: linear-gradient(to right, #f97316, #facc15);
|
-webkit-background-clip: text;
|
color: transparent;
|
}
|
|
.gradient-yellow {
|
background: linear-gradient(to right, #fcd34d, #fde68a);
|
-webkit-background-clip: text;
|
color: transparent;
|
}
|
|
.tag {
|
margin-left: 10rpx;
|
}
|
|
.hot-views {
|
margin-left: 10rpx;
|
font-size: 24rpx;
|
color: #999;
|
}
|
}
|
}
|
}
|
}
|
</style>
|