Commit bfb222d4 by 前端

Merge branch 'zq_dev_3.0' into 'v3.0'

修改tab抖动问题

See merge request !85
2 parents 34b2ccbb 76171047
......@@ -21,9 +21,9 @@ Component({
tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'],
heightArr:[],
curTabIdx:0, //适用产品
intoViewId: 'to-0',
actNum: 0, //场景
showAuth: false
showAuth: false,
throttle: false
},
lifetimes:{
ready: function (){
......@@ -40,7 +40,7 @@ Component({
return pre+cur.height
},heightTop)
let idx = imgHeightArr.findIndex(item => item > e.scrollTop)
if(idx>-1){
if(idx>-1 && !this.data.throttle){
this.setData({
curTabIdx: idx
})
......@@ -79,7 +79,7 @@ Component({
}
this.setData({
navList,
intoViewId: `to-0`,
curTabIdx: 0,
activeNavIdx:this.data.isShare ? this.data.navIdx : 0,
tab
})
......@@ -89,10 +89,11 @@ Component({
methods: {
async changeTab(e){
let idx = e.detail
let {idx} = e.currentTarget.dataset
this.setData({
intoViewId: `to-${idx}`
curTabIdx: idx
})
this.data.throttle = true
let heightTop = this.data.headerHeight + 90 - 16 - 46 // 90 场景高度,16 可能是误差 , 46 tab高度
let prodArr = await this.getHeight('.prod-wrap')
heightTop += prodArr[0].height
......@@ -104,6 +105,9 @@ Component({
scrollTop: heightTop,
duration: 0
})
setTimeout(()=>{
this.data.throttle = false
},500)
},
getHeight(cla){
return new Promise((resolve,reject)=>{
......@@ -119,12 +123,6 @@ Component({
activeNavIdx: event.target.dataset.index
})
},
scrolltoupper(event){
const idx = this.data.heightArr.findIndex(item => item>event.detail.scrollTop)
this.setData({
curTabIdx: idx
})
},
downVideo(e) {
let {url} = e.target.dataset
this.setData({
......
{
"component": true,
"usingComponents": {
"tab": "../../../../../components/Tab/Tab"
}
}
\ No newline at end of file
......@@ -332,4 +332,55 @@
font-size: 28rpx;
color: rgba(255,255,255,.6);
padding: 16rpx 0 92rpx;
}
.tab-box {
display: flex;
width: 100%;
height: 46px;
box-sizing: border-box;
border-bottom: 1rpx solid #EAEBEF;
.tab {
position: relative;
flex-shrink: 0;
.text {
height: 84rpx;
display: flex;
align-items: center;
box-sizing: border-box;
color: #8A8C90;
justify-content: center;
margin: 0 24rpx;
font-weight: 400;
font-size: 28rpx;
font-family: PingFangSC-Medium;
}
.line {
width: 48rpx;
height: var(--borderRadius);
background: var(--btnColor);
border-radius: 8rpx 8rpx 0 0;
margin: 0 auto;
transform: scale(0);
transition: all .25s;
}
}
.active {
.text {
font-weight: 500;
font-size: 28rpx;
transition: all .25s;
color: var(--btnColor);
}
.line {
transform: scale(1);
}
}
}
.tab-box::-webkit-scrollbar {
display: none;
width: 0;
height: 0;
color: transparent;
}
\ No newline at end of file
......@@ -29,9 +29,17 @@
</view>
<view class="project-wrap">
<view style="position: sticky;top: {{headerHeight}}px ;z-index: 2;background-color: #F5F7FB;">
<tab openScroll="{{true}}" tab="{{tab}}" index="{{curTabIdx}}" bindclick="changeTab"></tab>
<!-- <tab openScroll="{{true}}" tab="{{tab}}" index="{{curTabIdx}}" bindclick="changeTab"></tab> -->
<scroll-view enhanced="{{true}}" show-scrollbar="{{false}}" scroll-left="{{curTabIdx*46}}" class="tab-box" scroll-x enable-flex scroll-with-animation >
<block wx:for="{{tab}}" wx:key="index">
<view class="tab {{index==curTabIdx?'active':''}}" bindtap="changeTab" data-idx="{{index}}">
<view class="text" >{{item}}</view>
<view class="line"></view>
</view>
</block>
</scroll-view>
</view>
<scroll-view class="project-img" scroll-into-view="{{intoViewId}}" bindscroll="scrolltoupper" scroll-y="{{true}}">
<scroll-view class="project-img" scroll-y="{{true}}">
<block wx:for="{{tab}}" wx:key="index">
<view id="to-{{index}}" class="img-item img-item{{actNum+1}}{{index+1}}">
<image class="img-item{{actNum+1}}{{index+1}}" src="{{IMGURL}}/scene/scene{{actNum+1}}{{index+1}}.png" />
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!