Browse Source

系统信息 联调接口

master
邓宏 2 years ago
parent
commit
ff987f3cd1
  1. 12
      pages/home/index.vue
  2. 23
      pages/home/my.vue
  3. 1
      pages/home/news.vue
  4. 22
      store/index.js

12
pages/home/index.vue

@ -310,11 +310,18 @@
<view class="area card">
<table>
<tr class="title"> <td>地块个数()</td><td>地块面积()</td><td>在种品种()</td><td>在种面积()</td> </tr>
<tr class="value"> <td>{{massif.plotNum}}</td><td>{{massif.totalArea}}</td><td>{{massif.plantArea}}</td><td>{{massif.productCount}}</td> </tr>
<tr class="value"> <td>{{massif.plotNum||0}}</td><td>{{massif.totalArea||0}}</td><td>{{massif.plantArea||0}}</td><td>{{massif.productCount||0}}</td> </tr>
</table>
<view class="article">
<text class="plant-bijibenjilutongxunlu" @click="$u.route({url:'pages/massif/myPlant'})"/>
<u-image
v-for="(v,k) in massif.images||[]" :key="k"
:title="`${host}/${massif.images[k]}`"
width="56rpx"
height="46rpx"
radius="8rpx"
:src="`${host}/${massif.images[k]}`"/>
<text class="line"/>
<text class="plant-nongzi" style="margin-right:64rpx;" @click="$u.route({url:'pages/stock/mana'})">库存</text>
<text class="plant-caigou" @click="$u.route({url:'pages/purchase/apply'})">采购</text>
@ -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()

23
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 @@
<text class="plant-kufangguanli-lingyongguihuan"/> <text>领用记录</text> <text class="plant-youbian"/>
</view>
<view class="item" @click="$u.route({url:'/pages/home/news'})">
<text class="plant-xitongxiaoxi"/> <text>系统消息</text> <text class="plant-youbian"/>
<text class="plant-xitongxiaoxi"/> <text>系统消息</text> <text class="number">{{$store.state.sysMsgNum}}</text> <text class="plant-youbian"/>
</view>
<view class="item" @click="$store.commit('outLogin')">
<text class="plant-tuichu"/> <text>退出</text> <text class="plant-youbian"/>
@ -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:{

1
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){

22
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)
},
}
})

Loading…
Cancel
Save