<template>
	<view class="content">
		<view class="list">
			<block v-for="(item,index) in pageList" :key="index">
				<view class="item vflex">
					<view class="hflex acenter">
						<!-- <view class="read" v-if="!item.is_read"></view> -->
						<view class="name" :class="item.is_read?'':'read'">{{item.title}}</view>
					</view>
					<view class="container">{{item.summary}}</view>
					<view class="hflex acenter jbetween bottom">
						<view class="text_style1">{{item.create_time}}</view>
						<view class="hflex acenter" @click="toDetail(item.id)">
							<view class="text_style2">查看详情</view>
							<image src="https://ship.shipcc.cn/common/right.png" mode="widthFix" style="width: 28rpx;"></image>
						</view>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	var that = ""
	import $api from '@/static/js/api.js'
	export default {
		data() {
			return {
				pageList: [
				],
				page: 1,
				limit: 15,
				total: 10
			}
		},
		onLoad() {
			that = this
		},
		onShow() {
			
			that.getList()
		},
		methods: {
			getList() {
				$api.req({
					url: '/data/api.Notice/index',
					data: {
						page: that.page,
						limit: that.limit
					}
				}, function(res) {
					if(res.code == 1) {
						if(that.page == 1) {
							that.pageList = res.data.data
						} else {
							that.pageList = that.pageList.concat(res.data.data)
						}
						that.total = res.data.total
					}
				})
			},
			// 打开详情
			toDetail(id) {
				var token = uni.getStorageSync('token')
				if(!token) {
					$api.info('请先登录')
					setTimeout(() =>{
						$api.jump('/pages/login/password_login')
					}, 1000)
				} else {
					$api.jump('/page_index/pages/index/noticeDetail?id=' + id)
				}
			},
			onReachBottom() {
				if (Number(that.page) * Number(that.limit) >= Number(that.total)) {
					$api.info("没有更多了")
				} else {
					that.page++
					that.getList(that.cid)
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #f4f4f4;
		padding: 20rpx 30rpx 0;
		
		.list {
			
			.item {
				margin-bottom: 20rpx;
				width: 100%;
				background: #fff;
				border-radius: 20rpx;
				box-sizing: border-box;
				padding: 32rpx 20rpx 26rpx;
				
				.read {
					position: relative;
					
				}
				.read::after {
					content: "";
					position: absolute;
					top: 10rpx;
					left: -8rpx;
					width: 12rpx;
					height: 12rpx;
					background-color: #ff4040;
					border-radius: 50%;
					margin-right: 16rpx;
				}
				.name {
					padding-left: 12rpx;
					font-size: 32rpx;
					color: #222;
				}
				.container {
					width: 100%;
					margin: 24rpx 0 30rpx;
					// border-bottom: 1rpx solid #f4f4f4;
					font-size: 28rpx;
					color: #878787;
					line-height: 40rpx;
					// margin-bottom: 30rpx;
					text-overflow: ellipsis;
					overflow: hidden;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					box-orient: vertical;
					line-clamp: 2;
					-webkit-line-clamp: 2;
				}
				.bottom {
					border-top: 1rpx solid #f4f4f4;
					padding-top: 32rpx;
				}
				.text_style1 {
					font-size: 28rpx;
					color: #888;
				}
				.text_style2 {
					font-size: 28rpx;
					color: #222;
					margin-right: 5rpx;
				}
			}
		}
	}
</style>