<template>
	<Layout>
		<div class="layout-container" style="width: 100%">
      <div class="layout-container" style="width: 100%">
        <img src="@/assets/images/join.jpg" style="width: 100% " >
      </div>

      <div  style="width: 70% ;;margin-left: 250px">
        <img src="@/assets/images/top.jpg" style="width: 100% " >
      </div>

		</div>

		<div class="section">
			<div class="container" style="max-width: 1160px">

        <el-row  type="flex" justify="center" v-for="(article,index) in articles.data" :key="index">
          <el-col :span="18"  >

            <h1 class="section--title" style="text-align: center;"> <strong>{{article.title}}</strong></h1>
            <p class="section--description" style="text-align: center;">{{article.author}}</p>
            <img :src="article.cover" style="width: 100%" alt="" />
          </el-col>
        </el-row>

			</div>
		</div>

	</Layout>
</template>

<script>
import Layout from "@/components/common/Layout";
export default {
	name: "NewsView",
	components: {Layout},
	data(){
		return{
			articles: {},
			pageIndex: 1,
		}
	},
	mounted() {
		this.getArticle(1)
	},
	methods:{
		getArticle(pageIndex){

      //分页新闻  每页6条
      let params={}
      params.page=pageIndex
      params.size=6
      let col={}
      col.colName="create_time"
      col.sortKind="desc"
      params.orderColList=[col]
      this.$post("/article/interlist", params)
          .then((res) => {
            if (res.code == 1) {
              console.log(res)
              this.articles = res.data;
            }
          })
          .catch((error) => {
            this.$message.error(error.message);
          });
		},
		changeIndex(p){
			if (p === 0){
				this.pageIndex = 1
			}else if (p === this.articles.pages + 1){
				this.pageIndex = this.articles.pages
			}else{
				this.pageIndex = p;
				this.getArticle(p)
			}
		},

    formatterDate(time) {
      if (!time) return '';
      let date = new Date(Number(time));
      let Y = date.getFullYear() + '-';
      let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
      let D = this.panLeft(date.getDate()) + ' ';
      let h = this.panLeft(date.getHours()) + ':';
      let m = this.panLeft(date.getMinutes()) + ':';
      let s = this.panLeft(date.getSeconds());
      return Y + M + D + h + m + s;
    },
     panLeft(num) {
      return num < 10 ? '0' + num : num;
       }
	}
}
</script>

<style scoped>

</style>
