监听右侧滚动

master
jscyl13849007907 2 years ago
parent 45aa956378
commit c564a83bbb

@ -195,7 +195,8 @@ Page({
],
active:0,
scrollInfoView:'category_0'
scrollInfoView:'category_0',
sList:[],
},
// onPullDownRefresh:function(){
// this.getJobList();
@ -1174,6 +1175,7 @@ Page({
// that.getJobList();
// }
that.getJobList('onshow');
wx.removeStorage({
key: "townsManInfo",
@ -1205,7 +1207,7 @@ Page({
},
getJobList() {
getJobList($type) {
var that = this;
// debugger
that.setData({
@ -1294,6 +1296,25 @@ Page({
index: that.data.currentJobDrawer.index ? that.data.currentJobDrawer.index : null,
};
}
});
let _stopList = [];
if($type == 'onshow'){
that.data.list.forEach((item,index) => {
// 动态计算高度并赋值
that.getDomInfo('category_' + index,(categoryRes)=>{
// console.log('指定区域:',categoryRes)
_stopList.push(Number(categoryRes.top))
})
});
}
that.setData({
sList:_stopList,
recordList: that.data.recordList,
currentJobDrawer: that.data.currentJobDrawer,
});
that.setData({
recordList: that.data.recordList,
@ -1312,7 +1333,44 @@ Page({
});
});
},
bindCategoryScroll(e){
let that = this;
console.log('分类滚动:',e.detail.scrollTop,' ',that.data.sList)
// 核心思想:判断当前数值在数组的哪两个区间中,取临界值 Math方法
if(0 <= e.detail.scrollTop && e.detail.scrollTop < 4241){
that.setData({
active:0
})
}else if(4241 <= e.detail.scrollTop && e.detail.scrollTop < 8482){
that.setData({
active:1
})
}else {
that.setData({
active:2
})
}
},
getDomInfo($obj,callback=()=>{}){
if($obj){
const query = wx.createSelectorQuery()
query.select('#' + $obj).boundingClientRect(function(categoryRes){
callback(categoryRes);
})
query.exec()
}else{
callback({
bottom: -1,
dataset: {},
height: -1,
id: "",
left: -1,
right: -1,
top: -1,
width: -1
});
};
},
onScrollRefresh() {
this.data.recordList = [];
this.data.storeJobListSearchForm.pageNum = 1;

@ -18,6 +18,7 @@
style="padding-top: 0;height:100vh"
scroll-into-view="{{scrollInfoView}}"
scroll-with-animation="true"
bindscroll='bindCategoryScroll'
>
<view class="category-child category_0" id="category_0">
<view wx:if="{{recordList != null && recordList.length > 0}}" style="padding-top: 0;">

@ -4,7 +4,7 @@
"urlCheck": false
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "yicai",
"projectname": "dandelionPlatform",
"condition": {
"miniprogram": {
"list": [

Loading…
Cancel
Save