<template>
  <zj-page-layout
    :isScroll="true"
    :refresherTriggered="refresherTriggered"
    @refresherrefresh="refresherrefresh">
    <view class="list-container">
      <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toDetail(item)">
        <image :src="(item.detailImgs.split(','))[0]" mode="aspectFill"></image>
        <view class="main">
          <view class="title">{{item.name}}</view>
		  <view class="text">{{item.userName}} {{item.userMobile}}</view>
          <view class="text">提交时间 {{item.createTime}}</view>
        </view>
        <text class="iconfont icon-jinru"></text>
      </view>
    </view>
    <Loading :type="2" :loadStatus="loadStatus" :dataList="dataList" showText="您还没有提交过报名~" />

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

<script>
  export default {
    data() {
      return {
        id: '',
				dataList: [],
				pageNum: 1,
				loadStatus: 0,
        refresherTriggered: false,
      }
    },

    onLoad({id}) {
      this.id = id;
      this.getList();
    },

    methods: {
      getList() {
      	this.loadStatus = 1;
      	this.$api.post('/promotion/activity/list', {
          promotionQuestionnaireId: this.id || '',
      	}).then(res => {
      		this.loadStatus = 0;
      		let list = res.data;
      		if (list.length < 1) {
      		  this.loadStatus = 2;
      		}
      		this.dataList = list;
      	}).catch(() => {
      		this.loadStatus = 2;
      	}).finally(res => {
      		this.refresherTriggered = false;
      	})
      },

      refreshList() {
      	this.dataList = [];
      	this.pageNum = 1;
      	this.getList();
      },

      // 触发下拉刷新
      refresherrefresh(e) {
      	this.refresherTriggered = true;
      	this.refreshList();
      },

      toDetail(item) {
        this.$navToPage({
          url: `/packageHome/pages/codeActivity/applyDetail?id=${item.promotionQuestionnaireId}&aid=${item.promotionActivityId}`
        })
      },
    },
  }
</script>

<style lang="scss" scoped>
.list-container {
  padding: 0 20rpx;
  .item {
    @include zj-card;
    margin-top: 20rpx;
    padding: 30rpx;
    display: flex;
    align-items: center;
    image {
      width: 160rpx;
      height: 120rpx;
      margin-right: 20rpx;
    }
    .main {
      flex: 1;
      .title {
        font-size: 32rpx;
        font-weight: 600;
      }
      .text {
        font-size: 24rpx;
        color: $sec-font;
        margin-top: 12rpx;
      }
    }
    .iconfont {
      color: $sec-font;
    }
  }
}
</style>
