Commit 2f702978ebc4efc0663f79e279ba90e86e55c114

Authored by wangfan
1 parent fb9e2ba4

快速预定

... ... @@ -42,5 +42,10 @@ Component({
menuHidden:true
})
},
activeMenuID(id){
this.setData({
activeMenuID:id
})
},
}
})
\ No newline at end of file
... ...
... ... @@ -72,6 +72,10 @@ Page({
totalHeight: getApp().system.windowHeight,
kindHeight: getApp().system.windowHeight - 68
})
setTimeout(()=>{
this.initScrollHeightList();
},1000)
},
/**
... ... @@ -260,39 +264,44 @@ Page({
})
},
getClassNameFlag:true,
async bindscroll(e){
bindscroll(e){
if(!this.getClassNameFlag) return;
console.log(e);
this.getClassNameFlag=false;
let activeId=await this.getClassName();
this.getClassNameFlag=true;
this.setData({
activeId:activeId,
console.log('this.scrollHeightList',this.scrollHeightList)
let maxMX=9999999;
let activeId='';
Object.keys(this.scrollHeightList).forEach(tid=>{
let mx=parseInt(e.detail.scrollTop)-parseInt(this.scrollHeightList[tid].top)
if(mx>-100){
if(mx<maxMX) {
maxMX=mx;
activeId=tid;
}
}
})
if(activeId){
console.log(activeId, this.scrollHeightList[activeId].dataset.name)
this.setData({
activeId:activeId,
})
this.selectComponent("#menu").activeMenuID(activeId);
}
this.getClassNameFlag=true;
},
getClassName(){
scrollHeightList:{},
initScrollHeightList(scroll){
//if(Object.keys(this.scrollHeightList).length>0) return;
let that=this;
return new Promise(function(success,fail){
let activeId='';
let activeTop=-100000;
var query = wx.createSelectorQuery();
query.selectAll('.list-model-masonry').boundingClientRect()
query.exec(function (res) {
for(let i=0;i<res[0].length;i++){
let x=res[0][i];
if(x.top<150){
console.log(x)
if(x.top>activeTop){
activeTop=x.top
activeId=x.id
}
}
}
console.log('class_name-activeId',activeId,activeTop);
if(activeTop>32){
activeId='';
//x.top=parseInt(scroll.detail.scrollTop)+parseInt(x.top);
that.scrollHeightList[x.id]=x;
}
success(activeId)
success()
})
})
},
... ...
... ... @@ -12,10 +12,10 @@
>
<view style = "padding-left:180rpx;">
<view class="section" wx:for="{{cookbooklist}}" wx:key="cookbooklist-key">
<view id="{{'inToView'+item.id}}" class="class_name {{activeId==item.id?'class_name-active':''}}">
<view id="{{'inToView'+item.id}}" class="class_name {{activeId==item.id?'class_name-active11':''}}">
<view class="text">{{item.class_name}}</view>
</view>
<view class="list-model-masonry" id="{{item.id}}">
<view class="list-model-masonry" id="{{item.id}}" data-name="{{item.class_name}}">
<view class="list-model-column">
<block wx:for="{{item.cookbooklist[0]}}" wx:key="{{item.id}}" wx:for-index="itemIndex" >
<view class="item">
... ...