WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2024-03-19 88f58ada7a6afae4f79988f9a3d40366de738228
签名组件,绘图追加白底
1 files modified
26 ■■■■■ changed files
forms/userSignature/CSignatureLayer.vue 26 ●●●●● patch | view | raw | blame | history
forms/userSignature/CSignatureLayer.vue
@@ -94,8 +94,6 @@
            this.curLine = [];
            this.chirography = [];
            this.canvasContext.clearRect(0, 0, this.cavWidth, this.cavHeight);
            this.canvasContext.setFillStyle('#ffffff');
            this.canvasContext.fillRect(0, 0, this.cavWidth, this.cavHeight);
            this.canvasContext.draw();
        },
        handleClose() {
@@ -405,10 +403,33 @@
            }
            ctx.draw(true);
        },
        _brushingGround(callback) {
            Taro.canvasToTempFilePath({
                canvasId: this.cavId,
                x: 0,
                y: 0,
                width: Math.ceil(this.cavWidth),
                height: Math.ceil(this.cavHeight),
                destWidth: Math.ceil(this.cavWidth),
                destHeight: Math.ceil(this.cavHeight),
                quality: 1,
                fileType: 'png',
                success: res => {
                    const ctx = this.canvasContext;
                    ctx.setFillStyle('#ffffff');
                    ctx.fillRect(0, 0, this.cavWidth, this.cavHeight);
                    ctx.drawImage(res.tempFilePath, 0, 0);
                    ctx.draw(false, () => {
                        callback();
                    });
                },
            });
        },
        handleSaveDraw() {
            if (this.firstTouch) {
                Tools.toast('请书写签名!');
            }
            this._brushingGround(() => {
            const delta = 20;
            const clipArea = { x: 0, y: 0, w: 0, h: 0 };
            clipArea.x = Math.max(this.cutArea.left - delta, 0);
@@ -432,6 +453,7 @@
                    this.layerOpened = false;
                },
            });
            });
        },
    },
    mounted() {