金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

127 lines
2.8 KiB

<template>
<view>
<view class="occupy-position"></view>
<view class="content">
<view class="tabbar-box">
<view class="tab-item"
:class="{'tab-active': currentTabBar == index}"
:style="{'width': 100 / tabbars.length +'%'}"
@click="clickTab(item, index)"
v-for="(item, index) in tabbars" :key="index">
<view class="tab-icon">
<text class="lf-font-40 lf-iconfont" :class="item.icon"></text>
</view>
<view class="tab-name">{{ item.text }}</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { mapGetters } from "vuex";
export default {
props: {
type: {
type: String, // 默认跳转方式redirect,可选switch
default: 'redirect'
}
},
data(){
return {
}
},
computed: {
...mapGetters(['currentTabBar', 'tabbars', 'isShowTabBar'])
},
created(){
// 组件被创建时检查当前在哪个页面,然后校验currentTabBar是否与之匹配
let pages = getCurrentPages();
let page = pages[pages.length - 1].route;
let tabbars = this.tabbars;
let tabbar_name = tabbars[this.currentTabBar].path;
let current = 0;
tabbars.map((item, index) => {
if(item.path == '/'+ page){
current = index;
}
})
if(tabbar_name != '/'+ page){
this.$store.commit('setCurrentTabBar', current);
}
},
methods: {
clickTab(item, index){
if(this.currentTabBar == index) return;
this.$store.commit('setCurrentTabBar', index);
this.$url(item.path, {type: this.type});
}
}
}
</script>
<style lang="scss" scoped="scoped">
.lf-font-40{
font-size: 40rpx;
}
.occupy-position{
width: 750rpx;
height: 120rpx;
box-sizing: content-box;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
.content{
width: 750rpx;
height: 120rpx;
background-color: #FFFFFF;
border-radius: 60rpx 60rpx 0 0;
box-shadow: 0rpx -2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
position: fixed;
bottom: 0;
left: 0;
z-index: 99999;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
display: flex;
align-items: center;
box-sizing: content-box;
.tabbar-box{
width: 100%;
height: 100rpx;
display: flex;
.tab-item{
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.tab-name{
font-size: 24rpx;
color: #777777;
}
&.tab-active{
.tab-icon{
background-color: #15716E;
width: 60rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
transform: translateY(-20rpx) scale(1.4);
border-radius: 50%;
color: #FFFFFF;
overflow: hidden;
text{
transform: scale(0.6);
}
}
.tab-name{
color: #15716E;
font-weight: bold;
}
}
}
}
}
</style>