<template>
	<view class="container">
		<view class="title">
		    <view>
		      <text class="line"></text>电子签名<text style="font-size: 20rpx;font-weight: normal;">（请书写工整，字迹清晰）</text>
		    </view>
		    <text class="page_mark">8/8</text>
		</view>
		<view class="signatureContent">
			<e-signature :showCanvas="showCanvas" ref="signatureComponent" @sendImage="getImage"></e-signature>
		</view>
		<view class="fixed" url="bank-card" @click="save()">
		   我自愿签订推广人合同书
		</view>
	</view>
</template>

<script>
	import eSignature from '@/components/eSignature/eSignature.vue';
	import api from '../../api/api';
import { nextTick } from "vue";
	export default {
	    data() {
	        return {
				//打开canvas绘制签名
				showCanvas: true,
				//是否展示操作菜单
				completionSignPath: '' ,//签名
				applyParam:{
					personalSignOssPath:''
				}
	        }
	    },
		components:{eSignature},
		onLoad() {
			if(uni.getStorageSync('applyId')){
				setTimeout(()=>{
					this.queryById(uni.getStorageSync('applyId'))
				},500)
			}
		},
	    methods: {
			save(){
				this.$refs.signatureComponent.finish()
			},
			queryById(id){
				api.queryById(id).then((res)=>{
					if(res['success']){
						this.applyParam = res['data']['data'];
					}
				})
			},
			getImage(e){
				this.applyParam.personalSignOssPath = e;
				api.saveApplyInfo(this.applyParam).then((res)=>{
					console.log(res)
					if(res['success']){
						
					}else{
						uni.showToast({
							title: res['message'],
							duration: 2000,
							icon: 'none'
						})
						return;
					}
				})
				
			},
	    }
	}
</script>

<style lang="scss">
	@import 'applyCommon.scss';
	.signatureContent{
	    margin: 0 13px 20px 13px;
		height: 100%;
	}
	.signature_action{
	    display: flex;
	    justify-content: space-evenly;
	    margin-top: 20px;
	    uni-image{max-width: 60px;max-height: 60px;}
	}
</style>