<template>
  <div class="com-main com-width-1400 com-margin-auto">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">Home</el-breadcrumb-item>
      <el-breadcrumb-item>Current Flyer</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="item">
      <div class="item-title">
        <span></span>
        <span>Current Flyer</span>
      </div>
      <ul class="item-content" v-loading="listLoading">
        <li v-for="item in articleLists" :key="item.id">
          <nuxt-link
            :to="{
              name: 'news-newsName',
              params: {
                newsName: item.title
                  .replace(/\s+/g, '-')
                  .replace('&', '%26')
              },
            }"
          >
            <div class="main-content">
              <div>{{ item.title }}</div>
              <div>{{ item.create_time }}</div>
            </div>
          </nuxt-link>
        </li>
      </ul>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="getList"
      />
      <div v-if="!articleLists.length">
        <el-empty description="No Data"></el-empty>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      total: 0,
      listQuery: {
        page: 1,
        limit: 12,
      },
      articleLists: [],
      listLoading: true,
    };
  },
  async created() {
    await this.getList();
  },

  methods: {
    getList() {
      this.$axios
        .post("/uk-api/home/articleList", {
          page: this.listQuery.page,
          limit: this.listQuery.limit,
        })
        .then((res) => {
          if (res.code == 1) {
            this.articleLists = res.result.data;
            this.total = res.result.total;
            this.listLoading = false;
          }
          this.$nextTick(() => {
            window.scroll(0, 0);
          });
        })
        .catch(() => {
          this.listLoading = false;
          this.articleLists = [];
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.item {
  margin-top: 20px;
  margin-bottom: 20px;
  background: #ffffff;
  box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.15);
  padding-top: 20px;

  .item-title {
    margin-left: 55px;
    span:nth-of-type(1) {
      display: inline-block;
      width: 3px;
      height: 13px;
      background: #e90000;
      border-radius: 2px;
    }
    span:nth-of-type(2) {
      height: 24px;
      font-size: 18px;
      font-family: Proxima Nova;
      font-weight: 600;
      color: #333333;
      line-height: 24px;
    }
  }
  .item-content {
    font-size: 16px;
    font-family: Proxima Nova;
    font-weight: 400;
    color: #4a596c;
    list-style: circle;
    margin: 10px 20px 10px 70px;
    li {
      height: 32px;
      line-height: 32px;
      &::marker {
        color: #0b6dc9;
      }
      .main-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: url(@/assets/img/home/line.png) repeat-x 0 16px;
        div:nth-of-type(1) {
          background-color: #fff;
          padding-right: 10px;
        }
        div:nth-of-type(2) {
          width: 200px;
          background-color: #fff;
          padding-left: 10px;
          box-sizing: border-box;
        }
      }
    }
  }
}
:deep(.el-pagination.is-background) {
  .el-pager {
    li.number {
      font-family: Proxima Nova;
      background: linear-gradient(0deg, #ebebeb, #ffffff);
      border: 1px solid #d5d5d5;
      border-radius: 50%;
      font-weight: 400;
      color: #a7a7a7;
      text-shadow: 0px 1px 0px #ffffff;
    }
    li:not(.disabled).active {
      background: #00213b;
      box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.4);
      border-radius: 50%;
      color: #ffffff;
    }
  }
  .btn-prev,
  .btn-next {
    border-radius: 50%;
    background-color: #fff;
    .el-icon-arrow-left:before {
      content: "";
    }
    .el-icon-arrow-right:before {
      content: "";
    }
  }
}
</style>
