index.wxml
<view class='shopDetail-box'>
<view class="tab-left" >
<view class="{{tabArr.curHdIndex=='1'? 'active' : ''}}" id="1" data-id="1" bindtap="tab">人身保障</view>
<view class="{{tabArr.curHdIndex=='2'? 'active' : ''}}" id="2" data-id="2" bindtap="tab">财产保障</view>
<view class="{{tabArr.curHdIndex=='3'? 'active' : ''}}" id="3" data-id="3" bindtap="tab">健康保障</view>
<view class="{{tabArr.curHdIndex=='4'? 'active' : ''}}" id="4" data-id="4" bindtap="tab">养老保障</view>
</view>
<view class="tab-right">
<view class="right-item {{tabArr.curBdIndex=='1'? 'active' : ''}}">
1
</view>
<view class="right-item {{tabArr.curBdIndex=='2'? 'active' : ''}}">
2
</view>
<view class="right-item {{tabArr.curBdIndex=='3'? 'active' : ''}}">
3
</view>
<view class="right-item {{tabArr.curBdIndex=='4'? 'active' : ''}}">
4
</view>
</view>
</view>
index.wxss
.fs18{
font-size: 18px;
}
.fs16{
font-size: 16px;
}
.fs14{
font-size: 14px;
}
.fs12{
font-size: 12px;
}
.mb10{
margin-bottom: 10px;
}
.shopDetail-box{
padding-top: 55px;
}
.tab-left .active {
color: #fc5b13;
border-bottom: 2px solid #fc5b13;
}
.tab-left {
background: #fff;
position: fixed;
z-index: 22;
top: 0;
left: 0;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 16px;
color: #333;
border-bottom: 1px solid #d5d5d5;
}
.tab-left view {
width: 30%;
height: 48px;
display: flex;
justify-content: center;
align-items: center;
}
.tab-right .right-item {
display: none;
height: 300rpx;
width: 100%;
/* border: solid 1px; */
}
.tab-right .right-item.active {
display: block;
}
.shopDetail-bottom{
position: absolute;
left: 15px;
bottom: 15px;
color: #fff;
}
index.js
Page({
data: {
// tab 切换
tabArr: {
curHdIndex: 1,
curBdIndex: 1
}
},
//tab切换
tab: function (e) {
//var dataId = e.currentTarget.dataset.id;
var dataId = e.currentTarget.id;
var obj = {};
obj.curHdIndex = dataId;
obj.curBdIndex = dataId;
this.setData({
tabArr: obj
})
console.log(obj);
},
})