<template>
  <div class="AppRedemptionPoints">
    <AiTopFixed>
      <u-search v-model="keyword" :clearabled="false" placeholder="请输入申请人" :show-action="false" bg-color="#F5F5F5"
        search-icon-color="#999" color="#666" @search="getListInit"></u-search>
    </AiTopFixed>
    <div class="list-content">
      <div class="item" v-for="(item, index) in list" :key="index"  @click="toGoodsList(item)">
        <div class="name">
          <img :src="item.avatarUrl" alt="" v-if="item.avatarUrl">
          <img src="./img/user-img.png" alt="" v-else>{{item.name}}
        </div>
        <div class="total">
          <span>积分总额：{{item.allIntegral}}</span>
          <span>积分余额：{{item.integral}}</span>
        </div>
        <div class="bottom">
          <p>帮兑换</p>
          <u-icon name="arrow-right" color="#CACACA" size="24" />
        </div>
      </div>
    </div>
    <AiEmpty v-if="!list.length" />

  </div>
</template>

<script>
import {mapState} from 'vuex'

export default {
  name: "AppRedemptionPoints",
  appName: "积分代兑换",
  data() {
    return {
      list: [],
      keyword: '',
      current: 1
    }
  },
  computed: {
    ...mapState(['user']),
  },
  onLoad() {
    this.getListInit()
    uni.$on('updateGoodsList', () => {
      this.getListInit()
    })
  },
  onShow() {
    document.title = "积分代兑换"
  },

  methods: {
    getListInit() {
      this.current = 1
      this.getList()
    },
    getList() {
      this.$http.post(`/app/appwechatuserqujing/listByFdAppletUserByGirdMember`, null, {
        params: {
          current: this.current,
          con: this.keyword
        }
      }).then(res => {
        if (res.code == 0) {
          this.list = this.current == 1 ? res.data.records : [...this.list, ...res.data.records]
        }
      })
    },
    toGoodsList(item) {
      uni.navigateTo({url: `./goodsList?openId=${item.openId}&userId=${item.id}&integralUserId=${item.integralUserId}`})
    }
  },
  onReachBottom() {
    this.current ++
    this.getList()
  }
}
</script>

<style lang="scss" scoped>
.AppRedemptionPoints {
  ::v-deep .fixed {
    z-index: 9999;
  }
  ::v-deep .u-search {
    margin-bottom: 0 !important;
  }
  .list-content {
    padding: 32px;
    .item {
      width: 100%;
      padding: 32px 30px 0;
      background-color: #fff;
      box-sizing: border-box;
      border-radius: 8px;
      margin-bottom: 32px;
      .name {
        font-family: PingFangSC-SNaNpxibold;
        font-weight: 600;
        font-size: 32px;
        color: #000;
        line-height: 40px;
        margin-bottom: 20px;
        img {
          width: 40px;
          height: 40px;
          margin-right: 12px;
          vertical-align: bottom;
        }
      }
      .total {
        font-family: PingFangSC-Regular;
        font-size: 24px;
        color: #666;
        line-height: 34px;
        padding-bottom: 34px;
        span {
          display: inline-block;
          width: 250px;
        }
      }
      .bottom {
        display: flex;
        justify-content: space-between;
        padding: 24px 0;
        font-family: PingFangSC-Regular;
        font-size: 28px;
        color: #000;
        line-height: 38px;
        border-top: 1px solid #eee;
      }
    }
  }
}
</style>
