Commit 600e4d39 by chenwq

防抖,吸顶

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