This commit is contained in:
‘tuzi0421 2024-01-16 19:00:14 +08:00
commit a93b95e814
6 changed files with 178 additions and 16 deletions

View File

@ -3,7 +3,8 @@
onLaunch: function() {
console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
console.log('App Launch')
// plus.navigator.setFullscreen(true);//
// plus.navigator.setFullscreen(true);//
// uni.hideTabBar();
},
onShow: function() {
console.log('App Show')

View File

@ -0,0 +1,147 @@
<template>
<view class="tabbar-container">
<block>
<!-- 针对中间的导航栏 通过true来判断控制类名和样式 -->
<view class="tabbar-item" v-for="(item, index) in tabbarList" :class="[item.centerItem ? 'center-item' : '']" @click="changeItem(item)" :key="index">
<view class="item-top">
<image :src="currentItem == item.id ? item.selectIcon : item.icon"></image>
</view>
<!-- 通过三元判断控制类名 达到控制选中和未选中的样式 -->
<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
<text>{{ item.text }}</text>
</view>
</view>
</block>
</view>
</template>
<script>
// easycom 使
export default {
props: {
currentPage: {
type: Number,
default: 0
}
},
data () {
return {
currentItem: 0,
tabbarList: [
{
id: 0,
path: '/pages/index/index',
icon: '/static/logo.png',
selectIcon: '/static/logo.png',
text: '首页',
centerItem: false
},
{
id: 1,
path: '/pages/person/person',
// icon: '/static/logo.png',
// selectIcon: '/static/logo.png',
text: '扫一扫',
// class
centerItem: true
},
{
id: 2,
path: '/pages/person/person',
icon: '/static/logo.png',
selectIcon: '/static/logo.png',
text: '我的',
centerItem: false
}
]
}
},
mounted () {
this.currentItem = this.currentPage
// tabBar
uni.hideTabBar()
},
methods: {
changeItem (item) {
let _this = this
//_this.currentItem = item.id;
uni.switchTab({
url: item.path
})
}
}
};
</script>
<style lang="scss" scope>
view {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.tabbar-container {
position: fixed;
bottom: 0rpx;
left: 0rpx;
width: 100%;
height: 110rpx;
box-shadow: 0 0 5px #999;
display: flex;
align-items: center;
padding: 5rpx 0;
color: #999999;
/* 针对tabbar的统一处理 */
.tabbar-item {
width: 33.33%;
height: 100rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
.item-top {
width: 70rpx;
height: 70rpx;
padding: 10rpx;
image {
width: 100%;
height: 100%;
}
}
//
.item-bottom {
font-size: 12px;
width: 100%;
}
//
.item-active {
color: #fff;
}
}
// tabbar
.center-item {
display: block;
position: relative;
.item-top {
flex-shrink: 0;
width: 100rpx;
height: 100rpx;
position: absolute;
top: -50rpx;
left: calc(50% - 50rpx);
border-radius: 50%;
box-shadow: 0 0 5px #999;
}
.item-bottom {
position: absolute;
bottom: 5rpx;
}
.item-active {
position: absolute;
bottom: 5rpx;
color: #1fff;
}
}
}
</style>

View File

@ -2,12 +2,11 @@
import "./static/iconfont/iconfont.css"
import "./static/iconfont/iconfont-weapp/iconfont-weapp-icon.css"
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import svg from './static/iconfont/svg.js'
Vue.use(svg);
import svg from './static/iconfont/svg.js'
Vue.use(svg);
Vue.config.productionTip = false;
App.mpType = 'app';
@ -27,4 +26,5 @@ export function createApp() {
app
}
}
// #endif
// #endif

View File

@ -66,7 +66,8 @@
}
]
},
"tabBar":{
"tabBar":{
"custom":true,
"color": "#7A7E83",
"selectedColor": "#3cc51f",
"borderStyle": "black",
@ -83,5 +84,5 @@
"text":"我的"
}
]
}
}
}

View File

@ -1,5 +1,6 @@
<template>
<view class="home">
<template>
<view class="container home">
<view class="home_head">
<view class="iconfont icon-chaojiguanliyuan accounticon"></view>
<view class="name">Ykxiao 超级管理员</view>
@ -58,14 +59,21 @@
</view>
</view>
</view>
</view>
</view>
<tab-bar :current-page="0"></tab-bar>
</view>
</template>
<script>
export default {
<script>
import tabBar from "@/components/customTabBar/index"
export default {
components:{
tabBar
},
data() {
return {
return {
}
},
methods: {

View File

@ -58,12 +58,17 @@
<view class="t-icon t-icon-xitongshezhi-gerenzhongxin personicon"></view>
<view class="font13">系统设置</view>
</view>
</view>
</view>
<tab-bar :current-page="2"></tab-bar>
</view>
</template>
<script>
export default {
<script>
import tabBar from "@/components/customTabBar/index"
export default {
components:{
tabBar
},
data() {
return {
}