|
@@ -1,9 +1,11 @@
|
|
<template>
|
|
<template>
|
|
<view class="tab_bar">
|
|
<view class="tab_bar">
|
|
<view class="tabbarBox">
|
|
<view class="tabbarBox">
|
|
- <view class="handleBox" v-for="(item) in tabBarList" :key="item.key +'tab_bar'">
|
|
|
|
|
|
+ <view class="handleBox" v-for="(item) in tabBarList" :key="item.key + 'tab_bar'">
|
|
<view class="menuBox" @click="goPages(item)">
|
|
<view class="menuBox" @click="goPages(item)">
|
|
<view class="menuIcon">
|
|
<view class="menuIcon">
|
|
|
|
+ <view class="message-style" v-if="item.key === 'chat' && messageCount > 0">{{ messageCount }}
|
|
|
|
+ </view>
|
|
<image v-if="item.key != selectIndex" class="img" :src="item.iconPath"></image>
|
|
<image v-if="item.key != selectIndex" class="img" :src="item.iconPath"></image>
|
|
<image v-else class="img" :src="item.selectedIconPath"></image>
|
|
<image v-else class="img" :src="item.selectedIconPath"></image>
|
|
</view>
|
|
</view>
|
|
@@ -18,6 +20,8 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import { onMounted } from 'vue';
|
|
|
|
+import store from '@/store'
|
|
export default {
|
|
export default {
|
|
props: {
|
|
props: {
|
|
page: {
|
|
page: {
|
|
@@ -28,8 +32,8 @@ export default {
|
|
watch: {
|
|
watch: {
|
|
page: {
|
|
page: {
|
|
handler(value) {
|
|
handler(value) {
|
|
- console.log('value',value);
|
|
|
|
-
|
|
|
|
|
|
+ console.log('value', value);
|
|
|
|
+
|
|
this.selectIndex = value;
|
|
this.selectIndex = value;
|
|
},
|
|
},
|
|
immediate: true,
|
|
immediate: true,
|
|
@@ -39,43 +43,44 @@ export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
selectIndex: null,
|
|
selectIndex: null,
|
|
- userType: uni.getStorageSync('userType') //读取本地存储
|
|
|
|
|
|
+ userType: uni.getStorageSync('userType'), //读取本地存储
|
|
|
|
+ messageCount: store.state.user.messageCount
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
//获取当前页面
|
|
//获取当前页面
|
|
tabBarList() {
|
|
tabBarList() {
|
|
- if(this.userType === 1){
|
|
|
|
|
|
+ if (this.userType === 1) {
|
|
return [
|
|
return [
|
|
- {
|
|
|
|
- "pagePath": "/pages/index",
|
|
|
|
- "iconPath": "/static/images/tabbar/home.png",
|
|
|
|
- "selectedIconPath": "/static/images/tabbar/home_.png",
|
|
|
|
- "text": "首页",
|
|
|
|
- key:'home'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "pagePath": "/pages/mallMenu",
|
|
|
|
- "iconPath": "/static/images/tabbar/class.png",
|
|
|
|
- "selectedIconPath": "/static/images/tabbar/class_.png",
|
|
|
|
- "text": "分类",
|
|
|
|
- key:'class'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "pagePath": "/pages/classify",
|
|
|
|
- "iconPath": "/static/images/tabbar/work.png",
|
|
|
|
- "selectedIconPath": "/static/images/tabbar/work_.png",
|
|
|
|
- "text": "订单",
|
|
|
|
- key:'order'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "pagePath": "/pages/mine",
|
|
|
|
- "iconPath": "/static/images/tabbar/mine.png",
|
|
|
|
- "selectedIconPath": "/static/images/tabbar/mine_.png",
|
|
|
|
- "text": "我的",
|
|
|
|
- key:'mine'
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
|
|
+ {
|
|
|
|
+ "pagePath": "/pages/index",
|
|
|
|
+ "iconPath": "/static/images/tabbar/home.png",
|
|
|
|
+ "selectedIconPath": "/static/images/tabbar/home_.png",
|
|
|
|
+ "text": "首页",
|
|
|
|
+ key: 'home'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "pagePath": "/pages/mallMenu",
|
|
|
|
+ "iconPath": "/static/images/tabbar/class.png",
|
|
|
|
+ "selectedIconPath": "/static/images/tabbar/class_.png",
|
|
|
|
+ "text": "分类",
|
|
|
|
+ key: 'class'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "pagePath": "/pages/classify",
|
|
|
|
+ "iconPath": "/static/images/tabbar/work.png",
|
|
|
|
+ "selectedIconPath": "/static/images/tabbar/work_.png",
|
|
|
|
+ "text": "订单",
|
|
|
|
+ key: 'order'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "pagePath": "/pages/mine",
|
|
|
|
+ "iconPath": "/static/images/tabbar/mine.png",
|
|
|
|
+ "selectedIconPath": "/static/images/tabbar/mine_.png",
|
|
|
|
+ "text": "我的",
|
|
|
|
+ key: 'mine'
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
}
|
|
}
|
|
return [
|
|
return [
|
|
{
|
|
{
|
|
@@ -83,14 +88,14 @@ export default {
|
|
"iconPath": "/static/images/tabbar/home.png",
|
|
"iconPath": "/static/images/tabbar/home.png",
|
|
"selectedIconPath": "/static/images/tabbar/home_.png",
|
|
"selectedIconPath": "/static/images/tabbar/home_.png",
|
|
"text": "首页",
|
|
"text": "首页",
|
|
- key:'home'
|
|
|
|
|
|
+ key: 'home'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"pagePath": "/pages/mallMenu",
|
|
"pagePath": "/pages/mallMenu",
|
|
"iconPath": "/static/images/tabbar/class.png",
|
|
"iconPath": "/static/images/tabbar/class.png",
|
|
"selectedIconPath": "/static/images/tabbar/class_.png",
|
|
"selectedIconPath": "/static/images/tabbar/class_.png",
|
|
"text": "分类",
|
|
"text": "分类",
|
|
- key:'class'
|
|
|
|
|
|
+ key: 'class'
|
|
},
|
|
},
|
|
// {
|
|
// {
|
|
// "pagePath": "/pages/release",
|
|
// "pagePath": "/pages/release",
|
|
@@ -99,26 +104,26 @@ export default {
|
|
// "text": "发布",
|
|
// "text": "发布",
|
|
// key:'release'
|
|
// key:'release'
|
|
// },
|
|
// },
|
|
- // {
|
|
|
|
- // "pagePath": "/pages/chat",
|
|
|
|
- // "iconPath": "/static/images/tabbar/class.png",
|
|
|
|
- // "selectedIconPath": "/static/images/tabbar/class_.png",
|
|
|
|
- // "text": "消息",
|
|
|
|
- // key:'chat'
|
|
|
|
- // },
|
|
|
|
|
|
+ {
|
|
|
|
+ "pagePath": "/pages/chat",
|
|
|
|
+ "iconPath": "/static/images/tabbar/class.png",
|
|
|
|
+ "selectedIconPath": "/static/images/tabbar/class_.png",
|
|
|
|
+ "text": "消息",
|
|
|
|
+ key: 'chat'
|
|
|
|
+ },
|
|
{
|
|
{
|
|
"pagePath": "/pages/classify",
|
|
"pagePath": "/pages/classify",
|
|
"iconPath": "/static/images/tabbar/work.png",
|
|
"iconPath": "/static/images/tabbar/work.png",
|
|
"selectedIconPath": "/static/images/tabbar/work_.png",
|
|
"selectedIconPath": "/static/images/tabbar/work_.png",
|
|
"text": "订单",
|
|
"text": "订单",
|
|
- key:'order'
|
|
|
|
|
|
+ key: 'order'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"pagePath": "/pages/mine",
|
|
"pagePath": "/pages/mine",
|
|
"iconPath": "/static/images/tabbar/mine.png",
|
|
"iconPath": "/static/images/tabbar/mine.png",
|
|
"selectedIconPath": "/static/images/tabbar/mine_.png",
|
|
"selectedIconPath": "/static/images/tabbar/mine_.png",
|
|
"text": "我的",
|
|
"text": "我的",
|
|
- key:'mine'
|
|
|
|
|
|
+ key: 'mine'
|
|
}
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|
|
@@ -127,12 +132,13 @@ export default {
|
|
created() {
|
|
created() {
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
|
|
+ },
|
|
|
|
+ onMounted() {
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
//进入tabble页
|
|
//进入tabble页
|
|
goPages(page) {
|
|
goPages(page) {
|
|
- console.log('page,index',page);
|
|
|
|
|
|
+ console.log('page,index', page);
|
|
uni.switchTab({
|
|
uni.switchTab({
|
|
url: page.pagePath
|
|
url: page.pagePath
|
|
})
|
|
})
|
|
@@ -187,4 +193,24 @@ export default {
|
|
@extend .Text;
|
|
@extend .Text;
|
|
color: #d81e06;
|
|
color: #d81e06;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.menuIcon {
|
|
|
|
+ position: relative;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.message-style {
|
|
|
|
+ background: rgba(239, 68, 68, 1);
|
|
|
|
+ color: #fff;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ justify-content: center;
|
|
|
|
+
|
|
|
|
+ width: 20px;
|
|
|
|
+ height: 20px;
|
|
|
|
+ border-radius: 20px;
|
|
|
|
+
|
|
|
|
+ position: absolute;
|
|
|
|
+ right: 0;
|
|
|
|
+ z-index: 3;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|