niexiting 11 months ago
parent
commit
2f3b0ab5da
  1. 14
      api/request2.js
  2. 50
      pages/index/index.vue

14
api/request2.js

@ -3142,3 +3142,17 @@ export function uploadFile(tableName, tableId, filePath, callBack) {
}, },
}); });
} }
/**
* 获取文件列表
* @param {*}
*
*/
export function getMainMessage() {
return request({
url: baseApi + "/wms/index/indexPda",
method: "get",
data: {},
});
}

50
pages/index/index.vue

@ -26,7 +26,7 @@
<view class="thumb-box" v-for="(item1, index1) in item.children" :key="index1" <view class="thumb-box" v-for="(item1, index1) in item.children" :key="index1"
@click="openCheck(item1.path)"> @click="openCheck(item1.path)">
<view class="" style="position: relative; "> <view class="" style="position: relative; ">
<u-badge v-if='index1==0' type="error" :count="count" :offset="position"></u-badge> <u-badge v-if="item1.count>0" type="error" :count="item1.count" :offset="position" :showZero ="false"></u-badge>
<image class="item-menu-image" :src="'/static/menus/'+item1.componentName" mode=""> <image class="item-menu-image" :src="'/static/menus/'+item1.componentName" mode="">
</image> </image>
<view class=""> <view class="">
@ -48,6 +48,7 @@
<script> <script>
import { import {
getDictionaryItem, getDictionaryItem,
getMainMessage
} from '@/api/request2.js'; } from '@/api/request2.js';
import comMessage from '@/mycomponents/common/comMessage.vue' import comMessage from '@/mycomponents/common/comMessage.vue'
import classifyData from '@/common/classify.data.js'; import classifyData from '@/common/classify.data.js';
@ -75,7 +76,9 @@
timer: null, // timer: null, //
forcedLogin: false, forcedLogin: false,
count: 1, count: 1,
position: [-10, -10] position: [-10, -10],
timer: null,
menusCount: {}
} }
}, },
onLoad() { onLoad() {
@ -106,6 +109,7 @@
}) })
}) })
this.getDictory() this.getDictory()
this.timerRefresh();
} else { } else {
this.showMessage("获取菜单失败") this.showMessage("获取菜单失败")
} }
@ -124,7 +128,9 @@
} }
}, },
onHide() {}, onHide() {
this.stopRefresh();
},
onShow() { onShow() {
if (sessionStorage.getItem("hasLogin") == null || sessionStorage.getItem("hasLogin") == false) { if (sessionStorage.getItem("hasLogin") == null || sessionStorage.getItem("hasLogin") == false) {
uni.showModal({ uni.showModal({
@ -146,10 +152,47 @@
} }
} }
}) })
} else {
this.timerRefresh();
} }
}, },
onUnload() {
this.stopRefresh();
},
mounted() {}, mounted() {},
methods: { methods: {
timerRefresh() {
this.getMainMessage();
this.stopRefresh();
var that = this;
this.timer = setInterval(function() {
that.getMainMessage();
console.log('刷新菜单');
}, 1000*60)
},
stopRefresh(){
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
getMainMessage(){
getMainMessage().then(res => {
this.menusCount = res.data;
this.tabbar.forEach(item=>{
item.children.forEach(rightItem=>{
var count = this.menusCount[rightItem.component]
if(count!=undefined){
rightItem.count =count;
}
})
})
this.$forceUpdate()
});
},
findList(tab) { findList(tab) {
let res = null let res = null
for (let i = 0; i < tab.length; i++) { for (let i = 0; i < tab.length; i++) {
@ -284,6 +327,7 @@
}) })
}, },
openCheck(url) { openCheck(url) {
uni.navigateTo({ uni.navigateTo({
url: "/" + url url: "/" + url

Loading…
Cancel
Save