<template>
	<view>
		<u-navbar :title="type==1&&'系统消息' || type==2&&'患者消息'" title-size="34" title-color="#000" :border-bottom="false"
			back-icon-color="#000"></u-navbar>

		<!-- 暂无信息 -->
		<view class="flex-row flex-jus-center bt_center" v-if="list.length==0&&info.length==0">
			<d-empty text="暂无新消息" mode="search"></d-empty>
		</view>

		<view class="box" v-if="type==1&&list.length!=0">
			<view class="list" v-for="item in list" :key="item.id" @click="toNext(item.base_type,item.data)">
				<view class="list_">
					<view class="left">
						<!-- <u-icon name="volume-up-fill" color="#666666" size="28"></u-icon> -->
						<image src="/static/group/new_xx.png" mode=""></image>
						<!-- <text>{{item.content}}</text> -->
						<text>系统信息</text>
					</view>
					<!-- <view class="right" v-if="item.read_status>0">
						<text class="road">{{item.read_status}}</text>
					</view> -->
					<view class="right">
						<text>{{item.notice_at}}</text>
					</view>
				</view>
				<view class="content_">
					<text>{{item.content}}</text>
				</view>
				<!-- <view class="content_">
					<text> 驳回原因：{{item.content}}</text>
				</view> -->
			</view>
		</view>

		<view class="box" v-if="type==2&&info.length!=0">
			<view class="list" v-for="item in info" :key="item.id" @click="toNext(item.base_type,item.data)">
				<view class="list_">
					<view class="left">
						<image src="/static/image/home2.png" mode=""></image>
						<text>患者消息</text>
					</view>

					<view class="right">
						<text>{{item.notice_at}}</text>
					</view>
				</view>
				<view class="content_">
					<text>{{item.content}}</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		homeReaed,
		homeSessionPeople,
		homeSessionSystem
	} from '../../api/all'
	export default {
		data() {
			return {
				type: 1,
				navbarHeight: this.$navbarHeight,
				statusBarHeight: this.$statusBarHeight,
				list: [],
				info: []
			}
		},
		computed: {

		},
		onShow() {

		},
		onLoad(e) {
			this.type = e.type
		},
		methods: {
			getList() {
				homeSessionSystem({
					store_id: uni.getStorageSync('store_id') || 11001
				}).then((res) => {
					// console.log(res, 'list');
					if (res.errcode == 0) {
						this.list = res.data.list
					}
				})
			},
			getInfo() {
				homeSessionPeople({
					store_id: uni.getStorageSync('store_id') || 11001
				}).then((res) => {
					// console.log(res, 'listd');
					if (res.errcode == 0) {
						this.info = res.data.list
					}
				})
			},
			// 已读
			getRead() {
				homeReaed({
					store_id: uni.getStorageSync('store_id') || 11001,
					type: this.type == 1 ? 'system' : 'patient'
				}).then((res) => {
					// console.log(res, 'listd');
					if (res.errcode == 0) {
						// this.info = res.data.list
					}
				})
			},
			// 跳转
			toNext(base_type, e) {
				// console.log(base_type,'aaaaaaaa');
				if (base_type == 2 && e) {
					const id = e.split(',').slice(0, 1)
					const re_id = e.split(',').slice(1, 2)
					this.$go('../../subPackages/sub_workbench/workbench_infoPatient?id=' + id + '&re_id=' + re_id)
				} else if (base_type == 5 && e) {
					this.$go('/subPackages/sub_my/prescriptionDetail?id=' + e)
				}
			},
		},
		mounted() {
			this.getList()
			this.getInfo()
			this.getRead()
		}
	}
</script>
<style>
	page {
		background-color: #eeeeef;
	}
</style>
<style lang="scss" scoped>
	.bg {
		width: 100vw;
		background: linear-gradient(90deg, #6ACDBB 0%, #6ACDBB 93%);
		position: fixed;
		left: 0;
		top: 0;
		z-index: 0;
	}

	.navbar {
		background: linear-gradient(90deg, #6ACDBB 0%, #6ACDBB 93%);
		width: 100vw;
		position: fixed;
		left: 0;
		top: 0;
		font-size: 34rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		z-index: 99999;
	}

	.bt_center {
		margin: 200rpx auto;
	}

	.box {
		width: 710rpx;
		margin: 20rpx auto;
		background-color: #FFFFFF;
		padding: 8rpx 0;

		.info {
			display: flex;
			flex-direction: column;
			background-color: #FFFFFF;
			padding: 0 12rpx 32rpx 12rpx;

			.time {
				padding: 0 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-family: PingFang SC-Bold, PingFang SC;
				color: #666666;
				font-size: 26rpx;
				font-weight: 500;

				.color {
					color: #6ACDBB;

				}
			}
		}

		.list {
			margin: 20rpx 0;
			padding: 12rpx 32rpx;
			width: 710rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			border-radius: 60rpx;

			.content_ {
				font-weight: 400;
				color: #999999;
				font-size: 28rpx;
				margin: 4rpx 0;
			}

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

				.left {
					display: flex;
					align-items: center;

					text {
						margin-left: 20rpx;
						font-size: 32rpx;
						color: #333333;
						font-weight: bold;
					}

					image {
						width: 54rpx;
						height: 54rpx;
						// vertical-align: middle;
					}
				}

				.right {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					font-weight: 400;
					color: #999999;

					.road {
						width: 34rpx;
						height: 34rpx;
						border-radius: 50%;
						background-color: #FF6D6D;
						color: #FFFFFF;
						font-size: 24rpx;
						line-height: 34rpx;
						text-align: center;
						margin: 10rpx 0;
					}
				}

			}

		}
	}
</style>