<template>
  <view class="">
    <view class="calendar">
      <picker mode="date" fields="month" @change="bindDateChangeMonth">
        <view class="date">
          <view class="month">{{nowDate.m}}月</view>
          <view>{{nowDate.y}}</view>
        </view>
      </picker>
      <uni-calendar :insert="true" @change="changeDate" :date="nowYMD" :showMonth="false" />
    </view>
    <view class="task_list">
      <uni-section class="title" titleFontSize="32rpx" :title="'任务清单 '+ nowYMD" type="line"></uni-section>
      <view v-for="item in 5" :key="item">
        <taskItem></taskItem>
      </view>
      <!-- <u-empty icon="/static/img/empty/data.png" text="没有任务"></u-empty> -->
      <!-- <u-loadmore :status="loadConfig.status" :loading-text="loadConfig.loadingText"
        :loadmore-text="loadConfig.loadmoreText" :nomore-text="loadConfig.nomoreText" /> -->
    </view>
  </view>
</template>

<script>
  import taskItem from "@/components/task/taskItem.vue"
  export default {
    components:{
      taskItem
    },
    data() {
      return {
        current: 0,
        nowDate: {
          y: '',
          m: '',
          d: ''
        },
        loadConfig: {
          page: 1,
          limit: 25,
          loadingText: '努力加载中',
          loadmoreText: '轻轻上拉',
          nomoreText: '没有更多账单了~~',
          status: 'loadmore'
        },
      }
    },
    onLoad() {
      this.initDate();
    },
    onShow() {},
    computed: {
      nowYMD() {
        let m = this.nowDate.m < 10 ? '0' + this.nowDate.m : this.nowDate.m;
        let d = this.nowDate.d < 10 ? '0' + this.nowDate.d : this.nowDate.d;
        return this.nowDate.y + '-' + m + '-' + d;
      },
    },
    methods: {
      initDate() {
        let date = new Date();
        this.nowDate.y = date.getFullYear();
        this.nowDate.m = date.getMonth() + 1;
        this.nowDate.d = date.getDate();
      },
      // 选择日期
      changeDate(e) {
        this.nowDate.y = e.year;
        this.nowDate.m = +e.month;
        this.nowDate.d = e.date;
        this.loadConfig.page = 1;
        this.loadConfig.status = 'loadmore';
        console.log('加载任务');
      },
      // 选择月份
      bindDateChangeMonth(e) {
        this.nowDate.y = e.detail.value.split('-')[0];
        let m = e.detail.value.split('-')[1];
        this.nowDate.m = m < 10 ? +m : m;
      }
    },
    onPullDownRefresh() {
      uni.stopPullDownRefresh()
    }
  }
</script>

<style lang="scss">
  .calendar {
    background-color: #fff;
    padding-bottom: 28rpx;

    .date {
      display: flex;
      align-items: flex-end;
      background-color: #fff;
      padding: 28rpx;
      color: #333333;
      font-size: 25rpx;

      .month {
        margin-right: 15rpx;
        height: 49rpx;
        font-size: 35rpx;
        font-weight: bold;
      }
    }
  }

  .task_list {
    .title {
      background-color: transparent;
    }

    
  }
</style>