Browse Source

修复商品详情闪跳问题!

zhengjinyi 3 years ago
parent
commit
e56933ec97
2 changed files with 19 additions and 8 deletions
  1. 17 6
      pages/goods/product.vue
  2. 2 2
      pages/supplier/user/my-shop.vue

+ 17 - 6
pages/goods/product.vue

@@ -21,7 +21,7 @@
 			id="topBar"
 			v-show="isNavbarFiexd"
 			:class="navbarFiexd"
-			:style="{ top: CustomBar + 'px' }"
+			:style="{ top: ( CustomBar - 2 ) + 'px' }"
 		>
 			<view class="search-input">
 				<view class="gosearch-btn" :class="navbarFiexd" @click="this.$api.navigateTo(clickPath)">
@@ -778,7 +778,6 @@ export default {
 				identity: this.identity
 			})
 				.then(response => {
-					this.skeletonShow = false
 					this.productImage = []
 					this.shop = response.data.shop
 					this.shopId = response.data.shopId
@@ -866,7 +865,10 @@ export default {
 					}
 					this.queryProductDetilsCoupons()
 					this.getCommodityCombinationList()
-					this.isRequest = true
+					setTimeout(()=>{
+						this.skeletonShow = false
+						this.isRequest = true
+					},1000)
 				})
 				.catch(error => {
 					this.$util.msg(error.msg, 2000)
@@ -992,7 +994,7 @@ export default {
 			// 点击tab 300ms才执行跳转,避免出错(来回跳动)
 			timer = setTimeout(() => {
 				this.tabClickAction(index)
-			}, 300)
+			}, 500)
 		},
 		// 跳转执行
 		tabClickAction(index) {
@@ -1292,7 +1294,6 @@ export default {
 			const productMain = await this.$util.boundingClientRect(this, '.container-product-main', false)
 			const productDetail = await this.$util.boundingClientRect(this, '.product-details', true)
 			const topBar = await this.$util.boundingClientRect(this, '#topBar', false)
-
 			/*
                 说明:采用累加方式来计算每一个 prdocut-details 的 scrollTop 定位
                      scrollTop = 上一个的scrollTop + 上一个的高度
@@ -1335,6 +1336,15 @@ export default {
 			100,
 			true
 		),
+		debounce (fn,delay){
+		    let timer = null //借助闭包
+		    return function() {
+		        if(timer){
+		            clearTimeout(timer) 
+		        }
+		        timer = setTimeout(fn,delay) // 简化写法
+		    }
+		},
 		getWinHeight() {
 			this.winHeight = wx.getSystemInfoSync().windowHeight
 		},
@@ -1344,7 +1354,8 @@ export default {
 	},
 	onPageScroll(e) {
 		//实时获取到滚动的值
-		const { scrollTop } = e
+		const { scrollTop } = e 
+		this.debounce(this.getSectionProps(),1000)
 		if (!this.tabSelectFlag) {
 			this.activeTab(scrollTop, this)
 		}

+ 2 - 2
pages/supplier/user/my-shop.vue

@@ -48,9 +48,9 @@
 									:widthInfo="176"
 								></uni-stars>
 							</view>
-							<view class="acount">
+							<!-- <view class="acount">
 								<text> {{ normalNum }} </text>件商品
-							</view>
+							</view> -->
 						</view>
 					</view>
 					<view class="right"><text class="iconfont icon-xiayibu"></text></view>