<template>
  <div class="AppGridIntegral">
    <div class="bg-blue"></div>
    <div class="header-content">
      <img src="https://cdn.cunwuyun.cn/dvcp/credit/head.png" alt="">
      <div class="headerDataPane" flex>
        <div class="headerItem top">
          <div v-text="`个人积分`"/>
          <b v-text="info.historyIntegralTotal||0"/>
        </div>
        <div class="headerItem">
          <div v-text="`剩余积分`"/>
          <b v-text="info.nowIntegral||0"/>
        </div>
        <div class="divider"/>
        <div class="headerItem">
          <div v-text="`积分排名`"/>
          <b v-text="info.integralRanking||'-'"/>
        </div>
      </div>
    </div>
    <div class="detail-content" v-if="list.length">
      <div class="title">积分明细</div>
      <div class="item" v-for="(item, index) in list" :key="index">
        <div class="item-info">
          <p v-text="item.eventDesc"/>
          <span v-text="item.doTime"/>
        </div>
        <div class="item-num" :class="'color-'+ item.integralCalcType">
          {{ (item.integralCalcType == 1 ? '+' : '-') + item.changeIntegral }}
        </div>
      </div>
    </div>
    <AiEmpty v-else/>
  </div>
</template>
<script>
import {mapState} from 'vuex'

export default {
  name: "AppGridIntegral",
  appName: "网格员积分",
  computed: {
    ...mapState(['user'])
  },
  data() {
    return {
      info: {},
      list: [],
      current: 1,
      pages: 0
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    // 积分排行
    getInfo() {
      let {current, info: {detailList: details}} = this
      if (!details?.pages || current <= details.pages) {
        this.$http.post('/app/appintegraluser/appGirdIntegral', null, {
          params: {current, size: 10}
        }).then(res => {
          if (res?.data) {
            this.info = res.data
            this.list = [this.list, res.data.detailList?.records || []].flat()
          }
        })
      }
    },
  },
  onReachBottom() {
    this.current++
    this.getInfo()
  }
}
</script>
<style scoped lang="scss">
.AppGridIntegral {
  width: 100vw;
  background-color: #f3f6f9;
  display: flex;
  flex-direction: column;
  align-items: center;

  .bg-blue {
    width: 100%;
    height: 270px;
    background-color: #3975C6;
  }

  .header-content {
    width: 690px;
    height: 408px;
    margin: -130px 0 40px;
    padding: 32px;
    box-sizing: border-box;
    position: relative;
    background: #FFF;
    border-radius: 16px;

    .headerDataPane {
      justify-content: space-around;
      top: 76px;
      left: 0;
      right: 0;
      position: absolute;
      z-index: 9;
      flex-wrap: wrap;

      .headerItem {
        text-align: center;
        font-size: 28px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #999999;
        line-height: 40px;

        b {
          display: block;
          line-height: 50px;
          color: #000;
          font-size: 36px;
          font-family: DINAlternate-Bold, DINAlternate;
          margin-bottom: 10px;
        }

        &.top {
          width: 100%;

          b {
            font-size: 104px;
            line-height: 122px;
          }
        }
      }
    }

    & > img {
      position: absolute;
      width: 342px;
      height: 220px;
      top: -60px;
      right: 10px;
      z-index: 2;
    }
  }

  .mar-b4 {
    margin-bottom: 8px;
  }

  .mar-b8 {
    margin-bottom: 16px;
  }

  .detail-content {
    width: 690px;
    background: #FFF;
    border-radius: 16px;
    padding: 30px 30px 94px;
    box-sizing: border-box;

    .title {
      font-size: 34px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333;
      line-height: 48px;
      margin-bottom: 30px;
    }

    .item {
      padding: 34px 0 32px 0;
      border-bottom: 2px solid #ddd;
      display: flex;

      .item-info {
        width: 500px;

        p {
          word-break: break-all;
          font-size: 32px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #333;
          line-height: 44px;
        }

        span {
          display: inline-block;
          margin-top: 8px;
          font-size: 24px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #999;
          line-height: 34px;
        }
      }

      .item-num {
        width: calc(100% - 500px);
        text-align: right;
        font-size: 36px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        line-height: 50px;
      }
    }
  }


  .color-1 {
    color: #2C51CE !important;
  }

  .color-0 {
    color: #E6736E !important;
  }

  .divider {
    width: 2px;
    height: 60px;
    background: #ededed;
  }
}
</style>
