<template>
  <h-view class="public-style electronic-contract-list" title="合同文本清单">
    <h-content>
      <div style="margin-top:20px">
        <div class="contract-list-item" v-for="(item,index) in data" :key="index">
          <img src="../../../assets/electronicContract/contract-list.png" alt />
          <div class="contract-list-text">
            <div>{{item.file_sign_name}}</div>
            <p style="color:red;margin-top:3px"></p>
          </div>

        </div>
      </div>
      <div class="footer" @click="createSign()">签约</div>
    </h-content>
  </h-view>
</template>

<script>
export default {
  data() {
    return {
      isModalVisible: false,
      con_list: [],
      infoShow: {},
      info: null,
      searchCondition: {
        input: null
      },
      data: []
    };
  },
  components: {},
  created() {
     if(this.$route.params.itemData){
      // console.log('33333333333',this.$route.params.itemData.un_sign_file_list)
    window.localStorage.unSignData = JSON.stringify(this.$route.params.itemData.un_sign_file_list);

    }
    this.data = JSON.parse(window.localStorage.unSignData);
    this.wxConfig();
    this.offsize = 1;
    this.pagesize = 10;
    this.index = [1, 0, 0];
  },
  mounted() {
    // this._initLoad()

  },
  activated(){
    if(this.$route.params.itemData){
      // console.log('33333333333',this.$route.params.itemData.un_sign_file_list)
    window.localStorage.unSignData = JSON.stringify(this.$route.params.itemData.un_sign_file_list);

    }
    this.data = JSON.parse(window.localStorage.unSignData);
  },

  methods: {
    createSign() {
      let goUrl = this.data[0].sign_url
      if (goUrl) {
        //
        // this.hlsPopup.showLoading("请稍等");
        window.open(goUrl, "_self");
        // let url = window.open('http://www.baidu.com','_self');

        // if(url == null){

        // }

      }
      else{
        this.$vux.toast.text('跳转链接不存在!', "middle");
      }
      // 打开模态框
    },

    // load_count: function() {
    //   let vm = this;
    //   let url = process.env.basePath + "contract_count";
    //   let param = {};
    //   // hlsPopup.showLoadingWithoutBackdrop();
    //   vm.$post(url, param).then(function(res) {
    //     vm.info = res;
    //     vm.changeData();
    //   });
    // },

    // loadMore: function() {
    //   let vm = this;
    //   vm.offsize = vm.offsize + 1;
    //   let url = process.env.basePath + "app_get_contract_selected";
    //   let param = {
    //     offsize: vm.offsize,
    //     searchInput: vm.searchCondition.input
    //   };
    //   vm.$post(url, param).then(function(res) {
    //     let returnData = [];
    //     returnData = res.getContract_list;
    //     if (returnData.length === 0) {
    //       vm.$refs.scroll.update(true);
    //     } else if (returnData.length > 0 && returnData.length < vm.pagesize) {
    //       vum.forEach(returnData, function(data, index, array) {
    //         vm.con_list.push(array[index]);
    //       });
    //       vm.$refs.scroll.update(true);
    //     } else if (returnData.length === vm.pagesize) {
    //       vum.forEach(returnData, function(data, index, array) {
    //         vm.con_list.push(array[index]);
    //       });
    //       vm.$refs.scroll.update(false);
    //     }
    //   });
    // },
    // goContractMainten: function (list) {
    //   this.$router.push({
    //     name: 'ContractSign',
    //     params: {
    //       contract_id: list.contract_id,
    //       cdd_list_id: list.cdd_list_id,
    //     },
    //   })
    // },
    // 调用微信接口的基础配置
    wxConfig() {
      let clientUrl = "";
      let u = navigator.userAgent;
      let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
      let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      if (isAndroid) {
        //这个是安卓操作系统
        console.log("机型：android");
        clientUrl = location.href;
      }
      if (isIOS) {
        //这个是ios操作系统
        console.log("机型：ios");
        clientUrl = location.href.split("#")[0];
      }
      // let url = $config.rootPath + '/js/sdk/getWxConfig?wxCode=' + $config.wxCode + '&clientUrl=' + clientUrl
      let url = process.env.basePathRl + "getSignature";
      let param = {
        apiKey: "handexinxi",
        url: clientUrl
      };
      hlsHttp.post(url, param).then(function(res) {
        wx.config({
          beta: true,
          debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
          appId: res.result.appId, // 必填，公众号的唯一标识
          timestamp: res.result.timestamp, // 必填，生成签名的时间戳
          nonceStr: res.result.nonceStr, // 必填，生成签名的随机串
          signature: res.result.signature, // 必填，签名，见附录1
          jsApiList: [
            "chooseImage",
            "previewImage",
            "downloadImage",
            "getLocalImgData",
            "uploadImage",
            "hideOptionMenu"
          ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
        wx.ready(function() {
          wx.hideOptionMenu();
        });
      });
    }
  }
};
</script>

<style lang="less" rel="stylesheet">
.electronic-contract-list {
  .content {
    // overflow: hidden;
    font-size: 14px;
    .contract-list-item {
      height: 60px;
      margin: 10px 20px;
      border: 1px solid #b2b2b2;
      padding: 14px 10px 0 10px;
      img {
      }
      .contract-list-text {
        display: inline-block;
        margin-left: 30px;
      }
    }
    .footer {
      width: 120px;
      line-height: 30px;
      background-color: #09bb07;
      text-align: center;
      color: #ffffff;
      border-radius: 5px;
      margin: 50px auto;
    }
  }
}
</style>
