diff --git a/pages/type/type/index.js b/pages/type/type/index.js index c9cce5f..bca8ab0 100644 --- a/pages/type/type/index.js +++ b/pages/type/type/index.js @@ -195,7 +195,8 @@ Page({ ], active:0, - scrollInfoView:'category_0' + scrollInfoView:'category_0', + sList:[], }, // onPullDownRefresh:function(){ // this.getJobList(); @@ -1173,7 +1174,8 @@ Page({ // }); // that.getJobList(); - // } + // } + that.getJobList('onshow'); wx.removeStorage({ key: "townsManInfo", @@ -1205,7 +1207,7 @@ Page({ }, - getJobList() { + getJobList($type) { var that = this; // debugger that.setData({ @@ -1293,7 +1295,26 @@ Page({ ...item, 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; diff --git a/pages/type/type/index.wxml b/pages/type/type/index.wxml index b395b4b..2b90567 100644 --- a/pages/type/type/index.wxml +++ b/pages/type/type/index.wxml @@ -18,6 +18,7 @@ style="padding-top: 0;height:100vh" scroll-into-view="{{scrollInfoView}}" scroll-with-animation="true" + bindscroll='bindCategoryScroll' > diff --git a/project.private.config.json b/project.private.config.json index ffdcd7b..6b245b5 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -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": [