<template>
  <div class="main-body">
    <topheader title="合同预览"></topheader>
    <iframe :src="contractSrc" frameborder="0" class="contractIframe"></iframe>
    <div class="submit-wrapper">
          <!-- <div @click="onSubmit">提交</div> -->

          <van-button block  type="primary" @click="createContract" native-type="submit">生成合同</van-button>
        </div>
  </div>
</template>

<script>
import Service from "../script/api/service";
import Topheader from "@/components/Topheader";
export default {
  name: "protocol",
  data() {
    return {
      contractSrc:'https://oss.esign.cn/1111564182/647fbc06-6c2b-4b6d-9d50-b2a0ffbe5599/esign_doc_96e9ecc041d14abda56b1691da6aa57e6424473970986064761.pdf.pdf?Expires=1597670541&OSSAccessKeyId=LTAI5cUiq89a7YXT&Signature=1qNcZe49mJA8KxCRgT5Ultq%2BEog%3D'
    };
  },
  computed: {},
  created(){
    let pdfUrl=sessionStorage.getItem('pdfUrl');
    this.contractSrc=pdfUrl;
  },
  mounted() {},
  watch: {},
  components: {
    Topheader
  },
  beforeDestroy() {},
  methods: {
    createContract(){
        let contractInfo=JSON.parse(sessionStorage.getItem('contractInfo'));
       let contractParams=contractInfo;
       console.log(contractParams);
      //  contractParams.serviceStartTime=new Date(contractInfo.serviceStartTime);
      //  contractParams.serviceEndTime=new Date(contractInfo.serviceEndTime);
       Service.$axiosCreateContract(contractParams).then(res => {
 if (res.data.errno == "-1") {
          this.$toast(res.data.data);
        } else if (res.data.errno == "0") {
           this.$dialog
            .alert({
              message: "发送成功"
            })
            .then(() => {
              this.$router.replace('./bjdc');
            });
        }
        });
    
    },
    queryLink: function() {
      window.location.href =
        "https://property.pingan.com/kehufuwu/fuwugongju/chanxianbaodanchayan.shtml";
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.main-body {
  background: #fff;
  /* height: 100vh; */
  /* padding: 0.3rem; */
  font-size: 0.24rem;
}
.contractIframe{
  width:100%;
  height: 90vh;
  overflow-y: scroll;
}
.submit-wrapper {
  position: fixed;
  z-index:999;
  bottom:0.24rem;
  left:0.5rem;
  right:0.5rem;
}
</style>
