hookehuyr

feat: 添加搜索弹窗组件并修改首页搜索交互

实现搜索弹窗组件,包含搜索框、筛选条件和结果展示功能
修改首页搜索框交互,点击后显示搜索弹窗而非跳转页面
...@@ -39,6 +39,7 @@ declare module 'vue' { ...@@ -39,6 +39,7 @@ declare module 'vue' {
39 PosterBuilder: typeof import('./src/components/PosterBuilder/index.vue')['default'] 39 PosterBuilder: typeof import('./src/components/PosterBuilder/index.vue')['default']
40 RouterLink: typeof import('vue-router')['RouterLink'] 40 RouterLink: typeof import('vue-router')['RouterLink']
41 RouterView: typeof import('vue-router')['RouterView'] 41 RouterView: typeof import('vue-router')['RouterView']
42 + SearchPopup: typeof import('./src/components/SearchPopup.vue')['default']
42 TabBar: typeof import('./src/components/TabBar.vue')['default'] 43 TabBar: typeof import('./src/components/TabBar.vue')['default']
43 } 44 }
44 } 45 }
......
1 +/* 搜索弹窗样式 */
2 +.search-page {
3 + background-color: #f5f5f5;
4 + min-height: 100vh;
5 +}
6 +
7 +/* 搜索头部固定定位 */
8 +.search-header {
9 + position: fixed;
10 + top: 0;
11 + left: 0;
12 + right: 0;
13 + z-index: 1000;
14 + background-color: #fff;
15 +}
16 +
17 +/* 搜索内容区域 */
18 +.search-content {
19 + margin-top: 200rpx; /* 为固定头部预留空间 */
20 +}
21 +
22 +/* 搜索结果列表样式 */
23 +.search-results-list {
24 + width: 100%;
25 + box-sizing: border-box;
26 +
27 + /* 滚动条样式 */
28 + &::-webkit-scrollbar {
29 + width: 6rpx;
30 + }
31 +
32 + &::-webkit-scrollbar-track {
33 + background: #f1f1f1;
34 + border-radius: 3rpx;
35 + }
36 +
37 + &::-webkit-scrollbar-thumb {
38 + background: #c1c1c1;
39 + border-radius: 3rpx;
40 +
41 + &:hover {
42 + background: #a8a8a8;
43 + }
44 + }
45 +}
46 +
47 +/* 加载状态样式 */
48 +.load-more-container {
49 + padding: 40rpx 0;
50 +
51 + .loading-container {
52 + display: flex;
53 + align-items: center;
54 + justify-content: center;
55 + color: #666;
56 +
57 + .loading-spinner {
58 + width: 32rpx;
59 + height: 32rpx;
60 + border: 4rpx solid #f3f3f3;
61 + border-top: 4rpx solid #f97316;
62 + border-radius: 50%;
63 + animation: spin 1s linear infinite;
64 + margin-right: 16rpx;
65 + }
66 +
67 + .loading-text {
68 + font-size: 28rpx;
69 + color: #666;
70 + }
71 + }
72 +
73 + .no-more-data {
74 + padding: 20rpx 0;
75 + text-align: center;
76 + color: #999;
77 + font-size: 28rpx;
78 + }
79 +}
80 +
81 +/* 旋转动画 */
82 +@keyframes spin {
83 + 0% { transform: rotate(0deg); }
84 + 100% { transform: rotate(360deg); }
85 +}
86 +
87 +/* 空状态样式 */
88 +.empty-state {
89 + .empty-icon {
90 + display: flex;
91 + justify-content: center;
92 + align-items: center;
93 + opacity: 0.6;
94 + }
95 +}
96 +
97 +.no-results-state {
98 + .no-results-icon {
99 + display: flex;
100 + justify-content: center;
101 + align-items: center;
102 + opacity: 0.7;
103 + }
104 +}
105 +
106 +/* 搜索结果卡片样式优化 */
107 +.search-results-list {
108 + .grid {
109 + .bg-white {
110 + transition: all 0.3s ease;
111 + border: 1rpx solid #e5e7eb;
112 +
113 + &:hover {
114 + box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
115 + transform: translateY(-2rpx);
116 + }
117 + }
118 + }
119 +}
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 <!-- 1 <!--
2 * @Date: 2025-06-28 10:33:00 2 * @Date: 2025-06-28 10:33:00
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-07-04 15:20:58 4 + * @LastEditTime: 2025-07-04 16:04:15
5 * @FilePath: /jgdl/src/pages/index/index.vue 5 * @FilePath: /jgdl/src/pages/index/index.vue
6 * @Description: 捡个电驴首页 6 * @Description: 捡个电驴首页
7 --> 7 -->
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 </nut-col> 16 </nut-col>
17 <nut-col span="18"> 17 <nut-col span="18">
18 <!-- Search Bar --> 18 <!-- Search Bar -->
19 - <nut-searchbar v-model="searchValue" placeholder="搜索更多商品" @focus="onFocusSearch" shape="round" background="transparent" input-background="#ffffff"> 19 + <nut-searchbar v-model="searchValue" placeholder="搜索更多商品" :disabled="true" @click-input="onSearchHandle" shape="round" background="transparent" input-background="#ffffff">
20 <template #leftin> 20 <template #leftin>
21 <Search2 /> 21 <Search2 />
22 </template> 22 </template>
...@@ -153,6 +153,9 @@ ...@@ -153,6 +153,9 @@
153 153
154 <!-- 自定义TabBar --> 154 <!-- 自定义TabBar -->
155 <TabBar /> 155 <TabBar />
156 +
157 + <!-- 搜索弹窗 -->
158 + <SearchPopup v-model:visible="showSearchPopup" />
156 </view> 159 </view>
157 </template> 160 </template>
158 161
...@@ -163,17 +166,17 @@ import { ref, onMounted } from 'vue' ...@@ -163,17 +166,17 @@ import { ref, onMounted } from 'vue'
163 import { useDidShow, useReady } from '@tarojs/taro' 166 import { useDidShow, useReady } from '@tarojs/taro'
164 import { Clock, Star, RectRight, Check, Search2, Shop, Heart1, HeartFill } from '@nutui/icons-vue-taro' 167 import { Clock, Star, RectRight, Check, Search2, Shop, Heart1, HeartFill } from '@nutui/icons-vue-taro'
165 import TabBar from '@/components/TabBar.vue' 168 import TabBar from '@/components/TabBar.vue'
169 +import SearchPopup from '@/components/SearchPopup.vue'
166 import "./index.less"; 170 import "./index.less";
167 171
168 // 响应式数据 172 // 响应式数据
169 const searchValue = ref('') 173 const searchValue = ref('')
170 const favoriteIds = ref([]) 174 const favoriteIds = ref([])
175 +const showSearchPopup = ref(false)
171 176
172 -const onFocusSearch = () => { 177 +const onSearchHandle = () => {
173 - // 跳转到搜索页面 178 + // 显示搜索弹窗
174 - Taro.navigateTo({ 179 + showSearchPopup.value = true
175 - url: '/pages/search/index'
176 - })
177 } 180 }
178 181
179 // Banner图片 182 // Banner图片
......