【秒杀商品详情】

1. 接入滚动逻辑
pull/1/MERGE
YunaiV 2023-06-11 23:06:35 +08:00
parent 0ceb18b823
commit 4e756482ce
1 changed files with 63 additions and 63 deletions

View File

@ -5,7 +5,7 @@
<view class='navbarH' :style='"height:"+navH+"rpx;"'> <view class='navbarH' :style='"height:"+navH+"rpx;"'>
<view class='navbarCon acea-row row-center-wrapper'> <view class='navbarCon acea-row row-center-wrapper'>
<view class="header acea-row row-center-wrapper"> <view class="header acea-row row-center-wrapper">
<view class="item" :class="navActive === index ? 'on' : ''" v-for="(item,index) in navList" :key='index' @tap="tap(item,index)"> <view class="item" :class="navActive === index ? 'on' : ''" v-for="(item,index) in navList" :key='index' @tap="tap( index)">
{{ item }} {{ item }}
</view> </view>
</view> </view>
@ -259,7 +259,6 @@
opacity: 0, opacity: 0,
scrollY: 0, scrollY: 0,
topArr: [], topArr: [],
toView: '',
height: 0, height: 0,
heightArr: [], heightArr: [],
lock: false, lock: false,
@ -943,68 +942,69 @@
}, },
// #endif // #endif
// TODO // ========== nav ==========
/**
// 退 * 后退
*/
returns: function() { returns: function() {
uni.navigateBack() uni.navigateBack()
}, },
/**
* 点击指定 nav bar
*
* @param index 新的 navList 位置
*/
tap: function(index) {
this.$set(this, 'navActive', index);
this.$set(this, 'lock', true);
this.$set(this, 'scrollTop', index > 0 ? this.topArr[index] - (app.globalData.navHeight / 2)
: this.topArr[index]);
},
/**
* 滚动
*
* @param e 滚动事件
*/
scroll: function(e) { scroll: function(e) {
var that = this, const scrollY = e.detail.scrollTop;
scrollY = e.detail.scrollTop; let opacity = scrollY / 200;
var opacity = scrollY / 200;
opacity = opacity > 1 ? 1 : opacity; opacity = opacity > 1 ? 1 : opacity;
that.opacity = opacity this.$set(this, 'opacity', opacity);
that.scrollY = scrollY this.$set(this, 'scrollY', scrollY);
if (that.lock) { if (this.lock) {
that.lock = false this.$set(this, 'lock', false)
return; return;
} }
for (var i = 0; i < that.topArr.length; i++) { // nav
if (scrollY < that.topArr[i] - (app.globalData.navHeight / 2) + that.heightArr[i]) { for (let i = 0; i < this.topArr.length; i++) {
that.navActive = i if (scrollY < this.topArr[i] - (app.globalData.navHeight / 2) + this.heightArr[i]) {
this.$set(this, 'navActive', i)
break break
} }
} }
}, },
tap: function(item, index) { /**
var id = item.id; * 处理器滚动条
var index = index; */
var that = this;
// if (!this.data.good_list.length && id == "past2") {
// id = "past3"
// }
this.toView = id;
this.navActive = index;
this.lock = true;
this.scrollTop = index > 0 ? that.topArr[index] - (app.globalData.navHeight / 2) : that.topArr[index]
},
infoScroll: function() { infoScroll: function() {
var that = this, const topArr = [];
topArr = [], const heightArr = [];
heightArr = []; for (let i = 0; i < this.navList.length; i++) {
for (var i = 0; i < that.navList.length; i++) { //productList
// //
var query = wx.createSelectorQuery().in(this); const query = wx.createSelectorQuery().in(this);
var idView = "#past" + i; const idView = "#past" + i;
// if (!that.data.good_list.length && i == 2) {
// var idView = "#past" + 3;
// }
query.select(idView).boundingClientRect(); query.select(idView).boundingClientRect();
query.exec(function(res) { query.exec(function(res) {
var top = res[0].top; const top = res[0].top;
var height = res[0].height; const height = res[0].height;
topArr.push(top); topArr.push(top);
heightArr.push(height); heightArr.push(height);
that.topArr = topArr this.$set(this, 'topArr', topArr);
that.heightArr = heightArr this.$set(this, 'heightArr', heightArr);
}); });
} }
}, },
fen2yuan(price) { fen2yuan(price) {
return Util.fen2yuan(price) return Util.fen2yuan(price)
} }