65 lines
1.3 KiB
Vue
65 lines
1.3 KiB
Vue
<template>
|
|
<div id="canvas" style="position: relative;border: 1px dashed #d5d2d2;width: 100%">
|
|
<van-button plain type="danger" hairline size="small" class="clearBtn" @click="reset">清空重签</van-button>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
module.exports = {
|
|
props: {
|
|
my_sign: {
|
|
type: String
|
|
}
|
|
},
|
|
methods: {
|
|
reset() {
|
|
$('#canvas').jSignature('reset')
|
|
this.$emit("update:my_sign", null)
|
|
},
|
|
checkNull() {
|
|
return $('#canvas').jSignature('getData', 'native').length === 0
|
|
},
|
|
submitSign() {
|
|
this.$emit("update:my_sign", $('#canvas').jSignature('getData'))
|
|
},
|
|
async updateSign() {
|
|
const data = await $.post("/mobile/common/signing/update", {sign: $('#canvas').jSignature('getData')})
|
|
},
|
|
async getMySign() {
|
|
const data = await $.get("/mobile/common/signing/getMySign")
|
|
if (data) {
|
|
console.log(this.my_sign)
|
|
|
|
$('#canvas').jSignature("importData", data)
|
|
this.$nextTick(() => {
|
|
|
|
})
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
this.getMySign()
|
|
},
|
|
async mounted() {
|
|
$("#canvas").jSignature({
|
|
width: '100%',
|
|
height: 300,
|
|
"decor-color": "transparent",
|
|
lineWidth: '3'
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
|
|
|
|
<style>
|
|
.clearBtn {
|
|
position: absolute !important;
|
|
bottom: 5px;
|
|
right: 5px;
|
|
color: red;
|
|
z-index: 99;
|
|
}
|
|
</style>
|