From ff987f3cd13f9428799ee248e20d7281b2d7ba4e Mon Sep 17 00:00:00 2001 From: dingtalk_umvbsp Date: Thu, 2 Mar 2023 13:29:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BF=A1=E6=81=AF=20?= =?UTF-8?q?=E8=81=94=E8=B0=83=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index.vue | 12 +++++++++--- pages/home/my.vue | 23 ++++++++++++++--------- pages/home/news.vue | 1 + store/index.js | 22 ++++++++++++++++++++-- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/pages/home/index.vue b/pages/home/index.vue index 582561d..146dbd6 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -310,11 +310,18 @@ - +
地块个数(个)地块面积(亩)在种品种(种)在种面积(亩)
{{massif.plotNum}}{{massif.totalArea}}{{massif.plantArea}}{{massif.productCount}}
{{massif.plotNum||0}}{{massif.totalArea||0}}{{massif.plantArea||0}}{{massif.productCount||0}}
- + + 库存 采购 @@ -448,7 +455,6 @@ import request,{host} from '@/common/request' // index:0, // pagePath:"/pages/home/rePassword" // }) - uni.setTabBarBadge({ index:2, text:'2' })//底部标签显示数字 this.getHeadImg() if(this.isAdmin){ this.getPlantBase() diff --git a/pages/home/my.vue b/pages/home/my.vue index 4ca009e..ae34c6c 100644 --- a/pages/home/my.vue +++ b/pages/home/my.vue @@ -40,8 +40,14 @@ font-size:36rpx; margin-right:32rpx; } - &:nth-child(3){ - margin-left:auto; + &:nth-child(2){ + margin-right:auto; + } + &.number{ + margin-right:10rpx; + color:#999; + font-weight: bold; + font-size:30rpx; } } } @@ -71,7 +77,7 @@ 领用记录 - 系统消息 + 系统消息 {{$store.state.sysMsgNum}} 退出 @@ -88,7 +94,6 @@ import {host} from '@/common/request' } }, onLoad(options){ - console.log('--my-----onLoad-----------') this.$nextTick(()=>{ if(options.toPage){ uni.navigateTo({url:`/pages/purchase/${options.toPage}`}) @@ -96,13 +101,13 @@ import {host} from '@/common/request' }) }, onShow(){ - console.log('------my-----onShow---------------') - // uni.setTabBarBadge({ index:2, text:'' })//底部标签显示数字 - uni.hideTabBarRedDot({index:2}) + this.$store.commit("setSysMsgShow",false) + setTimeout(()=>{ + uni.hideTabBarRedDot({index:2}) + }) }, onHide(){ - console.log('------my-----onHide---------------') - + this.$store.commit("setSysMsgShow",true) }, methods:{ diff --git a/pages/home/news.vue b/pages/home/news.vue index 96858a2..c01adab 100644 --- a/pages/home/news.vue +++ b/pages/home/news.vue @@ -275,6 +275,7 @@ export default { var res=await request("/api/message/getById",{params:{id:this.list[index].id}}) if(res.statu){ this.list[index].readStatus='已读' + this.$store.state.sysMsgNum-=1 uni.navigateTo({ url:`/pages/home/newsDetail?intoPage=news`, success(e){ diff --git a/store/index.js b/store/index.js index 027fc32..4fe2eb9 100644 --- a/store/index.js +++ b/store/index.js @@ -12,6 +12,8 @@ export default new Vuex.Store({ id:"", name:"", }, + sysMsgNum:'',//系统信息数量 + isShowSysNum:true, }, getters:{ userInfo: state=>state.userInfo, @@ -29,6 +31,7 @@ export default new Vuex.Store({ outLogin(state){ state.userInfo={} state.token='' + clearTimeout(timer) uni.reLaunch({ url:"/pages/home/login", }) @@ -39,10 +42,25 @@ export default new Vuex.Store({ setBaseId(state, val){//基地id state.baseInfo={...state.baseInfo,...val} }, + setSysMsgNum(state,val){ + state.sysMsgNum=val + if(val>0 && state.isShowSysNum){ + uni.setTabBarBadge({ index:2, text:`${val}` }) + } + }, + setSysMsgShow(state,val){ + state.isShowSysNum=val + }, }, actions:{ - async getSysMsg(a,b,c){ - console.log(a,b,c,'-------ddd---') + async getSysMsg({commit,dispatch}){ + var res=await request("/api/message/readNum",{disabledLoad:true}) + if(res.statu){ + commit("setSysMsgNum",res.data) + }else{ + commit("setSysMsgNum",'') + } + timer=setTimeout(()=>dispatch('getSysMsg'),10*60*1000) }, } })