This commit is contained in:
parent
42e810ac21
commit
eca0cef97e
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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: '提示',
|
||||
|
|
|
|||
Loading…
Reference in New Issue