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({ ...@@ -21,9 +21,9 @@ Component({
tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'], tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'],
heightArr:[], heightArr:[],
curTabIdx:0, //适用产品 curTabIdx:0, //适用产品
intoViewId: 'to-0',
actNum: 0, //场景 actNum: 0, //场景
showAuth: false showAuth: false,
throttle: false
}, },
lifetimes:{ lifetimes:{
ready: function (){ ready: function (){
...@@ -40,7 +40,7 @@ Component({ ...@@ -40,7 +40,7 @@ Component({
return pre+cur.height return pre+cur.height
},heightTop) },heightTop)
let idx = imgHeightArr.findIndex(item => item > e.scrollTop) let idx = imgHeightArr.findIndex(item => item > e.scrollTop)
if(idx>-1){ if(idx>-1 && !this.data.throttle){
this.setData({ this.setData({
curTabIdx: idx curTabIdx: idx
}) })
...@@ -79,7 +79,7 @@ Component({ ...@@ -79,7 +79,7 @@ Component({
} }
this.setData({ this.setData({
navList, navList,
intoViewId: `to-0`, curTabIdx: 0,
activeNavIdx:this.data.isShare ? this.data.navIdx : 0, activeNavIdx:this.data.isShare ? this.data.navIdx : 0,
tab tab
}) })
...@@ -89,10 +89,11 @@ Component({ ...@@ -89,10 +89,11 @@ Component({
methods: { methods: {
async changeTab(e){ async changeTab(e){
let idx = e.detail let {idx} = e.currentTarget.dataset
this.setData({ this.setData({
intoViewId: `to-${idx}` curTabIdx: idx
}) })
this.data.throttle = true
let heightTop = this.data.headerHeight + 90 - 16 - 46 // 90 场景高度,16 可能是误差 , 46 tab高度 let heightTop = this.data.headerHeight + 90 - 16 - 46 // 90 场景高度,16 可能是误差 , 46 tab高度
let prodArr = await this.getHeight('.prod-wrap') let prodArr = await this.getHeight('.prod-wrap')
heightTop += prodArr[0].height heightTop += prodArr[0].height
...@@ -104,6 +105,9 @@ Component({ ...@@ -104,6 +105,9 @@ Component({
scrollTop: heightTop, scrollTop: heightTop,
duration: 0 duration: 0
}) })
setTimeout(()=>{
this.data.throttle = false
},500)
}, },
getHeight(cla){ getHeight(cla){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
...@@ -119,12 +123,6 @@ Component({ ...@@ -119,12 +123,6 @@ Component({
activeNavIdx: event.target.dataset.index activeNavIdx: event.target.dataset.index
}) })
}, },
scrolltoupper(event){
const idx = this.data.heightArr.findIndex(item => item>event.detail.scrollTop)
this.setData({
curTabIdx: idx
})
},
downVideo(e) { downVideo(e) {
let {url} = e.target.dataset let {url} = e.target.dataset
this.setData({ this.setData({
......
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"tab": "../../../../../components/Tab/Tab"
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -333,3 +333,54 @@ ...@@ -333,3 +333,54 @@
color: rgba(255,255,255,.6); color: rgba(255,255,255,.6);
padding: 16rpx 0 92rpx; 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 \ No newline at end of file
...@@ -29,9 +29,17 @@ ...@@ -29,9 +29,17 @@
</view> </view>
<view class="project-wrap"> <view class="project-wrap">
<view style="position: sticky;top: {{headerHeight}}px ;z-index: 2;background-color: #F5F7FB;"> <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> </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"> <block wx:for="{{tab}}" wx:key="index">
<view id="to-{{index}}" class="img-item img-item{{actNum+1}}{{index+1}}"> <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" /> <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!