<template>
	<u-navbar title="消息" placeholder border=true leftIcon=''></u-navbar>
	<view class="basic_container pt20">
		<!-- 	<BasicContainer :option="option">
			<template #body> -->

		<view class="tabbar mb20 ">
			<block v-for="(item, index) in details.tabbarOption">
				<view :class="{'tabbar_item': true, active: index === details.tabbarStatus,  'flex-c-c': true}"
					@click="()=> handleTabbar(index)">
					<text>
						{{item.label}}
					</text>
				</view>
			</block>

			<view class="activeItem" :style="`transform: translateX(${100 * details.tabbarStatus}%);`">

			</view>
		</view>

		<!-- 列表 -->
		<view class="list">
			<block v-for="item in details.data">

				<view class="list_item">
					<!-- 标题 -->
					<view class="title_container border-bottom flex-c-sb">
						<view class="align-center">
							<!-- <image class="tip" src="@/static/weixin.png" mode=""></image> -->

							<text class="title1 ml10">{{item.categoryName}}</text>
						</view>


						<view class="info">
							{{item.time}}
						</view>
					</view>

					<!-- 内容 -->
					<view class="content_container border-bottom">
						<view class="content_title title2">
							<!-- 关于系统升级的通知 -->
							{{item.title}}
						</view>

						<view class="text">
							<rich-text :nodes="item.content"></rich-text>
						</view>

					</view>

					<!-- 查看详情 -->
					<view class="title_container  flex-c-sb" @click="handleDetil">
						<view class="title1">
							查看详情
						</view>


						<view class="info">
							<u-icon name="arrow-right" color="#999 " size="20"></u-icon>
						</view>
					</view>

				</view>

			</block>
		</view>
		<!-- </template>
		</BasicContainer> -->
	</view>
</template>

<script setup>
	import {
		reactive
	} from 'vue';
	import {
		getBasicNoticeList
	} from '@/api/user.js';

	let details = reactive({
		tabbarStatus: 0,
		activeIndex: 0,
		tabbarOption: [{
				label: '系统公告'
			},
			{
				label: '消息通知'
			},
		],
		data: []
	})

	const handleTabbar = (status) => {
		details.tabbarStatus = status
		details.activeIndex = 0
	}

	const handleDetil = () => {
		console.log('111 :>> ', 111);
		uni.navigateTo({
			url: '/pagesMsg/pages/MsgDetail/MsgDetail'
		})
	}

	const initPage = async () => {
		const res = await getBasicNoticeList({})

		const {
			code,
			data
		} = res
		if (code !== 200) return
		details.data = data
	}

	initPage()
</script>

<style lang="scss" scoped>
	.infoStart {
		&::before {
			content: '';
			display: block;
			width: 6px;
			height: 6px;
			background-color: #fc4956;
			border-radius: 50%;
		}
	}

	// tabbar
	.tabbar {
		position: relative;
		z-index: 9;
		background-color: #fff;
		display: flex;
		height: 90upx;
		position: relative;
		border-radius: 10upx;
		margin: 0 20upx;
		overflow: hidden;

		.tabbar_item {
			flex: 1;
			transition: all 0.3s;

			text {
				position: relative;
				z-index: 10;
			}

			&.active {
				color: #fff;
			}
		}

		// 选中背景
		.activeItem {
			width: 50%;
			height: 100%;
			position: absolute;
			bottom: 0;
			left: 0;
			background-color: var(--subjectColor);
			transition: all 0.3s;
		}
	}

	// 列表
	.list {
		padding: 12px;

		.list_item {
			background-color: #fff;
			border-radius: 8px;

			// 标题
			.title_container {
				padding: 10px;
			}

			// 内容
			.content_container {
				padding: 16px 10px;

				.content_title {
					margin-bottom: 7px;
				}

				.text {
					font-size: 13px;
					color: #999999;
					line-height: 19px;
				}
			}

			.title1 {
				font-size: 15px;
				color: #151515;
				line-height: 22px;
			}

			.title2 {
				@extend .infoStart;
				display: flex;
				align-items: center;
				font-size: 16px;
				color: #151515;
				line-height: 23px;

				&::before {
					margin-right: 10px;
				}
			}

			.info {
				color: #999;
				font-size: 12px;
				line-height: 17px;
			}

			.tip {
				width: 24px;
				height: 24px;
			}

			.border-bottom {
				border-bottom: 1px solid #eee;
			}
		}
	}
</style>