<template>
  <div class="home_wrapper">
    <!--  头部开始  -->
    <div class="header">
      <div class="header_left" @click="onClickLeft">
        <img src="../../../../static/images/agriculturalTrusteeship/return.png">
        <p>{{tt}}</p>
      </div>
    </div>
    <!--  头部结束  -->

    <!--  内容开始  -->
    <div class="main">
      <div class="search">
        <img src="../../../../static/images/agriculturalTrusteeship/index/search_icon_01.png" />
        <input type="text" placeholder="输入需求进行搜索" v-model="searchInput" />
        <img src="../../../../static/images/agriculturalTrusteeship/index/search_icon_02.png" @click="goSearch" />
      </div>

      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="getList"
      >
        <!--            @load="onLoad"-->
        <div class="main_content_right_list" v-for="(item,index) in productListYes" @click="$router.push({name:'agriculturalTrusteeshipSocietyProjectDetail',query:{id:item.id}})">
          <img v-if="item.mainImg" :src="item.mainImg" style="width: 18vw;height: 18vw;">
          <img v-else src="../../../../static/images/agriculturalTrusteeship/zwtp.png" style="width: 18vw;height: 18vw;">
          <div class="main_content_right_list_content">
            <p class="tt">{{item.productName}}</p>
<!--                <div class="tab">-->
<!--                  <p>￥<span>66</span>.00/亩</p>-->
<!--                  <p><span>销 600</span><span>分 4.7</span></p>-->
<!--                </div>-->
            <p class="name">{{item.productType}}</p>
          </div>
        </div>
      </van-list>
    </div>
    <!--  内容结束  -->

  </div>
</template>
<script>
  import Cookies from "js-cookie";
  import {productList, serviceList} from "@/api/agriculturalTrusteeship";
  export default {
    name: "agriculturalTrusteeshipInsuranceList",
    data() {
      return {
        activeKey: 0,
        active: 0,
        loading: false,
        finished: false,
        productListYes:[],
        productListNo:[],
        productList:[],
        query:{
          financialServiceId:'',
          productName:'',
        },
        tt:'',
        searchInput:'',
      };
    },
    created() {
      this.query.financialServiceId = this.$route.query.id;

      this.tt = this.$route.query.financialName
    },
    methods: {
      getList(){
        productList(this.query).then(response => {
          response.rows.map(res=>{
            if(res.sysYesNo == 'Y'){
              if (res.mainImg){
                let supplyMasterMap = res.mainImg.split( "," )
                res.mainImg = '/api'+supplyMasterMap[0]
              }
              this.productListYes.push(res);
            }
            if(res.sysYesNo == 'N'){
              this.productListNo.push(res);
            }
            this.productList.push(res);
          })
          if(this.productList.length >= response.total){
            this.finished = true;
            return;
          }else{
            this.loading = false;
            this.query.pageNum += 1 ;
          }
        });
      },

      goSearch(){
        this.productListYes = [];
        this.query.productName = this.searchInput;
        this.getList();
      },
    },
  }
</script>
<style scoped lang="scss">
.home_wrapper{
  height: 100vh;
  background: #ffffff url("../../../../static/images/agriculturalTrusteeship/insurance/insurance_list_head.png") no-repeat;
}
  /*头部*/
  .header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2vh 4% 2vh;
    .header_left{
      display: flex;
      align-items: center;
      p{
        font-size: .4rem;
        color: #ffffff;
        line-height: 1;
        margin-left: 10PX;
      }
    }
    .header_right{
      font-size: .35rem;
      background: #ffffff url("../../../../static/images/agriculturalTrusteeship/address.png") no-repeat 10PX center;
      padding: 2PX 15PX 2PX 25PX;
      border-radius: 50PX;
    }
  }

  /* 内容 */
  .main{
    background: #ffffff;
    padding-top: 2vh;
    border-top-left-radius: 25PX;
    border-top-right-radius: 25PX;
    /deep/ .van-tabs__nav{
      border-top-left-radius: 25PX;
      border-top-right-radius: 25PX;
      overflow: hidden;
    }
    /deep/ .van-tabs__line{
      background: #334281!important;
    }
    /deep/ .van-tab--active{
      color: #334281;
    }
    /deep/ .van-tabs__content{
      background: #ffffff;
      padding-top: 2vh;
    }
    .search{
       display: flex;
       justify-content: space-between;
       align-items: center;
       width: 92%;
       margin: 0PX auto;
       border: 1px solid #6E93F3;
       padding: 1PX 1PX 1PX 12PX ;
       border-radius: 50PX;
       input{
         flex: 1;
         background: transparent;
         margin-left: 10PX;
       }
    }
    .main_content_right_list{
      display: flex;
      margin: 0 auto;
      margin-top: 2vh;
      width: 92%;
      img{
        border-radius: 15PX;
        margin-right: 4%;
        width: 20%;
      }
      .main_content_right_list_content{
        display: flex;
        flex-direction:column;
        justify-content: space-between;
        align-items: start;
        .tt{
          color: #333333;
          font-size: .35rem;
        }
        .tab{
          display: flex;
          justify-content: space-between;
          p{
            &:nth-child(1){
              flex: 1;
              color: #FF5E00;
              span{
                font-size: .4rem;
              }
            }
            &:nth-child(2){
              flex: 1;
              span{
                width: 50%;
                display: inline-block;
                text-align: center;
                padding: 2PX 2PX;
                &:nth-child(1){
                  color: #497CE8;
                  background: #E2E9FD;
                  border-top-left-radius: 10PX;
                }
                &:nth-child(2){
                  color: #ffffff;
                  background-image: linear-gradient(to right , #5D87FA , #5FD5F5);
                  border-bottom-right-radius: 10PX;
                }
              }
            }
          }
        }
        .name{
          color: #497CE8;
          background: #E2E9FD;
          padding:2PX 5PX;
          border-radius: 5PX;
        }
      }
    }
  }
</style>
