uniAPP 小程序 签名组件

本文详细介绍了如何创建并使用一个横屏签名插件,包括插件的代码结构、功能实现以及在引用页面的配置。插件提供开始、结束、清除和保存签名操作,支持显示和触屏事件处理。通过引入和设置,可以在手机端实现完美适配的签名功能。

该插件是横屏签名插件, 修改后的插件已经的可以拿来就是用的状态,增加了显示功能,先上效果图

下面介绍代码:1.首先是插件本身,建议复制代码到common中使用。

<template>
    <!-- 
        签名组件
        LYH
        横屏组件
     -->
    <view class="signa">
        <view class="btn">
            <view class="cancel-btn" @click="clear">
                <span class="iconfont" style="margin-right: 10px;">&#xe634;</span>
                重写
            </view>
            
            <view class="save-btn" @click="save">
                <span class="iconfont" style="margin-right: 10px;">&#xe6ef;</span>
                保存
            </view>
            
            <view class="cancel-bth" @click="colse">
                <span class="iconfont" style="margin-right: 10px;">&#xe6c8;</span>
                关闭
            </view>
        </view>
        <canvas class="canvas" disable-scroll="true" :style="{'width':width,'height':height}" canvas-id="designature" @touchstart="starts"
        @touchmove="moves" @touchend="end"></canvas>
    </view>
</template>

<script>
    export default {
        components: {},
        data() {
            return {
                dom: null,
                line: [],
                radius: 0,
                width: '0px',
                height: '0px',
            }
        },
        onLoad() {
            
        },
        computed:{
            
        },
        created() {
            uni.getSystemInfo({
                success: (res) => {
                    this.width = res.windowWidth - 60 + 'px';
                    this.height = res.windowHeight - 15 + 'px';
                }
            });
            this.dom = uni.createCanvasContext('designature',this);
            
        },
        onShow(){
            
        },
        methods: {
            end(e) {
                
            },
            distance(a, b) {
                let x = b.x - a.x;
                let y = b.y - a.y;
                return Math.sqrt(x * x + y * y)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值