<template>
  <div class="" style="padding: 20px; height: 100%">
    <div class="title" style="height:5%; width:100%">
      <div style="
              width: 100%;
              height:100%;
              text-align: center;
              border-radius: 5px;
              padding-top: 7px;
              background-color: #ddd;
              font-size: 16px;
              font-weight: 700;
              color: #11111187;
            ">
        合同信息
      </div>
    </div>
    <div class="search">
      <div class="searchInput">
        <input v-model="searchCondition.input" placeholder="请输入机号信息">
        <button style="position:absolute;right:10px" @click="detectSearchCondition()">搜索</button>
      </div>
    </div>
    <div v-if="ListNum != 0" class="billList">
      <article v-for="(item, index) in massages" :key="item.id" class="article" style="margin-top:10px">
        <img slot="left-icon" src="../../../assets\electronicContract\contract-list.png" class="icon">
        <div slot="name" class="text" style="width: 80%;font-size: 12px;">
          <div class="cont-type" style="color: #000;font-size: 14px;font-weight:700">承租人：{{ item.customername }}
          </div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">经销商：{{ item.dealername }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">产品名称：{{ item.modelname }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">合同号：{{ item.contractno }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">机号：{{ item.serialno }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">租金总额：{{ item.contractamt }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">租赁开始日：{{ item.leasebgndt }}</div>
          <div class="cont-type" style="color: #5a5959;font-size: 14px">状态：<span style="font-weight: 700;
          color: rgba(198, 0, 0, 0.5);">{{ item.status }}</span></div>
        </div>
        <button @click="download(index)">账单下载</button>
        <router-link v-if="item.status == '还款中'" :to="{name:'CmbPolyPayDetail',query:{contractno:item.contractno}}">
          <img src="../../../assets\image\right-arrow@2x.png" class="more" alt="">
        </router-link>
      </article>
    </div>
    <div v-else-if="ListNum == 0" class="billList">
      <div style="
              width: 200px;
              height: 160px;
              position: relative;
              left: 50%;
              top: 100px;
              transform: translateX(-100px);
            ">
        <img src="../../../assets\image\nobill.png" style="width: 200px; height: 160px" alt="">
        <p style="text-align: center; color:#555;">暂无相关合同信息</p>
      </div>
    </div>
  </div>
</template>

<script>
import { getUrlParam } from '@/scripts/utils'
export default {
  data () {
    return {
      ListNum: 0,
      massages: [],
      searchCondition: {
        input: null,
      },
    }
  },
  created () {
    if (window.localStorage.openId) {
      this.searchBill(window.localStorage.openId)
    }
  },
  mounted () { },
  methods: {
    searchBill (openId) {
      let vm = this
      let value = vm.searchCondition.input
      let url = process.env.basePath + 'getCmbConList'
      // console.log('请求数据')
      let params = {
        openId: 'oBdoRwAgUiwsQvNGYhBYks6JJLPE',
        // openId: openId,
        serialno: value,
      }
      // console.log("请求");
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, params).then(function (res) {
        vm.hlsPopup.hideLoading()
        // console.log(res)
        if (res.result.respCode === 'S') {
          var dataInfo = JSON.parse(res.result.json)
          vm.ListNum = dataInfo.lists.length
          vm.massages = dataInfo.lists
        } else {
          vm.ListNum = 0
          vm.hlsPopup.showLongCenter('查询合同列表失败' + res.result.respMsg)
        }
      })
    },
    download (index) {
      console.log('下载')
    },
    detectSearchCondition () {
      this.searchBill(window.localStorage.openId)
    },
  },
}
</script>

<style lang="less" type="text/less" scoped>
.search {
  display: flex;
  //height: 50px;
  background-color: #fff;
  margin-top: 10px;
  // margin-bottom: 10px;
  position: relative;
  border: 1px solid #cccccc;
  border-radius: 20px;
  .searchInput {
    margin-left: 5%;
    display: -webkit-flex;
    /* margin: 0.14rem 0.2rem; */
    width: 80%;
    height: 0.56rem;
    display: -webkit-box;
    display: flex;
    -webkit-box-align: center;
    align-items: center;
    -webkit-align-items: center;
    input {
      text-align: center;
      width: 90%;
      margin-left: 5%;
      font-size: 13px;
      height: 17px;
      line-height: 17px;
      border: none;
      margin-top: 3px;
      margin-bottom: 4px;
      //padding-left: 11px;
    }
  }
  button {
    margin-right: -10px;
    background-color: rgb(230, 230, 230);
    border: 1px solid #cccccc;
    border-radius: 20px;
    width: 20%;
    height: 100%;
  }
}
// 账单卡片列表
.billList {
  //账单卡片
  width: 100%;
  .article {
    position: relative;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    margin: 0 auto 12px;
    height: 200px;
    width: 98%;
    .text {
      margin-left: 45px;
      position: relative;
      top: 50%;
      transform: translateY(-50%);
      .cont-type {
        padding-top: 2px;
        width: 100%;
        word-wrap: break-word;
      }
      :nth-child(1) {
        width: 200px;
      }
    }
    .icon {
      //左侧图标
      position: relative;
      float: left;
      width: 40px;
      padding-left: 5px;
      top: 50%;
      transform: translateY(-20px);
      img {
        width: 40px;
        height: 40px;
      }
    }
    .left-icon {
      width: 40px;
      margin-right: 0;
    }
    button {
      position: absolute;
      top: 12px;
      right: 5px;
      width: 70px;
      height: 25px;
      font-size: 12px;
      background-color: #d1d1d1;
      border: 2px solid #dcd0d0;
      border-radius: 5px;
      padding-right: 1px;
      padding-left: 1px;
    }
    .more {
      position: absolute;
      right: 5px;
      top: 50%;
      transform: translateY(-16px);
    }
    box-shadow: 3px 3px 3px 3px #b6b6b6;
  }
  padding-bottom: 30px;
  .text {
    margin-left: 15px;
    line-height: 16px;
  }
}
</style>
