<template>
  <h-view style="overflow:auto;" title="扫码支付">
    <div class="page-box" style="padding: 20px; height: 100%">
      <div style="height:12%; width:100%">
        <div class="title" style="height:42%; width:100%">
          <div>合同信息</div>
        </div>
        <div class="search" style="height:40%; width:100%">
          <div class="searchInput">
            <input
              v-model="searchCondition.input" placeholder="请输入机号信息" onfocus="this.placeholder=''"
              onblur="this.placeholder='请输入机号信息'">
            <button style="position:absolute;right:10px" @click="detectSearchCondition()">搜索</button>
          </div>
        </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-icon.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>
          <router-link v-if="item.status == '还款中'" :to="{ name: 'CmbPolyPayDetail', query: { contractno: item.contractno } }" class="more">
            <img src="../../../assets\image\right-arrow@2x.png" alt="">
          </router-link>
          <!--<button @click="download(item.contractno)">账单下载</button>-->
        </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>
  </h-view>
</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 (contractno) {
      // console.log('下载')
      window.open('https://lease.hitachics.com:8990/ReportServer?reportlet=/report/HCLC_PDR003.cpt&CONTRACTNO=' + contractno + '&format=PDF&extype=simple', '_self')
    },
    detectSearchCondition () {
      this.searchBill(window.localStorage.openId)
    },
  },
}
</script>

<style lang="less" type="text/less" scoped>
.title {
  border-radius: 5px;
  background-color: #ddd;
  display: flex;
  justify-content: space-around;
  align-items: center;

  div {
    height: 20px;
    line-height: 20px;
    font-size: 16px;
    font-weight: bolder;
    color: #11111187;
  }
}

.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: 15%;
    height: 100%;
    box-sizing: content-box;
    padding: 0px;
  }
}

// 账单卡片列表
.billList {
  //账单卡片
  width: 100%;
  padding-bottom: 30px;

  .article {
    position: relative;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    margin: 0 auto 12px;
    height: 200px;
    width: 98%;

    .text {
      float: left;
      line-height: 16px;
      margin-left: 5px;
      margin-right: 0px;
      position: relative;
      top: 50%;
      transform: translateY(-50%);

      .cont-type {
        padding-top: 2px;
        width: 97%;
        word-wrap: break-word;
      }
    }

    .icon {
      //左侧图标
      position: relative;
      float: left;
      width: 40px;
      padding-left: 5px;
      margin-right: 0;
      top: 50%;
      transform: translateY(-20px);

      img {
        width: 40px;
        height: 40px;
      }
    }

    button {
      position: absolute;
      bottom: 12px;
      right: 15px;
      width: 75px;
      height: 25px;
      font-size: 14px;
      color: #fff;
      background-color: rgb(0, 200, 0);
      border: 2px solid rgb(0, 200, 0);
      border-radius: 5px;
      padding-right: 1px;
      padding-left: 1px;
    }

    .more {
      top: 50%;
      transform: translateY(-50%);
      position: relative;
      float: left;
    }
    box-shadow: 3px 3px 3px 3px #b6b6b6;
  }
}
</style>
