<template>
  <div class="esignBox">
    <span class="title">请进行手动签名</span>
    <vue-esign class="vue-esign" ref="esign" :isClearBgColor="false"  :width="width" :height="height"  :isCrop="isCrop" :lineWidth="lineWidth" :lineColor="lineColor" :bgColor="bgColor" />

    <div class="btnBox">
      <div class="cancel"  style="margin: 0 auto;" @click="cancel">取消</div>
      <div class="btnSign"  style="margin: 0 auto;" @click="confirmSign">确定签名</div>
    </div>

  </div>
</template>

<script>
export default {
  name: "signCom",
  data(){
    return {
      width:window.innerWidth,
      height:window.innerHeight-120,
      lineWidth: 4,
      lineColor: '#000000',
      bgColor: '#ffffff',
      resultImg: '',
      isCrop: true,
    }
  },
  mounted() {
    this.$refs.esign.reset()
  },
  methods:{
    cancel(){
      this.$refs.esign.reset()
      this.$emit('cancel')
    },
    confirmSign(){
      this.$refs.esign.generate({quality:0.2,format:'image/jpeg'}).then(res=>{
        this.$emit('confirmSign',res)
        this.$refs.esign.reset()
      }).catch(err=>{})
    },
  },
}
</script>

<style scoped lang="less">

.esignBox{
  width: 100%;
  height: 100%;
  .title{
    width: 100%;
    display: inline-block;
    height: 60px;
    text-align: center;
    line-height: 60px;
    background-color: white;
    font-size: 22px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #01040D;
  }
.btnBox{
  width: 100%;
  height: 60px;
  display: flex;
  .cancel{
    width: 50%;
    height: 60px;
    background-color: #F4F5F6 ;
    color: #6C5DD3;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .btnSign{
    width: 50%;
    height: 60px;
    background-color: #F4F5F6 ;
    color: #6C5DD3;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
}
</style>