<template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  <member-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div inviter-order-list">
    <view class="div common-header-wrap">
      <view class="status-holder"></view>
      <view :style="'height:'+navHeight+'px'"></view>
      <view class="common-header-holder"></view>
      <view class="common-header-fixed">
      <title-header />
      <uni-nav-bar title="推广佣金" class="common-header" left-icon="back" @clickLeft="goBack()">
      </uni-nav-bar>
    </view>
    </view>
<view class="scroll-view div" style="position:relative">
    <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
      <view class="div"  v-if="orderList && orderList.length">
        <view class="div inviter-item" v-for="(v,k) in orderList" :key="v.orderinviter_id">
          <view class="div" :class="{invalid:!v.orderinviter_valid}">
          <view class="div detail">{{v.orderinviter_remark}}</view>
          <view class="div money add">+{{v.orderinviter_money}}</view>
          <time class="date">
            <text :class="v.orderinviter_valid==1?'green':'gray'">{{v.orderinviter_valid_text}}</text>
          </time>
          </view>
        </view>
      </view>
      <empty-record v-else-if="orderList && !orderList.length"></empty-record>
    </scroll-view>
</view>
  </view></member-base>
</template>

<script>
import {getFontSize} from '@/util/common'
import TitleHeader from '../../TitleHeader'
import MemberBase from '../MemberBase'
import { getInviterOrder } from '../../../api/memberInviter'
import EmptyRecord from '../../EmptyRecord'
export default {
  name:'MemberInviterOrder',
  components:{
    TitleHeader,
    MemberBase,
    EmptyRecord
  },
  computed:{
  fontSize(){
    return getFontSize()
  },
  },
  data(){
    return {
      navHeight: 0,
      params: { 'page': 0, 'per_page': 10 },
      loading: false, // 是否加载更多
      isMore: true, // 是否有更多
      orderList: false
    }
  },
  created () {

  this.loadMore()

  },

  mounted(){

  // #ifdef  MP-WEIXIN

  this.navHeight = uni.getMenuButtonBoundingClientRect().top

  // #endif

  },
  methods:{
    goBack(){uni.navigateBack({delta:1})},
    getOrderList (ispush) {
      uni.showLoading({ title: '加载中' })
      let params = this.params
      getInviterOrder(params).then(res => {
        uni.hideLoading()
        if (res) {
          if (ispush && this.orderList) {
            this.orderList = this.orderList.concat(res.result.list)
          } else {
            this.orderList = res.result.list
          }
          if (res.result.hasmore) {
            this.isMore = true
          } else {
            this.isMore = false
          }
        }
      })
    },
    loadMore () {
      this.loading = true
      this.params.page = ++this.params.page
      if (this.isMore) {
        this.loading = false
        this.getOrderList(true)
      }
    }
  }
}
</script>

<style scoped lang="scss">
  .scroll-view-wrapper{display: flex;flex-direction: column;}
  .scroll-view{flex:1}
  .inviter-order-list {}
  .inviter-order-list .inviter-item {  background-color: #FFF;position: relative; z-index: 1; display: block; padding: 0.5rem 0; border-bottom: solid 0.05rem #EEE;}
  .inviter-order-list .inviter-item .detail { min-height: 1.8rem; margin: 0 5rem 0 0; font-size:$h6; word-wrap:break-word; line-height: 0.9rem; color: #555;padding-left:.5rem}
  .inviter-order-list .inviter-item .money { position: absolute; z-index: 1; top: 0.5rem; right: 0.5rem; height: 0.9rem; line-height: 0.9rem;}
  .inviter-order-list .inviter-item .money.add { color: #f23030;}
  .inviter-order-list .inviter-item .money.reduce { color: #36BC9B;}
  .inviter-order-list .inviter-item .date { position: absolute; z-index: 1; bottom: 0.4rem; right: 0.5rem; height: 0.9rem; font-size:$h6; line-height: 0.9rem; color: #999;}
  .inviter-order-list .inviter-item .date .green{color:green}
  .inviter-order-list .inviter-item .invalid .money.add {color: gray;}
</style>
