| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | <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>			<div class="nav-header" :style="{height:computeNavHeight}"></div>		</template>		<ItemMessage v-for="(item,index) in dataList" :item="item" :index="index" @modify="handleModify">		</ItemMessage>	</z-paging></template><script>	import {		getMsgCountUrl,		getMessageListUrl,		modifyMsgUrl	} from '@/common/config/api.js'	import ItemMessage from '@/components/ItemMessage.vue'	export default {		components: {			ItemMessage		},		data() {			return {				dataList: []			}		},		onShow() {			this.getMsgCount();		},		computed: {			computeNavHeight() {				console.log(uni.$u.sys());				return uni.$u.sys().statusBarHeight + 44 + 'px'			}		},		methods: {			handleModify(id) {				modifyMsgUrl({						params: {							id						}					})					.then(res => {						console.log('阅读消息', res);						this.$refs.msgpPging.reload();						this.getMsgCount()					})					.catch(err => {						console.log(err);					})			},			// 获取未读消息数量			getMsgCount() {				getMsgCountUrl({						params: {							userId: this.vuex_user.id						}					})					.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							})						} else {							uni.removeTabBarBadge({								index: 1							})						}					})					.catch(err => {						console.log(err);					})			},			queryList(pageNo, pageSize) {				// this.$refs.msgpPging.complete([1, 2, 3, 4, 5]);				getMessageListUrl({						pageNum: pageNo,						pageSize: pageSize,						userId: this.vuex_user.id					})					.then(res => {						console.log('消息列表: ', res);						this.$refs.msgpPging.complete(res.records);					})					.catch(err => {						console.log('err: ', err);						this.$refs.msgpPging.complete(false);					})			}		}	}</script><style lang="scss" scoped>	page {		background-color: #F6F8FD;	}	.nav-header {		background-image: url('@/static/images/nav-bg.png');		background-size: cover;		background-position: center;	}</style>
 |