<template>
  <div class="AppRedemptionPoints">
    <AiTopFixed>
      <div class="header">
        <div class="num">
          <p>积分余额</p>
          <h3>562</h3>
        </div>
        <div class="btn" @click="toMyOrder">我的订单</div>
      </div>
      <div class="search">
        <u-tabs :list="tabList" :is-scroll="false" :current="currentTabs" height="76" font-size="28" bg-color="#fff" inactive-color="#8891A1" 
          active-color="#1D2229 " :bar-style="barStyle" @change="changeTab" ></u-tabs>
        <div class="type-select">
          <div :class="currentType == index ? 'item active' : 'item'" v-for="(item, index) in typeList" :key="index" @click="typeClick(index)">
            {{item}}
            <span v-if="index == 1" class="down-icon">⏷</span>
          </div>
        </div>
        <div class="point-select" v-if="currentType == 1">
          <u-tabs :list="pointTypeList" :is-scroll="true" :current="currentPoint" height="80" font-size="24" bg-color="#fff" inactive-color="#666666" 
          active-color="#4181FF" bar-width="0" :bold="false" @change="pointClick" ></u-tabs>
        </div>
      </div>
    </AiTopFixed>
    <div class="list-content">
      <u-waterfall v-model="flowList">
        <template v-slot:left="{leftList}">
          <div v-for="(item, index) in leftList" :key="index" @click="toProductDetail()">
            <div class="item">
              <img src="https://cdn.cunwuyun.cn/dvcp/h5/watermark/8.png" alt="">
              <div class="type type0">京东低价商品</div>
              <div class="content">
                <p class="text">无染(wuro)本色抽纸无染(wuro)本色抽纸无无染(wuro)本色抽纸无染(wuro)本色抽</p>
                <div class="item-money">
                  <h3>50积分</h3>
                  <p>+￥2.00</p>
                  <span>兑换后再付</span>
                </div>
                <div class="btn btn0">去兑换</div>
              </div>
            </div>
          </div>
        </template>
        <template v-slot:right="{rightList}">
          <div v-for="(item, index) in rightList" :key="index">
            <div class="item">
              <img src="https://cdn.cunwuyun.cn/dvcp/h5/watermark/8.png" alt="">
              <div class="type type0">京东低价商品</div>
              <div class="content">
                <p class="text">无染(wuro)本色抽纸无染(wuro)本色抽纸无无染(wuro)本色抽纸无染(wuro)本色抽</p>
                <div class="item-money">
                  <h3>50积分</h3>
                </div>
                <div class="btn btn0">去兑换</div>
              </div>
            </div>
          </div>
        </template>
      </u-waterfall>
    </div>
    <!-- <AiEmpty v-else></AiEmpty> -->
  </div>
</template>

<script>
import {mapState} from "vuex";

export default {
  name: 'AppRedemptionPoints',
  appName: '积分兑换',
  data() {
    return {
      tabList: [{name: '全部'}, {name: '免费兑'}, {name: '京东低价商品'}],
      currentTabs: 0,
      barStyle: {
        'width': '20px',
        'height': '3px',
        'border-radius': '2px',
        'bottom': '-3px',
        'background': '#2D7DFF'
      },
      typeList: ['最新上架', '积分', '我可兑换的'],
      currentType: 1,
      pointTypeList: [{name: '全部'}, {name: '50分以下'},  {name: '100分以下'},  {name: '200分以下'},  {name: '5000分以下'}],
      currentPoint: 0,
      leftList: [1,1,1,1,1,11,1,1],
      rightList: [1,1,1,1,1,11,1,1],
      flowList: [1,1,1,1,1,11,1,1],
    }
  },
  computed: {
    ...mapState(['user']),
  },
  onLoad() {

  },
  onShow() {
    document.title = '积分兑换'
  },
  methods: {
    changeTab(index) {
      this.currentTabs = index
      // this.getListInit()
    },
    typeClick(index) {
      this.currentType = index
      // this.getListInit()
    },
    pointClick(index) {
      this.currentPoint = index
      // this.getListInit()
    },
    toProductDetail() {
      uni.navigateTo({url: './productDetails'})
    },
    toMyOrder() {
      uni.navigateTo({url: './myOrderList'})
    }
  },
  onReachBottom() {
    // this.current = this.current + 1
    // this.getList()
  },
}
</script>

<style lang="scss" scoped>
.AppRedemptionPoints {
  min-height: 100%;
  ::v-deep .AiTopFixed .content {
   background: #f3f6f9 !important;
   padding: 0;
  }
  .header {
    display: flex;
    justify-content: space-between;
    padding: 32px 24px;
    background-color: #fff;
    margin-bottom: 24px;
    .num {
      p {
        font-family: PingFangSC-Regular;
        font-weight: 400;
        font-size: 24px;
        color: #999;
        line-height: 34px;
      }
      h3 {
        font-family: PingFangSC-SNaNpxibold;
        font-weight: 600;
        font-size: 66px;
        color: #FF6900;
        line-height: 92px;
      }
    }
    .btn {
      width: 168px;
      height: 64px;
      border: 1px solid #4181FF;
      line-height: 62px;
      border-radius: 44px;
      box-sizing: border-box;
      text-align: center;
      font-family: PingFangSC-Medium;
      font-weight: 500;
      font-size: 26px;
      color: #4181FF;
      margin-top: 28px;
    }
  }
  .search {
    background-color: #fff;
    .type-select {
      display: flex; 
      border-top: 1px solid #D8D8D8;
      line-height: 84px;
      .item {
        flex: 1;
        text-align: center;
        font-family: PingFangSC-Regular;
        font-size: 26px;
        color: #8891A1;
        .down-icon {
          display: inline-block;
          margin-left: 8px;
          transition: all 0.3s ease-in-out;
          transform: rotate(0deg);
        }
      }
      .active {
        color: #4181FF;
        .down-icon {
          transform: rotate(180deg);
        }
      }
    }
  }
  .list-content {
    padding: 24px 0 24px 24px;
    background-color: #f3f6f9;
    .item {
      width: calc(100% - 24px);
      background-color: #fff;
      border-radius: 20px;
      position: relative;
      margin-bottom: 24px;
      img {
        width: 100%;
        height: 340px;
      }
      .type {
        padding: 8px 16px;
        font-family: PingFangSC-Regular;
        font-size: 20px;
        line-height: 28px;
        color: #FFF;
        border-top-right-radius: 20px;
        border-bottom-left-radius: 20px;
        position: absolute;
        top: 0;
        right: 0;
      }
      .type0 {
        background-color: #E64E39;
      }
      .type1 {
        background-color: #FF6900;
      }
      .content {
        padding: 16px 16px 24px;
        position: relative;
        .text {
          font-family: PingFangSC-SNaNpxibold;
          font-weight: 600;
          font-size: 26px;
          color: #222;
          line-height: 38px;
          text-overflow: -o-ellipsis-lastline;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          line-clamp: 2;					
          -webkit-box-orient: vertical;
          margin-bottom: 12px;
        }
        .item-money {
          width: calc(100% - 160px);
          h3 {
            font-family: PingFangSC-SNaNpxibold;
            font-weight: 600;
            font-size: 34px;
            color: #FF6900;
            line-height: 48px;
          }
          p {
            font-family: PingFangSC;
            font-weight: 600;
            font-size: 26px;
            color: #4181FF;
          }
          span {
            display: inline-block;
            font-family: PingFangSC-Regular;
            font-weight: 400;
            font-size: 8px;
            color: #4181FF;
            line-height: 22px;
          }
        }
        .btn {
          padding: 14px 32px;
          font-family: PingFangSC-Medium;
          font-weight: 500;
          font-size: 22px;
          line-height: 28px;
          border-radius: 44px;
          position: absolute;
          bottom: 24px;
          right: 16px;
        }
        .btn0 {
          background-color: #2D7DFF;
          color: #FFF;
        }
        .btn1 {
          background-color: #E2E2E2;
          color: #666;
        }
      }
    }
    .item:nth-of-type(2n-1) {
      margin-right: 22px;
    }
  }
}
</style>
