<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="list-container">
      <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">天河区棠下</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;
}

.list-container {
  .item {
    margin-top: 30rpx;
    background: #ffffff;
    padding: 20rpx 30rpx;
    .top {
      display: flex;
      align-items: center;
      image {
        width: 88rpx;
        height: 88rpx;
        border-radius: 50%;
        flex-shrink: 0;
      }
      .user {
        margin-left: 20rpx;
        flex: 1;
        .name {

        }
        .time {
          color: $sec-font;
          font-size: 24rpx;
          margin-top: 8rpx;
        }
      }
      .status {
        color: $assist-color;
      }
    }
    .goods {
      display: flex;
      padding: 30rpx 0;
      image {
        width: 120rpx;
        height: 120rpx;
      }
      .main {
        flex: 1;
        margin-left: 20rpx;
        .name {
          font-size: 32rpx;
        }
        .des {
          margin-top: 12rpx;
          font-size: 28rpx;
          color: $reg-font;
        }
        .price {
          margin-top: 12rpx;
        	text {
        		color: $assist-color;
        		font-weight: 500;
        		font-size: 32rpx;
            margin-right: 12rpx;
        	}
        }
      }
    }
    .total {
      border-top: 1px solid #eaeaea;
      height: 80rpx;
      display: flex;
      align-items: center;
      justify-content: end;
      font-size: 28rpx;
      text {
        margin-left: 12rpx;
        color: $assist-color;
      }
    }
    .bottom {
      border-top: 1px solid #eaeaea;
      padding-top: 20rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .left-location {
        font-size: 24rpx;
        color: $sec-font;
      }
      .right-btn {
        .u-button {
          height: 60rpx;
        }
      }
    }
  }
}
</style>
