123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <template>
- <view class="tabbar-area">
- <view class="tabbar-bottom" :style="{ backgroundColor: backgroundColor, height: tabbarHeight + 'px' }">
- <view class="tabbar-bottom-item" ref="tabbarItem" v-for="(item, index) in tabbars" :key="index"
- @click="switchTab(item,index)">
- <image :src="currentIndex == index ? item.selectedIconPath : item.iconPath"
- :class="['tabbar-bottom-item-icon']"></image>
- <text class="tabbar-bottom-item-text"
- :style="{ color: currentIndex == index ? textActiveColor : textColor }">{{ item.text }}</text>
- <text class="tabbar-bottom-item-count"
- v-if="item.count">{{ item.count >= 99 ? '99+' : item.count }}</text>
- </view>
- </view>
- <view class="midButton">
- <image class="image" src="../../static/tabbar-icon/center.png" mode=""></image>
- </view>
- <view class="safe-bottom-area" style="background-color: #fff;">
- <uv-safe-bottom></uv-safe-bottom>
- </view>
- </view>
- </template>
- <script>
- let animationModule = null;
- // #ifdef APP-NVUE
- animationModule = weex.requireModule('animation')
- // #endif
- export default {
- props: {
- currentIndex: {
- type: Number,
- default: 0
- },
- backgroundColor: {
- type: String,
- default: '#fff'
- },
- textColor: {
- type: String,
- default: '#717171'
- },
- textActiveColor: {
- type: String,
- default: '#1ABC9C'
- },
- tabbarHeight: {
- type: Number,
- default: 60
- },
- tabbars: {
- type: Array,
- default: () => ([])
- },
- midButton: {
- type: Boolean,
- default: true,
- }
- },
- data() {
- return {}
- },
- mounted() {
- uni.hideTabBar()
- },
- methods: {
- switchTab(item, index) {
- if (!item.pagePath) return;
- uni.switchTab({
- url: item.pagePath,
- });
- // this.payAnimation()
- },
- async payAnimation() {
- const active = [{
- dom: this.$refs.tabbarItem[this.currentIndex],
- styles: {
- transform: `scale(1.2)`
- },
- transformOrigin: 'center center',
- timingFunction: 'ease-in-out',
- duration: 100,
- },
- {
- dom: this.$refs.tabbarItem[this.currentIndex],
- styles: {
- transform: `scale(1)`
- },
- transformOrigin: 'center center',
- timingFunction: 'ease-in-out',
- duration: 100,
- }
- ]
- for (var i = 0; i < active.length; i++) {
- await this.animationActive(active[i])
- }
- },
- animationActive(active) {
- return new Promise((resolve, reject) => {
- animationModule.transition(active.dom, {
- styles: active.styles || {},
- duration: active.duration,
- timingFunction: active.timingFunction,
- delay: active.delay || 0,
- transformOrigin: active.transformOrigin,
- }, () => {
- resolve()
- })
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .tabbar-area {
- position: fixed;
- bottom: 0rpx;
- width: 750rpx;
- height: 145rpx;
- background-color: transparent;
- padding-top: 25rpx;
- // #ifndef APP-NVUE
- box-sizing: border-box;
- // #endif
- display: flex;
- flex-direction: column;
- }
- .tabbar-bottom {
- width: 750rpx;
- flex: 1;
- // #ifndef APP-NVUE
- display: flex;
- // #endif
- flex-direction: row;
- align-items: center;
- justify-content: space-around;
- border-top-left-radius: 40rpx;
- border-top-right-radius: 40rpx;
- }
- .midButton {
- position: absolute;
- top: 0px;
- left: 305rpx;
- .image {
- height: 145rpx;
- width: 145rpx;
- }
- }
- .tabbar-bottom-item {
- // #ifndef APP-NVUE
- display: flex;
- // #endif
- align-items: center;
- justify-content: center;
- flex-direction: column;
- height: 120rpx;
- width: 100rpx;
- position: relative;
- }
- .tabbar-bottom-item-icon {
- height: 80rpx;
- width: 54rpx;
- position: relative;
- }
- .tabbar-bottom-item-text {
- font-size: 20rpx;
- color: rgb(113, 113, 113);
- }
- .tabbar-bottom-item-count {
- background-color: #ff4d4d;
- font-size: 20rpx;
- font-weight: bold;
- color: #ffffff;
- padding: 8rpx;
- position: absolute;
- top: 0rpx;
- right: 0rpx;
- border-radius: 100rpx;
- /* 半径为高度的一半 */
- // #ifndef APP-NVUE
- display: flex;
- // #endif
- justify-content: center;
- align-items: center;
- }
- .safe-bottom-area {
- width: 750rpx;
- background-color: #fff;
- }
- </style>
|