<template>
	<view>
		<view style="color: #999;font-size: 12px;padding: 10px;">更新时间：{{time}}</view>
		<view style="padding: 0px 15px;">
			<view class="list-item" v-for="(item,index) in HeadlineData.list" :key="index" @click="toArticle(item.id)">
				<i :style="{color:index === 0 ? '#f00' : (index === 1?'#ff8c00':(index === 2?'#ffd900':'#999'))}">{{index+1}}</i>
				<view class="txt">
					{{item.title}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import App from '@/common/js/app.js';
	export default {
		data() {
			return {
				HeadlineData: {},
				time: null
			}
		},
		onLoad(){
			this.getHeadlineInfo();
			this.time = this.timeFormate(new Date().getTime());
		},
		methods: {
			getHeadlineInfo(page = 1, isPage = false) {
				let _this = this,
					requestData = {
						page:page,
						one_id:'',
						two_id:'',
						sort:1
					};
				App._post_form('&p=headline&do=HeadlineList', requestData, res => {
					let HeadlineData = res.data;
					console.log(HeadlineData)
					_this.setData({
						HeadlineData
					})
				}, false, () => {
					
				})
			},
			toArticle(id){
				App.navigationTo({
					url:`pages/mainPages/headline/headlineDetail?headline_id=${id}`
				})
			},
			// 时间戳转年月日时分秒星期
			timeFormate (timeStamp) {
			      let y = new Date(timeStamp).getFullYear().toString()
			      let M = new Date(timeStamp).getMonth() + 1 < 10 ? '0' + (new Date(timeStamp).getMonth() + 1) : new Date(timeStamp).getMonth() + 1
			      let d = new Date(timeStamp).getDate() < 10 ? '0' + new Date(timeStamp).getDate() : new Date(timeStamp).getDate()
			      let h = new Date(timeStamp).getHours() < 10 ? '0' + new Date(timeStamp).getHours() : new Date(timeStamp).getHours()
			      let m = new Date(timeStamp).getMinutes() < 10 ? '0' + new Date(timeStamp).getMinutes() : new Date(timeStamp).getMinutes()
			      let s = new Date(timeStamp).getSeconds() < 10 ? '0' + new Date(timeStamp).getSeconds() : new Date(timeStamp).getSeconds()
			      // let w = new Date(timeStamp).getDay().toString()
			      // switch (w) {
			      //   case '1':
			      //     w = '一'
			      //     break
			      //   case '2':
			      //     w = '二'
			      //     break
			      //   case '3':
			      //     w = '三'
			      //     break
			      //   case '4':
			      //     w = '四'
			      //     break
			      //   case '5':
			      //     w = '五'
			      //     break
			      //   case '6':
			      //     w = '六'
			      //     break
			      //   default:
			      //     w = '日'
			      // }
			      return y + '年' + M + '月' + d + '日' + '  ' + '  ' + h + ':' + m + ':' + s
			},
		}
	}
</script>

<style lang="scss" scoped>
.dis-flex{
	display: flex;
	align-items: center;
}
.list-item{
	display: flex;
	align-items: flex-start;
	line-height: 26px;
	margin-bottom: 10px;
	padding-right: 10px;
	padding-bottom: 8px;
	border-bottom: 1px solid #efefef;
	
	i{
		margin-right: 5px;
		color: #999;
		font-size: 13px;
	}
	.txt{
		display:-webkit-box;//将盒子转换为弹性盒子
		-webkit-box-orient:vertical;//文本显示方式，默认水平
		-webkit-line-clamp:2;//设置显示多少行
		overflow:hidden;
	}
}
</style>
