| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 | 
							- <!-- 底部导航组件 -->
 
- <template>
 
- 	<view class="tabBar" :style="{'padding-bottom': paddingBottomHeight + 'rpx'}">
 
- 		<view class="tab-bar-box">
 
- 			<view class="null-box"></view>
 
- 			<view class="tba-bar-min-box" @click="tabBarGoPage(1)">
 
- 				<img src="@/pages/images/btn_sy_xz.png" v-if="currentRoute == 'pages/views/home/home'">
 
- 				<img src="@/pages/images/btn_sy_zc.png" v-else>
 
- 				<view :class="currentRoute == 'pages/home'?'primary':''">首页</view>
 
- 			</view>
 
- 			<view class="null-box"></view>
 
- 			<view class="tba-bar-min-box" @click="tabBarGoPage(2)">
 
- 				<img src="@/pages/images/btn_xx_xz.png" v-if="currentRoute == 'pages/views/information/information'">
 
- 				<img src="@/pages/images/btn_xx_zc.png" v-else>
 
- 				<view :class="currentRoute == 'pages/information/information'?'primary':''">消息</view>
 
- 				<view class="tips-box" v-if="totalCount>0"></view>
 
- 			</view>
 
- 			<view class="null-box"></view>
 
- 			<view class="tba-bar-min-box" @click="tabBarGoPage(3)">
 
- 				<img src="@/pages/images/btn_wd_xz.png" v-if="currentRoute == 'pages/views/mine/mine'">
 
- 				<img src="@/pages/images/btn_wd_zc.png" v-else>
 
- 				<view :class="currentRoute == 'pages/mine'?'primary':''">我的</view>
 
- 			</view>
 
- 			<view class="null-box"></view>
 
- 		</view>
 
- 	</view>
 
- </template>
 
- <script>
 
- 	import {
 
- 		systemNoticeGetNoticeCount
 
- 	} from '@/pages/api/index.js'
 
- 	export default {
 
- 		name: 'tabBar',
 
- 		data() {
 
- 			return {
 
- 				paddingBottomHeight: 0, //苹果X以上手机底部适配高度
 
- 				currentRoute: "",
 
- 				userType: "",
 
- 				totalCount: 0,
 
- 			}
 
- 		},
 
- 		created() {
 
- 			let that = this;
 
- 			uni.getSystemInfo({
 
- 				success: function(res) {
 
- 					let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
 
- 					model.forEach(item => {
 
- 						//适配iphoneX以上的底部,给tabbar一定高度的padding-bottom
 
- 						if (res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
 
- 							that.paddingBottomHeight = 40;
 
- 						}
 
- 					})
 
- 				}
 
- 			});
 
- 		},
 
- 		onShow() {
 
- 		},
 
- 		mounted() {
 
- 			// 获取当前路由
 
- 			let pages = getCurrentPages();
 
- 			let page = pages[pages.length - 1];
 
- 			this.currentRoute = page.route;
 
- 			// 获取当前角色
 
- 			this.userType = uni.getStorageSync('userType');
 
- 			this.systemNoticeGetNoticeCount();
 
- 		},
 
- 		methods: {
 
- 			tabBarGoPage(type) {
 
- 				if (type === 1) {
 
- 					if (this.currentRoute !== 'pages/views/home/home') {
 
- 						uni.redirectTo({
 
- 							url: '/pages/views/home/home',
 
- 						});
 
- 					}
 
- 				} else if (type === 2) {
 
- 					if (this.currentRoute !== 'pages/views/information/information') {
 
- 						uni.redirectTo({
 
- 							url: '/pages/views/information/information',
 
- 						});
 
- 					}
 
- 				} else if (type === 3) {
 
- 					if (this.currentRoute !== 'pages/views/mine/mine') {
 
- 						uni.redirectTo({
 
- 							url: '/pages/views/mine/mine',
 
- 						});
 
- 					}
 
- 				}
 
- 			},
 
- 			async systemNoticeGetNoticeCount(){
 
- 					const {
 
- 						data
 
- 					} = await systemNoticeGetNoticeCount();
 
- 					if(data.code == 200){
 
- 						this.$set(this,'totalCount',data.data);
 
- 					}
 
- 			},
 
- 		}
 
- 	}
 
- </script>
 
- <style lang="stylus" scoped>
 
- 	.tabBar {
 
- 		z-index: 9999;
 
- 		width: 100%;
 
- 		height: 98rpx;
 
- 		background: #ffffff;
 
- 		position fixed ;
 
- 		bottom: 0;
 
- 		left: 0;
 
- 		box-shadow: 0 -3rpx 13rpx 0 rgba(0, 0, 0, 0.1);
 
- 		.tab-bar-box {
 
- 			display flex;
 
- 			.null-box {
 
- 				flex: 1;
 
- 			}
 
- 			.tba-bar-min-box {
 
- 				width: 64rpx;
 
- 				position: relative;
 
- 				img {
 
- 					width: 44rpx;
 
- 					height: 44rpx;
 
- 					margin: 14rpx auto 0;
 
- 				}
 
- 				view {
 
- 					line-height: 37rpx;
 
- 					font-size: 19rpx;
 
- 					text-align center;
 
- 					color: #666666;
 
- 				}
 
- 				.tips-box {
 
- 					position: absolute;
 
- 					top: 10rpx;
 
- 					left: 44rpx;
 
- 					display inline-block;
 
- 					background: #fa5151;
 
- 					border-radius 50%;
 
- 					width:20rpx;
 
- 					height:20rpx;
 
- 				}
 
- 			}
 
- 		}
 
- 	}
 
- </style>
 
 
  |