<template>
  <div class="progress">
    <AiTopFixed>
      <div class="tab-select">
        <div class="item" :class="tabIndex == index ? 'active' : ''" v-for="(item, index) in tabs" :key="index" @click="tabClick(index)">{{item}}<span></span></div>
      </div>
      <div class="select-box">
        <div class="left">
          <!--  :areaId="user.areaId" @select="areaSelect" select-root -->
          <AiAreaPicker v-model="areaId" :name.sync="areaName" >
            <div style="display: flex;">
              <span v-if="areaName" style="color:#333;fontSize: 14px;" class="areaName">{{ areaName }}</span>
              <span v-else style="color: #999;fontSize: 14px;" class="areaName">所在地区</span>
              <u-icon name="arrow-down" color="#999" size="24" style="margin-left: 4px;width: 14px;display:inline-block;margin-top:18px"></u-icon>
              <u-icon name="close-circle" v-if="areaId" color="#999" size="24" style="margin-left: 4px;width: 14px;display:inline-block;margin-top:18px"></u-icon>
            </div>
          </AiAreaPicker>
        </div>
        <div class="right">
          <AiSelect dict="helpDeclarationStatus" v-model="status">
            <span v-if="!status" style="color: #999;">风险类型</span>
            <span v-else>{{status}}</span>
            <u-icon name="arrow-down" color="#999" size="24" style="margin-left: 4px;width: 14px;display:inline-block;"></u-icon>
            <u-icon name="close-circle" v-if="ststus" color="#999" size="24" style="margin-left: 4px;width: 14px;display:inline-block;"></u-icon>
          </AiSelect>
        </div>
      </div>
    </AiTopFixed>
    <div v-if="list.length">
      <div class="card_list" v-for="(item,index) in list" :key="index">
        <div class="card" @click="$linkTo(`./details?id=${item.id}`)">
          <div class="top">
            <div class="title">{{ item.riskDescription }}</div>
            <div class="time">{{ item.declareTime }}</div>
          </div>
          <div class="bottom">
            <span :style="{background: item.status == 0? '#FF883C':item.status == 1? '#1AAAFF': item.status==2? '#FF4466': '#42D784'}"></span>
            <span :class="item.status == 0? 'status0': item.status==1? 'status1': item.status==2? 'status3': 'status2'">{{ $dict.getLabel('helpDeclarationStatus',item.status) }}</span>
          </div>
        </div>
      </div>
    </div>
    <AiEmpty v-else description="暂无数据"/>

    <AiFixedBtn>
      <div class="addBtn iconfont iconfont-iconfangda" @tap="toAdd()"/>
    </AiFixedBtn>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tabs: ['全部待办','办理历史'],
      tabIndex: 0,
      list: [],
      current: 1,
      areaId: '',
      areaName: '',
      status: '',
    }
  },
  onShow() {
    this.$dict.load('helpDeclarationStatus')
    this.getList()
  },
  methods: {
    tabClick(index) {
      this.current = 1,
      this.list = [],
      this.tabIndex = index,
      this.getList()
    },

    getList() {
      this.$http.post('/app/apphelpdeclarationinfo/list',null,{
        params: {
          current: this.current,
          // status: this.tabIndex == 0 ? 
        }
      }).then((res) => {
        if(res?.data) {
          this.list = this.current == 1? res.data.records : [...this.list,...res.data.records]
        }
      })
    },

    toAdd() {
       uni.navigateTo({url: './add'})
    },

    onReachBottom() {
      this.current ++
      this.getList()
    }
  }
}
</script>

<style lang="scss" scoped>
.progress {
  // padding-top: 24px;
  ::v-deep .AiTopFixed .content {
    padding: 0;
  }

  .tab-select {
    width: 100%;
    height: 96px;
    line-height: 96px;
    background: #3975C6;
    display: flex;

    .item{
      flex: 1;
      text-align: center;
      font-size: 28px;
      font-family: PingFangSC-Regular, PingFang SC;
      color: #CDDCF0;
    }

    .active{
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      position: relative;
      color: #fff;
      span{
        width: 48px;
        height: 4px;
        background: #FFF;
        position: absolute;
        bottom: 14px;
        left: 50%;
        margin-left: -24px;
      }
    }
  }

  .select-box {
    display: flex;
    height: 96px;
    line-height: 96px;
    width: 100%;
    .left,
    .right {
      flex: 1;
      text-align: center !important;
      font-size: 28px;
    }
  }

  .card_list {
    padding: 0 32px;
    box-sizing: border-box;
    .card {
      background: #FFFFFF;
      box-shadow: 0px 0px 8px 0px #00000005;
      border-radius: 16px;
      margin-bottom: 24px;
      .top {
        padding: 32px;
        box-sizing: border-box;
        border-bottom: 2px solid #DDDDDD;
        .title {
          color: #333333;
          font-size: 32px;
          font-weight: 600;
          overflow:hidden; 
          text-overflow:ellipsis;
          display:-webkit-box;
          -webkit-box-orient:vertical;
          -webkit-line-clamp:2;
        }
        .time {
          margin-top: 32px;
          color: #999999;
          font-size: 26px;
        }
      }
      .bottom {
        padding: 32px;
        box-sizing: border-box;
        span:first-child {
          display: inline-block;
          width: 8px;
          height: 8px;
          border-radius: 50%;
          margin-right: 8px;
          background: #FF4466;
        }
      }
      .status0 {
        color: #FF883C
      }
      .status1 {
        color: #1AAAFF
      }
      .status2 {
        color: #42D784
      }
      .status3 {
        color: #FF4466
      }
    }
  }
}
</style>