<template>
  <div class="AppPointsApply">
    <div class="points_img" @click="toAdd">
      <img src="./imgs/points.png" alt="">
    </div>
    <h3>申请记录</h3>
    <div v-if="list.length">
      <div class="card" v-for="(item,index) in list" :key="index" >
        <div class="top">
          <div class="top_title">{{ item.applyItem }}</div>
          <div><span class="top_status" :class="item.status==0? 'status0' : item.status==1? 'status1': 'status2'">{{ $dict.getLabel('integralDeclareStatus',item.status) }}</span></div>
        </div>
        <div class="bottom">
          <div class="bottom_points">积分+{{ item.applyIntegral }}</div>
          <div class="bottom_time">{{ item.createTime }}</div>
        </div>
      </div>
    </div>
    <AiEmpty description="暂无数据" class="emptyWrap" v-else></AiEmpty>
  </div>
</template>

<script>
export default {
  name: 'AppPointsApply',
  appName: '积分申请',
  data() {
    return {
      current: 1,
      list: [],
    }
  },
  onShow() {
    this.$dict.load('integralDeclareStatus').then(() => {
      this.getPointsList()
    })
  },
  methods: {
    toAdd() {
      uni.navigateTo({url: './addPoints'})
    }, 
    getPointsList() {
      this.$http.post(`/app/appintegralmemberapply/listByGirdMember`, null, {
        params: {
          current: this.current,
        }
      }).then(res=> {
        if(res?.data) {
          this.list = this.current > 1 ? [...this.list, ...res.data.records]: res.data.records
        }
      })
    }
  },
  onReachBottom() {
    this.current ++
    this.getPointsList()
  }
}
</script>

<style lang="scss" scoped>
.AppPointsApply {
  padding: 250px 32px 32px;
  box-sizing: border-box;

  .points_img {
    padding: 16px 32px;
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #F5F5F5;
    z-index: 9;
    img {
      width: 100%;
    }
  }
  h3 {
    margin-top: 48px;
  }
  .card {
    margin-top: 24px;
    padding: 24px;
    box-sizing: border-box;
    background: #FFFFFF;
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.02);
    border-radius: 16px;
    .top {
      display: flex;
      justify-content: space-between;
      .top_title {
        width: 450px;
        overflow: hidden; 
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        color: #333333;
        font-weight: 500;
      }
      .top_status {
        padding: 6px 16px;
        box-sizing: border-box;
        border-radius: 8px;
        text-align: right;
        width: calc(100% - 450px);
      }
      .status0 {
        background: #FFEDE2;
        color: #FF883C;
      }

      .status1 {
        background: #E2F6E1;
        color: #3BBC37;
      }

      .status2 {
        background: #FAE2E2;
        color: #E23C3C;
      }
    }
    .bottom {
      display: flex;
      justify-content: space-between;
      margin-top: 24px;
      .bottom_points {
        color: #FF6900;
      }
      .bottom_time {
        color: #999999;
      }
    }
  }
}
</style>