|
|
- <template>
- <view class="tabbar">
- <view
- :class="{item : true, active : select == index}"
- v-for="(item, index) in list"
- :key="index"
- v-if="isVedio || index != 1"
- @click="toPath(item, index)">
- <view class="icon">
- <image :src="select == index ?
- item.selectedIconPath :
- item.iconPath" class="icon-image" mode=""></image>
- </view>
- <view class="title">
- {{ item.title }}
- </view>
- </view>
- </view>
- </template>
-
- <script>
- import { mapGetters, mapState } from 'vuex'
- export default {
- name:"tabbar",
- props : ['select'],
- computed : {
- ...mapGetters(['isVedio']),
- ...mapState(['configList']),
- },
- data() {
- return {
- list : [
- {
- "selectedIconPath": "/static/image/tabbar/1.png",
- "iconPath": "/static/image/tabbar/2.png",
- "pagePath": "/pages/index/index",
- "title": "首页",
- },{
- "selectedIconPath": "/static/image/tabbar/3.png",
- "iconPath": "/static/image/tabbar/4.png",
- "pagePath": "/pages/index/publish",
- "title": "发布",
- },{
- "selectedIconPath": "/static/image/tabbar/5.png",
- "iconPath": "/static/image/tabbar/6.png",
- "pagePath": "/pages/index/center",
- "title": "我的",
- }
- ],
- inter : null,
- };
- },
- mounted() {
- this.inter = setInterval(() => {
- console.log('$forceUpdate', this.isVedio);
- this.$forceUpdate()
- }, 500)
-
- setTimeout(() => {
- clearInterval(this.inter)
- this.inter = null
- }, 20000)
- },
- beforeDestroy() {
- if(this.inter){
- clearInterval(this.inter)
- }
- },
- methods : {
- toPath(item, index){
- if(index == this.select){
- return
- }
- uni.redirectTo({
- url: item.pagePath
- })
- },
- }
- }
- </script>
-
- <style scoped lang="scss">
- .tabbar{
- position: fixed;
- width: 750rpx;
- background-color: #fff;
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: row;
- height: 120rpx;
- z-index: 999999;
- bottom: 0;
- left: 0;
- line-height: 50rpx;
- color: #333;
- .item{
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .icon{
- width: 54rpx;
- height: 54rpx;
- .icon-image{
- width: 54rpx;
- height: 54rpx;
- }
- }
- .title{
- overflow: hidden;
- // white-space: nowrap;
- // text-overflow: ellipsis;
- // -o-text-overflow: ellipsis;
- font-size: 23rpx;
- }
- }
- }
- .active .title{
- background: $uni-linear-gradient-color; /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
- -webkit-background-clip: text;/*将设置的背景颜色限制在文字中*/
- -webkit-text-fill-color: transparent;/*给文字设置成透明*/
- }
- </style>
|