<template>
  <view class="page">
    <u-navbar class="u-navbar" title="电子合同" placeholder @leftClick="leftClick" leftIconColor="#fff"  bgColor="#00337A"  :titleStyle="{ color: '#FFF', fontSize: '32rpx' }"/>
	<view class="file-box">
	    <PdfView :path="webUrl" style="width: 100%;height: 80%!important;"/>
	</view>
	
	<view class="bottom-box">
		<view class="btn1" @click="leftClick">返回</view>
		<view class="btn2" @click="contractConfirm">确认合同</view>
	</view>
  </view>
</template>

<script>
import PdfView from '../../components/PdfView.vue'
import config from '@/config'
export default {
  components: { PdfView },
  data() {
    return {
		videoUrl:"",
		webUrl:``,
		contractData:{}
    }
  },
  onLoad(option) {
	this.webUrl=option.pdfUrl||"";
	 console.log(this.webUrl)  
	this.contractData=JSON.parse(option.contractData)
    console.log(this.contractData)  
  },
  onShow() {
  },
  methods: {
	contractConfirm(){
		console.log(this.contractData)
		uni.request({
		  url: config.realAppUrl + '/contract/addContractMessage',
		  method: 'post',
		  data: this.contractData,
		  header: {
			'Content-Type': 'application/x-www-form-urlencoded',
			Authorization: uni.getStorageSync('realNameToken')
		  },
		  success: res => {
			  console.log(res)
			res = res.data;
			if(res.code==200){
				console.log(res)
				uni.showToast({
					title: res.data,
					icon: 'none'
				})
				setTimeout(()=>{
					uni.reLaunch({
						url: `/pages/realName/workbench/index`
					})
				},1500)
			}
		  },
		  fail: err => {
			console.log(err)
		  }
		})
		
	},
    // 返回
    leftClick() {
      console.log('返回')
      uni.navigateBack({
      	delta: 1 // 返回
      });
    }
  },

}
</script>

<style lang="scss">
.page {
	width: 100vw;
	height: 100vh;
	background-color: #EFEFEF;
	box-sizing: border-box;
	position: relative;
	.file-box{
		width: 100%;
		height: 80vh;
		// overflow-y: auto;
		 
	}
	.bottom-box{
		width: 90%;
		margin: 0 auto;
		height: 120rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.btn1{
			width: 40%;
			height: 80rpx;
			display: flex;
			align-items: center;justify-content: center;
			color: #FFF;
			background: #00337A;
			border-radius: 10rpx;
		}
		.btn2{
			width: 40%;
			height: 80rpx;
			display: flex;
			align-items: center;justify-content: center;
			color: #FFF;
			background: #00337A;
			border-radius: 10rpx;
		}
	}
}
</style>
