This commit is contained in:
1173117610@qq.com 2026-05-11 17:07:29 +08:00
parent 42e810ac21
commit eca0cef97e
2 changed files with 24 additions and 13 deletions

View File

@ -3,9 +3,9 @@
<!-- 头部搜索与导航 -->
<view class="header">
<view class="search-section">
<view class="search-bar-wrap">
<view class="search-bar-wrap" @click="goSearch">
<text class="search-icon">🔍</text>
<input class="search-input" placeholder="输入关键词或粘贴商品标题" placeholder-class="placeholder-style" />
<text class="search-input" style="color: #999;">输入关键词或粘贴商品标题</text>
<view class="search-btn-red">搜索</view>
</view>
<image class="search-right-ad" src="https://img.bc.haodanku.com/cms_web/1651735687" mode="aspectFit"></image>
@ -334,6 +334,11 @@
}
},
methods: {
goSearch() {
uni.navigateTo({
url: '/pages/search/search'
});
},
getIndexData() {
uni.request({
url: 'https://api.cmspro.haodanku.com/index/index?cid=qOstW90',

View File

@ -7,10 +7,10 @@
<view class="back-btn" @click="goBack" hover-class="back-btn-hover">
<text class="back-arrow"></text>
</view>
<view class="search-input-wrap">
<view class="search-input-wrap" @click="onInputFocus">
<text class="search-icon">🔍</text>
<input class="search-input" type="text" v-model="keyword" placeholder="输入关键词或粘贴商品标题"
confirm-type="search" @confirm="onSearch(keyword)" :focus="true" />
confirm-type="search" @confirm="onSearch(keyword)" @focus="onInputFocus" :focus="true" />
</view>
<view class="search-btn-red" @click="onSearch(keyword)">搜索</view>
</view>
@ -156,7 +156,7 @@
<text class="card-sub">热点资讯</text>
</view>
<view class="topic-list">
<view class="topic-item" v-for="(item, index) in hotThemes" :key="index">
<view class="topic-item" v-for="(item, index) in hotThemes" :key="index" @click="onTopicClick(item)">
<view class="topic-num" :class="'num-' + (index + 1)">{{ index + 1 }}</view>
<text class="topic-title">{{ item.title }}</text>
</view>
@ -204,14 +204,6 @@
}
},
watch: {
keyword(val) {
//
if (!val) {
this.isSearching = false;
this.searchResults = [];
this.currentKeyword = '';
}
},
activePlatform() {
//
if (this.isSearching && this.currentKeyword) {
@ -277,6 +269,12 @@
}
});
},
onInputFocus() {
//
if (this.isSearching) {
this.isSearching = false;
}
},
onSearch(word) {
if (!word || !word.trim()) {
uni.showToast({ title: '请输入搜索内容', icon: 'none' });
@ -396,6 +394,14 @@
url: `/pages/detail/detail?id=${id}`
});
},
onTopicClick(item) {
// link category_id category cat_id
const categoryId = item.link;
if (!categoryId) return;
uni.navigateTo({
url: `/pages/category/category?cat_id=${categoryId}`
});
},
clearHistory() {
uni.showModal({
title: '提示',