| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <template>
- <view class="tabbar-container">
- <block>
- <view class="tabbar-item" v-for="(item, index) in tabbarList" :key="index" :class="[item.centerItem ? ' center-item' : '']" @click="changeItem(item)">
- <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>
- export default {
- props: {
- currentPage: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- currentItem: 0,
- tabbarList: [
- {
- id: 0,
- path: '/packageShang/pages/tabbar/home',
- icon: '/packageShang/static/images/tabbar/home.png',
- selectIcon: '/packageShang/static/images/tabbar/home-active.png',
- text: '首页',
- centerItem: false
- },
- {
- id: 1,
- path: '/packageShang/pages/tabbar/category',
- icon: '/packageShang/static/images/tabbar/category.png',
- selectIcon: '/packageShang/static/images/tabbar/category-active.png',
- text: '分类',
- centerItem: true
- },
- {
- id: 2,
- path: '/packageShang/pages/tabbar/cart',
- icon: '/packageShang/static/images/tabbar/cart.png',
- selectIcon: '/packageShang/static/images/tabbar/cart-active.png',
- text: '购物车',
- centerItem: false
- },
- {
- id: 3,
- path: '/packageShang/pages/tabbar/user',
- icon: '/packageShang/static/images/tabbar/user.png',
- selectIcon: '/packageShang/static/images/tabbar/user-active.png',
- text: '我的',
- centerItem: false
- }
- ]
- };
- },
- mounted() {
- this.currentItem = this.currentPage;
- uni.hideTabBar();
- },
- methods: {
- changeItem(item) {
- let _this = this;
- //_this.currentItem = item.id;
- uni.redirectTo({
- url: item.path
- });
- }
- }
- };
- </script>
- <style>
- view {
- padding: 0;
- margin: 0;
- box-sizing: border-box;
- }
- @import url('/packageShang/components/iconfont/iconfont.css');
- @import url('/packageShang/common/common.scss');
- .tabbar-container {
- position: fixed;
- bottom: 0;
- left: 0;
- width: 100%;
- height: 167rpx;
- box-shadow: 0 0 5px #999;
- display: flex;
- align-items: center;
- padding: 5rpx 0;
- color: #999999;
- background-color: white;
- /* background-image: url('../static/images/tabbar/bgkuang.png'); */
- background-size: 100%;
- }
- .tabbar-container .tabbar-item {
- width: 33%;
- height: 100rpx;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- text-align: center;
- }
- .tabbar-container .item-active {
- color: #1E7DFB;
- }
- .tabbar-container .center-item {
- display: block;
- position: relative;
- }
- .tabbar-container .tabbar-item .item-top {
- width: 70rpx;
- height: 70rpx;
- padding: 10rpx;
- top: 24px;
- position: absolute;
- }
- .tabbar-container .center-item .item-top {
- flex-shrink: 0;
- width: 70rpx;
- height: 70rpx;
- position: absolute;
- top: 10rpx;
- left: calc(60% - 50rpx);
- border-radius: 50%;
- /* box-shadow: 0 0 5px #999; */
- /* background-color: #ffffff; */
- }
- .tabbar-container .tabbar-item .item-top image {
- width: 100%;
- height: 100%;
- }
- .tabbar-container .tabbar-item .item-bottom {
- font-size: 28rpx;
- width: 100%;
- top: 55px;
- position: absolute;
- }
- .tabbar-container .center-item .item-bottom {
- position: absolute;
- top: 37px;
- position: absolute;
- }
- </style>
|