| <template> | |
| 	<view class=""> | |
| 		<view class="tabbar-box"></view> | |
| 		<view class="tabbar"> | |
| 			<view | |
| 			 :class="{item : true, active : select == index}" | |
| 			 v-for="(item, index) in list" | |
| 			 :key="index" | |
| 			 v-if="!item.isNotShop || !userShop" | |
| 			 @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> | |
| 	</view> | |
| </template> | |
|  | |
| <script> | |
| 	import { mapGetters } from 'vuex' | |
| 	export default { | |
| 		name:"tabbar", | |
| 		props : ['select'], | |
| 		computed : { | |
| 			...mapGetters(['userShop']), | |
| 		}, | |
| 		data() { | |
| 			return { | |
| 				list : [ | |
| 					{ | |
| 						"selectedIconPath": "/static/image/tabbar/home-a.png", | |
| 						"iconPath": "/static/image/tabbar/home.png", | |
| 						"pagePath": "/pages/index/index", | |
| 						"title": "首页" | |
| 					}, | |
| 					{ | |
| 						"selectedIconPath": "/static/image/tabbar/category-a.png", | |
| 						"iconPath": "/static/image/tabbar/category.png", | |
| 						"pagePath": "/pages/index/category", | |
| 						"title": "分类", | |
| 						isNotShop : true, | |
| 					}, | |
| 					{ | |
| 						"selectedIconPath": "/static/image/tabbar/order-a.png", | |
| 						"iconPath": "/static/image/tabbar/order.png", | |
| 						"pagePath": "/pages/index/order", | |
| 						"title": "订单中心" | |
| 					}, | |
| 					{ | |
| 						"selectedIconPath": "/static/image/tabbar/cart-a.png", | |
| 						"iconPath": "/static/image/tabbar/cart.png", | |
| 						"pagePath": "/pages/index/cart", | |
| 						"title": "购物车", | |
| 						isNotShop : true, | |
| 					}, | |
| 					{ | |
| 						"selectedIconPath": "/static/image/tabbar/center-a.png", | |
| 						"iconPath": "/static/image/tabbar/center.png", | |
| 						"pagePath": "/pages/index/center", | |
| 						"title": "个人中心" | |
| 					} | |
| 				] | |
| 			}; | |
| 		}, | |
| 		methods : { | |
| 			toPath(item, index){ | |
| 				if(index == this.select){ | |
| 					return | |
| 				} | |
| 				uni.redirectTo({ | |
| 					url: item.pagePath | |
| 				}) | |
| 			}, | |
| 		} | |
| 	} | |
| </script> | |
|  | |
| <style scoped lang="scss"> | |
| .tabbar-box{ | |
| 	height: 120rpx; | |
| 	padding-bottom: env(safe-area-inset-bottom); | |
| } | |
| .tabbar{ | |
| 	position: fixed; | |
| 	width: 750rpx; | |
| 	background-color: #fff; | |
| 	display: flex; | |
| 	justify-content: center; | |
| 	align-items: center; | |
| 	flex-direction: row; | |
| 	height: 120rpx; | |
| 	padding-bottom: env(safe-area-inset-bottom); | |
| 	z-index: 999999; | |
| 	bottom: 0; | |
| 	left: 0; | |
| 	color: #BCBCBC; | |
| 	.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; | |
| 			line-height: 35rpx; | |
| 		} | |
| 	} | |
| } | |
| .active{ | |
| 	color: $uni-color !important; | |
| } | |
| </style> |