<template>
	<view class="roomIndex">
		<uni-menubar title="聊天室" />
		<tm-translate animation-name="fadeDown">
			<tm-listitem :left-icon-size="100" url="/pages/room/sysnotice" dense :value="sysnotice_count" title="系统通知"
				left-icon="fa-volume-down" show-left-icon>
				<template #rightValue>
					<text class="text-red text-weight-b text-size-n">{{sysnotice_count}}</text>
				</template>
			</tm-listitem>

			<view class="cu-list menu-avatar">
				<block v-for="(item,index) in chatList" :key="index">
					<view class="cu-item" @click="chatClick(item.uid,item.user.nickname,item.t_card_id)" >
						<view class="cu-avatar round lg">
							<tm-images :src="item.user.avatar"></tm-images>
						</view>
						<view class="content">
							<view class="text-black">{{item.user.nickname}}</view>
							<view class="text-gray text-sm flex">
								<view class="text-cut">
									{{item.label}}
								</view>
							</view>
						</view>
						<view class="action">
							<view class="text-grey text-xs">{{item.update_time}}</view>
							<view class="cu-tag round bg-red sm">{{item.msg_count}}</view>
						</view>
					</view>
				</block>
			</view>
		</tm-translate>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sysnotice_count: 0,
				value: "",
				selected: [{
					title: "全部名片"
				}],
				list: [{
						title: "全部名片"
					},
					{
						title: "选项1"
					},
					{
						title: "选项1"
					},
					{
						title: "选项1"
					},
					{
						title: "选项1"
					},
				],
				iconList: [{
						icon: 'icon-commentdots-fill',
						color: 'bg-gradient-orange-accent'
					},
					{
						icon: 'icon-paperplane-fill',
						color: 'bg-gradient-green-accent'
					},
					{
						icon: 'icon-tag-fill',
						color: 'bg-gradient-blue-accent'
					}
				],
				item_1: [{
					text: "删除",
					width: 110,
					color: 'red'
				}, ],
				chatList: []
			}
		},
		computed: {
			userInfo() {
				return this.$tm.vx.state().user.userInfo || {}
			}
		},
		onLoad() {
			this.$tm.request.post('chat/roomlist', {
				page: 1
			}).then(res => {
				this.chatList = res.data.data
				this.sysnotice_count = res.data.sysnotice_count
			})
		},
		methods: {
			chatClick(id, name, card_id) {
				uni.navigateTo({
					url: "/subpages/pages/card/cardChat?t_uid=" + id + '&name=' + name + '&card_id=' + card_id
				})
			}
		}
	}
</script>

<style scoped lang="scss">

</style>
