Commit 600e4d39 by chenwq

防抖,吸顶

1 parent 64e60246
......@@ -85,19 +85,11 @@ Component({
},
// 吸顶
handleBusiScroll(e) {
console.log(e)
wx.createSelectorQuery()
.select('#scroller')
.boundingClientRect((res) => {
console.log(res)
this.setData({
stickyScrollTop: e.detail.scrollTop,
stickyOffsetTop: res.top,
});
})
.exec();
},
handleBusiScroll: wx.$util.debounce(function (e) {
this.setData({
stickyScrollTop: e?.detail?.scrollTop
})
}, 100),
resetBusiData() {
this.setData({
......
......@@ -5,7 +5,6 @@
"total-tab": "../TotalTab/TotalTab",
"busi-card": "../BusiCard/BusiCard",
"output-crowdfund": "../outputCrowdfund/outputCrowdfund",
"sort-tab": "../sortTab/sortTab",
"van-sticky": "@vant/weapp/sticky/index"
"sort-tab": "../sortTab/sortTab"
}
}
\ No newline at end of file
......@@ -42,6 +42,13 @@
}
}
.sort-fix {
box-sizing: border-box;
position: absolute;
top: 0;
left: 16rpx;
}
.price-txt {
// font-family: 'test';
font-weight: Bold;
......
......@@ -62,9 +62,7 @@
<text class="price-txt">¥{{filter.money_three_for_two_thousands(busiObj.totalAmount || 0.00)}}</text>
</view>
<view>
<van-sticky scroll-top="{{ stickyScrollTop }}" offset-top="{{ stickyOffsetTop }}">
<sort-tab id="sortTab" sceneCode="{{formData.sceneCode}}" bindhandleSort="handleSort"></sort-tab>
</van-sticky>
<sort-tab id="sortTab" class="{{stickyScrollTop > 74 ? 'sort-fix' : ''}}" style="top: {{stickyScrollTop - 16 + 'px'}}" sceneCode="{{formData.sceneCode}}" bindhandleSort="handleSort"></sort-tab>
</view>
</view>
<!-- 售后众筹 -->
......
......@@ -2,11 +2,12 @@
.sort-tab {
display: flex;
box-sizing: border-box;
width: auto;
width: calc(100vw - 32rpx);
height: 86rpx;
line-height: 86rpx;
background-color: #FFFFFF;
padding: 0 20rpx;
margin-bottom: 4rpx;
.title {
width: 196rpx;
......
......@@ -79,12 +79,10 @@ Page({
if (e) {
this.setUserInfo()
let clientModule = this.selectComponent('#client')
let merchantModule = this.selectComponent('#merchant')
console.log('clientModule', clientModule)
// console.log()
// let merchantModule = this.selectComponent('#merchant')
clientModule.getClientApi && clientModule.clientRefresh()
clientModule.getBusinessData && clientModule.getBusinessData()
merchantModule.init && merchantModule.init()
// merchantModule.init && merchantModule.init()
}
let { isSuper, userInfo } = this.data
console.log(isSuper)
......
......@@ -108,6 +108,22 @@ const throttle = (fn, gapTime) => {
};
};
/* 防抖函数封装 */
function debounce(fn, interval) {
let timer;
let delay = interval || 1000; // 间隔的时间,如果interval不传,则默认1秒
return function () {
let that = this;
let args = arguments; // 保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
fn.apply(that, args); // 用apply指向调用debounce的对象,相当于this.fn(args);
}, delay);
};
}
/**删除对象里的null值 */
const clearObjNull = (options) => {
let obj = {};
......@@ -337,6 +353,7 @@ const Util = {
isFullSucreen,
clearObjNull,
throttle,
debounce,
isEmptyObj,
parseString,
getCurrentPageUrl,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!