<template>
  <zj-page-layout
  	:hasFooter="false"
  	:isScroll="true"
  	:refresherTriggered="refresherTriggered"
  	@refresherrefresh="refresherrefresh"
  	@scrolltolower="scrolltolower">
    <template slot="header">
      <view class="header-container">
        <u-tabs
        	:scrollable="false"
        	:list="tabList"
        	:current="curTab"
        	@click="changeTab"
        	lineColor="#01C30B"
        	:activeStyle="{
        		color: '#01C30B'
        	}"
        	:inactiveStyle="{
        		color: '#666666'
        	}"
        	itemStyle="padding-left: 0; padding-right: 0; height: 88rpx;">
        </u-tabs>
      </view>
    </template>

    <view class="common-order-list">
      <view class="item" @tap="$navPage(`/pages/mine/myBuy/detail`)">
        <view class="top">
          <image src="@/static/common/logo.png"></image>
          <view class="user">
            <view class="name">李海</view>
            <view class="time">21小时前发布</view>
          </view>
          <view class="status">待付款</view>
        </view>
        <view class="goods">
          <image src="@/static/user/other_book.png"></image>
          <view class="main">
            <view class="name">商品名称</view>
            <view class="des">商品描述</view>
            <view class="price"><text>¥18.00</text>x2</view>
          </view>
        </view>
        <view class="total">订单总金额<text>¥1200.00</text></view>
        <view class="bottom">
          <view class="left-location"><text class="iconfont icon-dingwei"></text>天河区棠下</view>
          <view class="right-btn">
            <u-button text="取消订单" shape="circle"></u-button>
          </view>
        </view>
      </view>
    </view>

  </zj-page-layout>
</template>

<script>
  export default {
    data() {
      return {
        imgUrl: this.$imageUrl,
        tabList: [
          {name: '全部', value: 1},
          {name: '待付款', value: 2},
          {name: '待发货', value: 3},
          {name: '待收货', value: 4},
          {name: '已收货', value: 5},
          {name: '售后中', value: 6},
        ],
        curTab: 0,
        dataList: [],
        pageNum: 1,
        refresherTriggered: false,
      }
    },

    async onLoad() {
      // await this.getList()
    },

    methods: {
      //获取列表数据
      async getList() {
        this.$api.post('/xxx/xxxlist', {
          pageNum: this.pageNum,
          pageSize: 10,
        }).then(res => {
          this.loadStatus = 0;
          let list = res.data.records;
          if(list.length < 10){
          	this.loadStatus = 2;
          }
          this.dataList = this.dataList.concat(list);
        }).catch(() => {
					this.loadStatus = 2;
				}).finally(res => {
					this.refresherTriggered = false;
				})
      },

      // 滚动到底部
      scrolltolower(e) {
      	if (this.loadStatus === 0) {
      		this.pageNum++;
      		this.getList();
      	}
      },

      // 触发下拉刷新
      refresherrefresh(e) {
      	this.refresherTriggered = true;
      	this.dataList = [];
      	this.pageNum = 1;
      	this.getList();
      },

    }
  }
</script>

<style lang="scss" scoped>
.header-container {
  background: #ffffff;
}


</style>
