<template>
	<view class="content safe-area-inset-bottom">
		<MessageNotification />
		<!-- 描述 -->
		<view class="info" v-for="item in list" :key="item.id" @click="next(item.base_type,item.id,item.data)">
			<view class="infos_title">
				<text class="infos">系统消息</text>
				<text class="time">{{item.notice_at}}</text>
			</view>
			<view class="preview">
				{{item.content}}
			</view>
		</view>
		
		<!-- 为空 -->
		<view class="empty">
			<u-empty text="暂无系统消息" mode="list" v-if="list.length==0"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		getSystemNoticeListApi
	} from '../../request/api/systemNotice'
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {

		},
		methods: {
			async goInfo() {
				try {
					const res = await getSystemNoticeListApi({
						store_id: uni.getStorageSync('store_id') || 11001
					})
					if (res.data && res.data.result && res.data.result.items) {
						this.list = res.data.result.items
					}
				} catch (error) {
					console.error('获取系统消息失败:', error)
				}
			},
			next(type,id,data){
				// if(type==7&&id){
				// 	uni.navigateTo({
				// 		url: '/subPackages/my/my-drug/drug-info?id=' + id
				// 	})
				// }
				if(type==4&&data){
					uni.navigateTo({
						url: "/subPackages/my/myrecord-detail?no=" + data
					})
				}
			}
		},
		mounted() {
			this.goInfo()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 750rpx;
		max-height: 100%;
		min-height: 100vh;
		padding-bottom: env(safe-area-inset-bottom);
		background: #F5F5F5;
		
		.empty {
			width: 100vw;
			max-height: 100vh;
			margin: 0 auto;
			padding: 300rpx 0;
		}

		.info {
			width: 750rpx;
			padding: 32rpx 40rpx;
			height: 156rpx;
			background: #FFFFFF;
			font-family: PingFang SC-Medium, PingFang SC;
			margin-bottom: 20rpx;

			.infos_title {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 8rpx;

				.infos {
					font-size: 28rpx;
					font-weight: bold;
					color: #232323;
					line-height: 42rpx;
				}

				.time {
					font-size: 22rpx;
					font-weight: 400;
					color: #999999;
				}
			}

			.preview {
				font-size: 24rpx;
				font-weight: 400;
				color: #999999;
				display: -webkit-box;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
				text-overflow: ellipsis;
				overflow: hidden;
				margin-top: 16rpx;
			}
		}

	}
</style>