|
@@ -1,11 +1,12 @@
|
|
|
<template>
|
|
|
<z-paging ref="msgpPging" v-model="dataList" @query="queryList" loading-more-no-more-text="没有更多消息了">
|
|
|
<template v-slot:top>
|
|
|
- <up-navbar title=" 消息" bgColor="transparent" leftIcon='' :title-style="{fontWeight:'bold'}">
|
|
|
+ <up-navbar title="消息" bgColor="transparent" leftIcon='' :title-style="{fontWeight:'bold'}">
|
|
|
</up-navbar>
|
|
|
<div class="nav-header" :style="{height:computeNavHeight}"></div>
|
|
|
</template>
|
|
|
- <ItemMessage v-for="(item,index) in dataList" :item="item" :index="index" @modify="handleModify">
|
|
|
+ <ItemMessage v-for="(item,index) in dataList" :item="item" :index="index" :key="item.notice_user_id"
|
|
|
+ @modify="handleModify">
|
|
|
</ItemMessage>
|
|
|
</z-paging>
|
|
|
</template>
|
|
@@ -13,7 +14,7 @@
|
|
|
<script>
|
|
|
import {
|
|
|
getMsgCountUrl,
|
|
|
- getMessageListUrl,
|
|
|
+ // getMessageListUrl,
|
|
|
modifyMsgUrl
|
|
|
} from '@/common/config/api.js'
|
|
|
import ItemMessage from '@/components/ItemMessage.vue'
|
|
@@ -38,9 +39,7 @@
|
|
|
methods: {
|
|
|
handleModify(id) {
|
|
|
modifyMsgUrl({
|
|
|
- params: {
|
|
|
- id
|
|
|
- }
|
|
|
+ noticeUserId: id
|
|
|
})
|
|
|
.then(res => {
|
|
|
console.log('阅读消息', res);
|
|
@@ -55,18 +54,30 @@
|
|
|
getMsgCount() {
|
|
|
getMsgCountUrl({
|
|
|
params: {
|
|
|
- userId: this.vuex_user.id
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 1,
|
|
|
+ userId: this.vuex_user.id,
|
|
|
+ status: 0
|
|
|
+ },
|
|
|
+ custom: {
|
|
|
+ catch: true
|
|
|
}
|
|
|
})
|
|
|
.then(res => {
|
|
|
console.log('未读消息数', res);
|
|
|
this.$refs.msgpPging.reload();
|
|
|
- const count = parseInt(res);
|
|
|
- if (count > 0) {
|
|
|
- uni.setTabBarBadge({
|
|
|
- index: 1,
|
|
|
- text: count > 99 ? '99+' : res
|
|
|
- })
|
|
|
+ if (res.code === 200) {
|
|
|
+ const count = String(res.total);
|
|
|
+ if (count > 0) {
|
|
|
+ uni.setTabBarBadge({
|
|
|
+ index: 1,
|
|
|
+ text: count > 99 ? '99+' : count
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.removeTabBarBadge({
|
|
|
+ index: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.removeTabBarBadge({
|
|
|
index: 1
|
|
@@ -79,14 +90,17 @@
|
|
|
},
|
|
|
queryList(pageNo, pageSize) {
|
|
|
// this.$refs.msgpPging.complete([1, 2, 3, 4, 5]);
|
|
|
- getMessageListUrl({
|
|
|
- pageNum: pageNo,
|
|
|
- pageSize: pageSize,
|
|
|
- userId: this.vuex_user.id
|
|
|
+ getMsgCountUrl({
|
|
|
+ params: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 1,
|
|
|
+ userId: this.vuex_user.id,
|
|
|
+ status: 0
|
|
|
+ },
|
|
|
})
|
|
|
.then(res => {
|
|
|
console.log('消息列表: ', res);
|
|
|
- this.$refs.msgpPging.complete(res.records);
|
|
|
+ this.$refs.msgpPging.complete(res);
|
|
|
})
|
|
|
.catch(err => {
|
|
|
console.log('err: ', err);
|