<template>
    <view>
        <tui-modal :show="modal" custom @cancel="close">
            <Signature v-if="show" @input="input" />
        </tui-modal>
    </view>
</template>
<script>
import Signature from "./Signature.vue";
export default {
    components: { Signature },
    props: {
        destroyOnClose: Boolean,
    },
    data() {
        return {
            modal: false,
            show: false,
        };
    },
    methods: {
        handleClick(e) {
            let index = e.index;
            if (index !== 0) {
                this.$emit("confirm");
            } else {
                this.$emit("cancel");
            }
            this.modal = false;
        },
        input(base64) {
            this.$emit("input", base64);
        },
        open() {
            if (this.destroyOnClose) {
                if (this.show) {
                    return;
                }
                this.show = true;
                this.modal = true;
            } else {
                this.modal = true;
            }
        },
        close() {
            this.modal = false;
            if (this.destroyOnClose) {
                // 过度动画完成后再隐藏
                setTimeout(() => {
                    this.show = false;
                }, 200);
            }
        },
    },
};
</script>
<style lang="scss">
::v-deep .tui-modal-box {
    width: 95% !important;
    height: auto !important;
    padding: 0 40rpx 40rpx !important;
}
</style>
