index.vue 1.7 KB
Newer Older
DCloud_JSON's avatar
1.5.6  
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<template>
	<view>
		<uni-list>
			<uni-list-item
				title="uni-im 会话列表" @click="toPath('/uni_modules/uni-im/pages/index/index?noTabbar=true')" :link="true"
				:show-badge="unreadMsgCount>0" :badge-text="unreadMsgCount+''" :badge-style="{'background':'#f41500'}"
			></uni-list-item>
			<uni-list-item
				title="用户列表" @click="toPath('/uni_modules/uni-im/pages/userList/userList')" :link="true"
			></uni-list-item>
			<uni-list-item
				title="通讯录" @click="toPath('/uni_modules/uni-im/pages/contacts/contacts')" :link="true"
				:show-badge="systemNoticeUnreadCount>0" :badge-text="systemNoticeUnreadCount+''" :badge-style="{'background':'#f41500'}"
			></uni-list-item>
			<uni-list-item
				title="个人中心" @click="toPath('/uni_modules/uni-id-pages/pages/userinfo/userinfo?showLoginManage=true')" :link="true"
			></uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapGetters,
		mapActions
	} from 'vuex';
	
	export default {
		computed: {
			...mapGetters({
				//未读聊天消息数量
				unreadMsgCount: 'uniIm/unread_count'
			}),
			systemNoticeUnreadCount(){
				return this.$store.getters['uniIm/systemNoticeUnreadCount']()||0
			}
		},
		data() {
			return {
			}
		},
		async onReady() {
			setTimeout( async()=> {
				await this.initConversationData()
			}, 1000);
		},
		methods: {
			//未读系统通知数量
			...mapActions({
				initConversationData: 'uniIm/initConversationData',
			}),
			toPath(path){
				uni.navigateTo({
					url: path,
					fail: () => {
						uni.switchTab({
							url:path,
							fail: (e) => {
								console.error(e);
							}
						})
					}
				});
			}
		}
	}
</script>

<style>

</style>