123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <template>
- <cover-view id="tabbar" class="tabbar" >
- <cover-view class="tabs flex-between" :style="{'padding-bottom':`${safeArea?'68rpx':'20rpx'}`}">
- <cover-view class="item flex-center" @click="switchTab(0)">
- <cover-image :src="`${assetsUrl}tabbar-friends-${tabIndex===0?'on':'off'}.png`" mode="aspectFill" class="tab-img"></cover-image>
- <cover-view class="tab-text font22 fw400" :class="tabIndex===0?'tab-text-active':''">
- 交友
- </cover-view>
- </cover-view>
- <cover-view class="item flex-center" @click="switchTab(1)">
- <cover-image :src="`${assetsUrl}tabbar-message-${tabIndex===1?'on':'off'}.png`" mode="aspectFill" class="tab-img"></cover-image>
- <cover-view class="tab-text font22 fw400" :class="tabIndex===1?'tab-text-active':''">
- 消息
- </cover-view>
- </cover-view>
- <cover-view class="item flex-center" @click="switchTab(2)">
- <cover-image :src="`${assetsUrl}tabbar-mine-${tabIndex===2?'on':'off'}.png`" mode="aspectFill" class="tab-img"></cover-image>
- <cover-view class="tab-text font22 fw400" :class="tabIndex===2?'tab-text-active':''">
- 我的
- </cover-view>
- </cover-view>
- </cover-view>
- </cover-view>
- </template>
- <script>
- import {hasSafeArea} from '../../util/index.js'
- export default {
- name:"TabBar",
- props:{
- tabIndex:{
- type:Number,
- default:0
- }
- },
- data() {
- return {
- assetsUrl:this.$util.assetsUrl,
- safeArea:this.$util.hasSafeArea(),
- list:[
- {
- pagePath: "/pages/friends/friends",
- text: "交友"
- },
- {
- pagePath: "/pages/messages/messages",
- text: "消息"
- },
- {
- pagePath: "/pages/mine/mine",
- text: "我的"
- }
- ],
- };
- },
- mounted() {
-
- },
- methods:{
- switchTab(index){
- console.log(index)
- uni.switchTab({
- url:this.list[index].pagePath
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .tabbar{
- width: 100vw;
- position: fixed;
- bottom: 0;
- left: 0;
- padding: 0 44rpx;
- box-sizing: border-box;
- background-color: $bgcolor1;
- z-index: 0;
- .tabs{
- .item{
- flex: 1;
- flex-direction: column;
- .tab-img{
- width: 72rpx;
- height: 72rpx;
- }
- .tab-text{
- color: $fontcolor2;
- text-align: center;
- }
- .tab-text-active{
- color: $fontcolor5 !important;
- }
- }
- .add{
- width: 96rpx;
- height: 72rpx;
- background: linear-gradient(133deg, #7F5CFA 0%, #654AFE 100%);
- border-radius: 32rpx;
- .add-img{
- width: 96rpx;
- height: 72rpx;
- }
- }
- }
- }
- </style>
|