<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>
      <img src="../../../../static/images/agriculturalTrusteeship/insurance/head_icon.png" @click="show=true">
    </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:'agriculturalTrusteeshipInsuranceProjectDetail',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>
    <!--  内容结束  -->
    <van-popup v-model="show" round closeable close-icon="close" style="width: 90%;">
      <div class="tt_box">
        <p class="content_tt">{{serviceForm.financialName}}</p>
        <div class="tab_box">
          <div class="tab_left">
            <p>产品 <span>{{serviceForm.products==null?'0':serviceForm.products.length}}</span></p>
          </div>
        </div>
      </div>
      <van-field readonly label="联系人" v-model="serviceForm.linker" input-align="right" placeholder="请输入联系人" />
      <van-field readonly label="地址" v-model="serviceForm.address" input-align="right" placeholder="请输入地址" />
      <van-field readonly label="电话" v-model="serviceForm.phone" input-align="right" placeholder="请输入电话" />
      <van-field readonly label="传真" v-model="serviceForm.fax" input-align="right" placeholder="请输入传真" />
      <van-field readonly label="简要描述" v-model="serviceForm.description" input-align="right" placeholder="请输入简要描述" />
      <div style="padding: 0 4% 2vh;">
        <van-uploader v-model="serviceForm.mainImgList" :show-upload="false" :deletable="false" />
      </div>
    </van-popup>
  </div>
</template>
<script>
  import Cookies from "js-cookie";
  import {entityGet, productList, serviceGet, serviceList} from "@/api/agriculturalTrusteeship";
  import MapGisTag from "@/components/Map/MapGisTagDTG";
  export default {
    name: "agriculturalTrusteeshipInsuranceList",
    components: {
      MapGisTag
    },
    data() {
      return {
        show:false,
        activeKey: 0,
        active: 0,
        loading: false,
        finished: false,
        productListYes:[],
        productListNo:[],
        productList:[],
        query:{
          financialServiceId:'',
          productName:'',
        },
        tt:'',
        searchInput:'',
        serviceForm:{}
      };
    },
    created() {
      this.query.financialServiceId = this.$route.query.id;

      this.tt = this.$route.query.financialName
      this.getUser();
    },
    methods: {
      //每个查看修改，新增  方法下引用下面方法
      mapClickLoading(){
        setTimeout(() => {
          this.$refs.clickLoading.pointPaceCountryDarw();
        }, 500);
      },
      getUser(){
        serviceGet(this.$route.query.id).then(response => {
          if (response.data.mainImg){
            response.data.mainImgList = [];
            var attachement = response.data.mainImg.split( "," );
            this.mainImgArr = response.data.mainImg.split( "," );
            attachement.forEach(responseAttach=>{
              response.data.mainImgList.push({
                url:'/api' + responseAttach,
                isImage: true
              });
            })
          }
          this.serviceForm = response.data;
        });
      },
      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;
}
.main_box{
  width: 92%;
  margin: 0 auto;
  margin-top: 2vh;
  border-radius: 10PX;
  overflow: hidden;
  background-color: #FFF;
  /deep/ .van-cell{
    padding: 0;
    margin-bottom: 10PX;
    &:last-child{
      margin-bottom: 0;
    }
  }
}
  /*头部*/
  .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;
        }
      }
    }
  }
.tt_box{
  border-bottom: 1PX solid #D1D8EB;
  padding: 2vh;
  .content_tt{
    font-size: .4rem;
    margin-bottom: 1.5vh;
    color: #334281;
  }
  .tab_box{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .tab_left{
      display: flex;
      p{
        &:nth-child(1){
          padding-right: 8PX;
          margin-right: 8PX;
        }
        span{
          color: #2B7EEC;
        }
        line-height: 1;
      }

    }
    .tab_right{
      display: flex;
      p{
        background: #F3F6FE;
        padding: 5PX 10PX;
        color: #497CE8;
        line-height: 1;
        border-radius: 5PX;
        margin-left: 10PX;
      }
    }
  }
}
</style>
