<template>
  <zj-page-layout
  	:hasFooter="false"
  	:isScroll="true"
  	:refresherTriggered="refresherTriggered"
  	@refresherrefresh="refresherrefresh"
  	@scrolltolower="scrolltolower">
    <view class="list-container">
      <view class="item">
        <view class="top">
          <image src="@/static/common/logo.png"></image>
          <view class="user">
            <view class="name">张三</view>
            <view class="time">23小时前发布</view>
          </view>
          <view class="price">¥1888.00</view>
        </view>
        <view class="title">商品名称</view>
        <view class="des">商品描述</view>
        <view class="imgs">
          <image src="@/static/user/other_speech.png"></image>
          <image src="@/static/user/other_speech.png"></image>
          <image src="@/static/user/other_speech.png"></image>
        </view>
        <view class="bottom">
          <view class="location">天河区棠下</view>
          <view class="right">
            <u-button text="取消点赞" shape="circle"></u-button>
          </view>
        </view>
      </view>
    </view>
  </zj-page-layout>
</template>

<script>
  export default {
    data() {
      return {
        imgUrl: this.$imageUrl,
        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>
.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;
        }
      }
      .price {
        color: $assist-color;
      }
    }
    .title {
      margin-top: 20rpx;
    }
    .des {
      margin-top: 20rpx;
    }
    .imgs {
      display: flex;
      flex-wrap: wrap;
      image {
        width: 140rpx;
        height: 140rpx;
        margin-right: 20rpx;
        margin-top: 20rpx;
      }
    }
    .bottom {
      border-top: 1px solid #eaeaea;
      margin-top: 20rpx;
      padding-top: 20rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .location {
        font-size: 24rpx;
        color: $sec-font;
      }
      .u-button {
        height: 60rpx;
      }
    }
  }
}
</style>
