From df4dd9f030ac4e830d93f2f64e2379a9b7dad278 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 25 六月 2025 20:41:20 +0800
Subject: [PATCH] 自定义顶部组件、顶部tab对应页面接入该组件

---
 pages/commodity-square/commoditySquare.vue |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/pages/commodity-square/commoditySquare.vue b/pages/commodity-square/commoditySquare.vue
index d7c7fad..e83e4e5 100644
--- a/pages/commodity-square/commoditySquare.vue
+++ b/pages/commodity-square/commoditySquare.vue
@@ -1,5 +1,6 @@
 <template>
 	<view class="container">
+		<top-bar selectedTitleIndex="shop" @changeTab="topBarChange" class="topBar"></top-bar>
 		<input type="text" v-show="false" v-model="flushDom" />
 		<view class="search">
 			<u-search class="nav-search" @blur='searchGoods' placeholder="鎼滅储鍟嗗搧" :show-action="false"></u-search>
@@ -12,7 +13,7 @@
 						:controls="false" object-fit="contain" :show-play-btn="false" :show-center-play-btn="false"
 						@loadedmetadata="getvideoInfo($event,'goodsList1',index)" :ref="'video'+item.id"
 						:style="{width:item.width,height:item.height}"></video> -->
-					<image :src="item.thumbnail" 
+					<image :src="item.thumbnail"
 						mode="aspectFill" class="goodsImg">
 					</image>
 					<view class="goodsInfo">
@@ -31,7 +32,7 @@
 						:controls="false" object-fit="contain" :show-play-btn="false" :show-center-play-btn="false"
 						@loadedmetadata="getvideoInfo($event,'goodsList2',index)" :ref="'video'+item.id"
 						:style="{width:item.width,height:item.height}"></video> -->
-					<image :src="item.thumbnail" 
+					<image :src="item.thumbnail"
 						mode="aspectFill" class="goodsImg">
 					</image>
 					<view class="goodsInfo">
@@ -60,11 +61,11 @@
 		</view>
 		<view style="display: flex;align-items: center;justify-content: center;margin-top: 20rpx;" v-if="canLoadMore">
 			娌℃湁鏇村鏁版嵁浜�.................</view>
-		<custom-tabbar bgColor="#ffffff" selected="shop"></custom-tabbar>
 	</view>
 </template>
 
 <script>
+	import TopBar from "@/components/TopBar.vue";
 	import {
 		getCategoryList,
 		getGoodsList
@@ -73,6 +74,7 @@
 		getSTSToken
 	} from '@/api/common.js'
 	export default {
+		components: {TopBar},
 		data() {
 			return {
 				//璁板綍涓ゅ垪楂樺害
@@ -104,6 +106,17 @@
 			}
 		},
 		methods: {
+			topBarChange(titleObj) {
+				if (titleObj.index === 'home') {
+					uni.switchTab({
+						url: titleObj.pagePath
+					});
+				} else {
+					uni.redirectTo({
+						url: titleObj.pagePath
+					});
+				}
+			},
 			async searchGoods(keyWard) {
 				this.getGoodsParam.keyword = keyWard
 				this.getGoodsParam.pageNumber = 1
@@ -393,4 +406,10 @@
 		color: red;
 		font-weight: bold;
 	}
-</style>
\ No newline at end of file
+	.topBar {
+		position: fixed;
+		top: 20rpx;
+		left: 20rpx;
+		z-index: 1000
+	}
+</style>

--
Gitblit v1.8.0