<template>
  <div class="integralTask">
    <div class="fix-top">
      <div class="img-bg">
        <img src="https://cdn.cunwuyun.cn/fengdu/img-jifenlist.png" alt="">
      </div>
      <div class="title">任务大厅</div>
    </div>
    <div class="card-list" v-if="list.length">
      <div class="card" v-for="(item,index) in list" :key="index" @click="$linkTo('./taskDetail?id='+item.id)">
        <h4>{{ item.title }}</h4>
        <p>{{ item.detail }}</p>
        <div class="imgs" v-if="item.files">
          <image mode="aspectFill" v-for="(e, i) in item.files" :key="i" :src="e.url"/>
        </div>
        <div class="time">
          <div class="goin" v-if="item.intoBegintime && item.intoEndtime">
            <img src="https://cdn.cunwuyun.cn/fengdu/ic-jinchangshijian.png" alt="">
            <div class="label">进场时间：</div>
            <div class="value">{{ item.intoBegintime.substring(0, 16)}} 至 {{ item.intoEndtime.substring(0, 16) }}</div>
          </div>
          <div class="exit" v-if="item.exitBegintime && item.exitEndtime">
            <img src="https://cdn.cunwuyun.cn/fengdu/ic-lichangshijian.png" alt="">
            <div class="label">离场时间：</div>
            <div class="value">{{ item.exitBegintime.substring(0, 16) }} 至 {{ item.exitEndtime.substring(0, 16) }}</div>
          </div>
          <div class="type">
            <img src="https://cdn.cunwuyun.cn/fengdu/ic-renwuleixing.png" alt="">
            <div class="label">任务类型：</div>
            <div class="value">{{ $dict.getLabel('fdIntegralTaskType', item.type) }}</div>
          </div>
        </div>
      </div>
    </div>
    <AiEmpty :description="`暂无任务`" class="emptyWrap" v-else/>
  </div>
</template>

<script>
export default {
  name: 'integralTask',
  appName: '积分任务',
  data() {
    return {
      list: [],
      current: 1,
    }
  },
  methods: {
    getList() {
      this.$instance.post('/app/appintegraltask/list',null,{
        params: {
          current: this.current,
          status: 1
        }
      }).then(res=> {
        if(res?.data) {
          this.list = this.current > 1 ? [...this.list, ...res.data.records] : res.data.records
        }
      })
    }
  },
  onShow() {
    uni.setNavigationBarTitle({
      title: '积分任务'
    });
    this.$dict.load(['fdIntegralTaskType']).then(() => {
      this.getList()
    })
  },
  onReachBottom() {
    this.current++
    this.getList()
  },
}
</script>

<style lang="scss" scoped>
.integralTask {
  padding-top: 292px;
  .fix-top {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    .img-bg {
      width: 100%;
      height: 216px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .title {
      font-size: 34px;
      font-weight: 500;
      color: #222222;
      padding: 32px 32px 0;
      background: #f3f5f7;
      z-index: 999;
      opacity: 1;
    }
  }
  
  .card-list {
    padding: 24px 32px;
    box-sizing: border-box;
    .card {
      background: #FFF;
      color: #333333;
      border-radius: 16px;
      margin-bottom: 24px;
      h4 {
        padding: 24px 24px 0;
        box-sizing: border-box;
        font-size: 34px;
        font-weight: 500;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      p {
        padding: 16px 24px;
        box-sizing: border-box;
        font-size: 28px;
        font-weight: 400;
      }
      .imgs {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        padding: 16px 24px;
        box-sizing: border-box;

        image {
          height: 208px;
          width: 33.33%;
          padding-right: 12px;
          margin-bottom: 12px;
          box-sizing: border-box;

          &:nth-of-type(3n) {
            padding-right: 0;
          }
        }
      }

      .time {
        padding: 0 24px 24px;
        box-sizing: border-box;
        border-top: 2px solid #EEEEEE;
        & > div {
          margin-top: 16px;
        }
        .goin,
        .exit,
        .type {
          display: flex;
          img {
            width: 30px;
            height: 30px;
            align-self: center;
          }
          .label {
            font-size: 24px;
            font-weight: 400;
            color: #666666;
            align-self: center;
            width: 130px;
          }
          .value {
            color: #333333;
            font-size: 24px;
            font-weight: 400;
            width: calc(100% - 160px);
          }
        }
      }
    }
  }
}
</style>