فهرست منبع

feat: 首页banner上方增加搜索框,点击跳转全部活动并展示搜索结果

Developer 1 هفته پیش
والد
کامیت
42ae2b7c5c
3فایلهای تغییر یافته به همراه37 افزوده شده و 4 حذف شده
  1. 13 0
      pages/home.vue
  2. 10 0
      pagesHome/allActivity.vue
  3. 14 4
      pagesHome/searchActivity.vue

+ 13 - 0
pages/home.vue

@@ -9,6 +9,9 @@
 		</up-navbar>
 		<image src="https://oss.familydaf.cn/sxsnfile/20251218/ee40161fef4647f0b736d118e554dc2f.png" class="top_bg_img" mode="widthFix"></image>
 		<view class="c-box adffc">
+				<view class="c-box-search" @click="toSearch">
+				<cus-search></cus-search>
+			</view>
 			<view class="c-box-lunbo">
 				<up-swiper
 					:list="bannarList"
@@ -61,6 +64,7 @@
 
 <script setup name="">
 	import CusTabbar from '@/components/CusTabbar/index.vue'
+	import CusSearch from '@/components/CusSearch/index.vue'
 	import NonprofitActivety from '@/components/pages/nonprofitActivety/index.vue'
 	import PageEmpty from '@/components/pageEmpty/index.vue'
 	import { ref, getCurrentInstance, onMounted, nextTick, watch } from 'vue'
@@ -125,6 +129,10 @@
 		userId:''
 	})
 	
+	const toSearch = () => {
+		uni.navigateTo({ url: '/pagesHome/searchActivity?from=home' })
+	}
+
 	const bannerClick = e => {
 		let banner = bannarOrigin.value[e];
 		if(banner&&banner?.redirect){
@@ -295,6 +303,11 @@
 			height: 100%;
 			overflow-y: auto;
 			position: relative;
+			&-search{
+				width: 100%;
+				padding: 20rpx 30rpx 0;
+				box-sizing: border-box;
+			}
 			&-lunbo{
 				width: 100%;
 				height: 326rpx;

+ 10 - 0
pagesHome/allActivity.vue

@@ -83,7 +83,17 @@
 	import ActivityArea from '@/components/pages/activityArea/index.vue'
 	import PageEmpty from '@/components/pageEmpty/index.vue'
 	import { ref, onMounted, nextTick, getCurrentInstance, watch } from 'vue'
+	import { onLoad } from '@dcloudio/uni-app'
 	const { proxy } = getCurrentInstance()
+
+	onLoad(options => {
+		if (options?.keyword) {
+			const kw = decodeURIComponent(options.keyword)
+			queryParams.value.activityName = kw
+			nextTick(() => { if(proxy.$refs.searchRef) proxy.$refs.searchRef.keyword = kw })
+			getActivityList()
+		}
+	})
 	import { useUserStore } from '@/common/stores/user';
 	const userStore = useUserStore();
 	

+ 14 - 4
pagesHome/searchActivity.vue

@@ -16,11 +16,17 @@
 	import CusHeader from '@/components/CusHeader/index.vue'
 	import CusSearch from '@/components/CusSearch/index.vue'
 	import { ref, getCurrentInstance, onMounted } from 'vue'
+	import { onLoad } from '@dcloudio/uni-app'
 	const { proxy } = getCurrentInstance()
-	
+
 	const list = ref([])
 	const queryText = ref('')
-	
+	const fromHome = ref(false)
+
+	onLoad(options => {
+		if (options?.from === 'home') fromHome.value = true
+	})
+
 	const handleSearch = data => {
 		let sh = uni.getStorageSync('searchHistory');
 		try{
@@ -31,8 +37,12 @@
 		}catch(e){
 			console.log(e,'e');
 		}	
-		proxy.getOpenerEventChannel().emit('confirmSearch',data)
-		uni.navigateBack();
+		if (fromHome.value) {
+			uni.redirectTo({ url: '/pagesHome/allActivity?keyword=' + encodeURIComponent(data) })
+		} else {
+			proxy.getOpenerEventChannel().emit('confirmSearch', data)
+			uni.navigateBack();
+		}
 	}
 	
 	const getSearchHistory = () => {