<template>
	<view>
		<view class="hd-v">
			<!-- <view class="start-bar"></view> -->
			<view class="tabs">
				<image src="../../static/img/back.png" mode="" @click="$request.backGo"></image>
				<text>{{$lang.lang.notice.notice}}</text>
			</view>
		</view>
		<!-- <view class="start-bar"></view> -->
		<view class="notice-list">
			<view class="notice-list-it" v-for="item in data" :key="item.id" @click="toInfo(item.id)">
				<view class="notice-list-top">
					<image  src="../../static/img/notice-1.png" mode=""></image>
					<!-- <image v-else src="../../static/img/notice-2.png" mode=""></image> -->
					<view class="">{{$lang.locale=='zh'?item.title:$lang.locale=='en'?item.titleEn:item.titleFr}}</view>
				</view>
				<view class="times">
					<image src="../../static/img/time.png" mode=""></image>
					<text>{{getDate(item.createTime)}}</text>
				</view>
<!-- 				<view class="tags2">
					<text v-if="item.status == 1">已读</text>
					<text v-else class="notice_no">未读</text>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				page:1,
				pages:1
			}
		},
		onShow() {
			this.getData()
		},
		onReachBottom() {
			this.page++
			if(this.page <= this.pages){
				this.getData()
			}
		},
		methods: {
			getData(){
				this.$request.get('/app-api/system/notice/page', { page: this.page, rows: 10}).then(res => {
					if(res.code == 0 &&res.data&& res.data.list&&res.data.list.length > 0){
						if(this.page==1){
							this.data = res.data.list
						}else{
							this.data = this.data.concat(res.data.list)
						}
						this.pages = res.data.pages
					}
				})
			},

			getDate(time) {
				const date = new Date(time);
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				let hour = date.getHours()
				let min = date.getMinutes()
				let sec = date.getSeconds()
				hour = hour > 9 ? hour : '0' + hour;
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				min = min > 9 ? min : '0' + min;
				sec = sec > 9 ? sec : '0' + sec;
				
				return `${year}-${month}-${day} ${hour}:${min}:${sec}`;
			},
			toInfo(id){
				uni.navigateTo({
					url:'../notice_info/notice_info?id='+id
				})
			}
		}
	}
</script>

<style>
	@import url(../../static/css/notice.css);
</style>
