<template>
  <div class="ticket-detail__container">
    <van-nav-bar :title="title" left-text="返回" @click-left="$route_back" left-arrow/>
    <div class="ticket-detail__content">
      <scroller ref="scroller" :on-refresh="onRefresh" :on-infinite="infinite">
        <div class="ticket-detail__header">
          <YearMonthPicker v-model="month"></YearMonthPicker>
          <StatisticsMonthTotal :data="statisticsData"/>
        </div>
        <div class="ticket-detail__title">
          <span>本月奖票</span>
        </div>
        <div class="ticket-list__wrap">
          <div class="ticket-list__item" v-for="item in data">
            <div class="item-content__wrap">
              <div class="text-ellipsis_wrap">
                <div class="item-content">
                  持续学习，对每个进行复盘，把每一件事做到极致持续学习，对每个进行复盘，把每一件事做到极致
                </div>
              </div>
              <div class="item-content__divider"></div>
            </div>
            <div class="ticket-item__date">3.12发放</div>
          </div>
        </div>
      </scroller>
    </div>
  </div>
</template>

<script>
  import moment from 'moment'
  import request from '@/utils/request'
  import StatisticsMonthTotal from './statistics_month_total'
  import YearMonthPicker from '@/components/common/YearMonthPicker'

  export default {
    name: 'ticket_personal_detail',
    data () {
      return {
        data: null,
        title: '武钰的奖票',
        month: moment().format('YYYY-MM'),
        statisticsData: [
          {label: '本月奖票', value: 0},
          {label: '累计奖票', value: 0}
        ]
      }
    },
    components: {StatisticsMonthTotal, YearMonthPicker},
    created () {
      this.searchParams = {page_size: 20}
    },
    methods: {
      onRefresh (doneCallback) {
        this.searchParams.page = 1
        this.getData(doneCallback)
      },
      infinite () {
        this.getData()
      },
      getData (callback = function(){}) {
        this.searchParams.employee_id = 214
        request('get','/api/integral/ticket',this.searchParams).then(res => {
						callback();
          const {scroller} = this.$refs
          if (res.data.code === 1) {
            const {list, total} = res.data.data
            this.searchParams.page++
            this.data = [].concat(this.eventData, list)
            scroller.finishInfinite(list.length < this.searchParams.page_size)
          } else {
            scroller.finishInfinite(true)
          }
        })
      }
    }
  }
</script>

<style scoped lang="less">
  .ticket-detail__container {
    position: relative;

    & /deep/ .van-nav-bar {
      background-color: #26a2ff;
    }

    & .ticket-detail__content {
      position: relative;
      height: calc(100% - 0.92rem);
      color: #303133;
      font-size: 0.32rem;
    }

    & .ticket-detail__header {
      position: relative;
      height: 2.04rem;
      background: #26a2ff;
      z-index: 1;

      & .bg-fff {
        background: transparent;

        & /deep/ .YMPicker_item_icon,
        /deep/ .date-text {
          color: #fff;
        }
      }
    }

    & .ticket-detail__title {
      position: relative;
      margin: 1rem 0 0.32rem 0;
      padding: 0 0.32rem;
      font-weight: 600;

      &:before {
        content: '';
        position: absolute;
        top: 50%;
        bottom: 0;
        left: 0.32rem;
        margin-top: -0.16rem;
        width: 0.08rem;
        height: 0.34rem;
        background: #26a2ff;
        border-radius: 0.04rem;
      }

      & > span {
        margin-left: 0.16rem;
      }
    }

    & .ticket-list__wrap {
      position: relative;
      padding: 0 0.32rem;
      color: #303133;

      & .ticket-list__item {
        margin-bottom: 0.24rem;
        background: #fff;
        border-radius: 0.16rem;

        & .item-content__wrap {
          position: relative;
          padding: 0.2rem 0.24rem;
          height: 1rem;

          & .text-ellipsis_wrap {
            display: flex;
            flex: 1;
            overflow: hidden;
          }

          & .item-content {
            height: 1rem;
            line-height: 0.5rem;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }

          & .item-content__divider {
            position: absolute;
            left: 0.3rem;
            right: 0.3rem;
            bottom: 0;
            height: 1px;
            background: linear-gradient(to right, #e2e2e2, #e2e2e2 3px, transparent 3px, transparent);
            background-size: 0.11rem 100%;

            &:before {
              content: ' ';
              position: absolute;
              top: -0.2rem;
              left: -0.5rem;
              height: 0.4rem;
              width: 0.4rem;
              background: #f5f5f5;
              border-radius: 100%;
            }

            &:after {
              content: ' ';
              position: absolute;
              top: -0.2rem;
              right: -0.5rem;
              height: 0.4rem;
              width: 0.4rem;
              background: #f5f5f5;
              border-radius: 100%;
            }
          }
        }

        & .ticket-item__date {
          padding: 0.16rem 0.24rem;
          font-size: 0.28rem;
          color: #C0C4CC;
        }
      }
    }
  }
</style>
