zhengjinyi 4 years ago
parent
commit
d21279723a
1 changed files with 42 additions and 11 deletions
  1. 42 11
      h5/pages/activity/activity_mid.vue

+ 42 - 11
h5/pages/activity/activity_mid.vue

@@ -95,7 +95,8 @@
 			  	list: [],
 			  }, 
 			  dataList:[],
-			  scrollTopArray:[]
+			  scrollTopArray:[],
+			  scrollTopIndex:0
 	        }
 	    },
 		onLoad() {
@@ -118,6 +119,8 @@
 					this.dataList.forEach((item,index) =>{
 						let productList = item.productList
 						let newProductList = []
+						this.scrollTopArray.push(index);
+						console.log(this.scrollTopArray)
 						// 处理商品价格
 						productList.forEach(el=>{
 							let value = el.retailPrice
@@ -189,20 +192,47 @@
 				    duration: 600
 				});
 			},
-			createSelectorQuery(e,el){
+			createSelectorQuery(e){
+				let self = this
+				let indexLength = this.scrollTopArray.length
+				let index = this.scrollTopArray[0]
+				let index1 = this.scrollTopArray[1]
+				let index2 = this.scrollTopArray[2]
+				let index3 = this.scrollTopArray[3]
+				let index4 = this.scrollTopArray[4]
+				let index5 = this.scrollTopArray[5]
+				let classIndex  = '.activity-section-'+index;
+				let classIndex1  = '.activity-section-'+index1;
+				let classIndex2  = '.activity-section-'+index2;
+				let classIndex3  = '.activity-section-'+index3;
+				let classIndex4  = '.activity-section-'+index4;
+				let classIndex5  = '.activity-section-'+index5;
+				// this.scrollTopArray.forEach(el=>{
+					
+				// })
+				// console.log('滚动条=======>',classIndex)
+				this.onCreateSelectorQuery(index,classIndex)
+				this.onCreateSelectorQuery(index1,classIndex1)
+				this.onCreateSelectorQuery(index2,classIndex2)
+				this.onCreateSelectorQuery(index3,classIndex3)
+				this.onCreateSelectorQuery(index4,classIndex4)
+				this.onCreateSelectorQuery(index5,classIndex5)
+			},
+			onCreateSelectorQuery(index,classIndex){
 				let self = this
-				let index = el.index
-				let classIndex = '.activity-section-'+index;
-				// console.log('滚动条=======>',e.scrollTop)
 				uni.createSelectorQuery().select(classIndex).boundingClientRect((res)=>{//最外层盒子节点4
-					if( res.top < 60 ){
-						self.headTab.TabCur = index;
-						console.log('选项卡索引',self.headTab.TabCur)
-						self.headTab.scrollLeft = (index - 1) * 60;
+					console.log(res)
+					if(res.dataset.index == index){
+						if( res.top ){
+							self.headTab.TabCur = index;
+							console.log('选项卡索引',self.headTab.TabCur)
+							self.headTab.scrollLeft = (index - 1) * 60;
+						}
 					}
 				}).exec()
-			},
+			}
 		},
+		
 		onShareAppMessage (res){//小程序三点分享转发
 			if (res.from === 'button') {
 				// 来自页面内转发按钮
@@ -225,7 +255,8 @@
 				this.showTop = false
 			}	
 			//锚点切换
-			// this.createSelectorQuery(e)
+			// this.scrollTopIndex++
+			this.createSelectorQuery(e)
 		},
 		onPullDownRefresh() {//下拉刷新
 			uni.stopPullDownRefresh()