canvas 手写签名 微信小程序

 很多时候,程序中需要用到签名的功能,附上源码(微信小程序)

.wxml

<view class="canvasBox">
      <view class="canvasTitle">请签名:</view>
      <view class="canvasContent">
        <view class="singatureTag">签名区域</view>
        <canvas style="width: {
  {canvasw}}px; height: {
  {canvash}}rpx;line-height:{
  {canvash}}rpx" disable-scroll="true"
          canvas-id="myCanvas" bindtouchstart="touchStart" bindtouchmove="touchMove" bindtouchend="touchEnd"
          touchcancel="canvasEnd" binderror="canvasIdErrorCallback"></canvas>
      </view>
</view>


<view class="next" style="padding-bottom:calc({
  {iphonex_height}}px + 20rpx);">
      <view class="next-list">
        <van-button round custom-style='font-size:30rpx;border-radius:20px;width:60%;' type="info" plain color="#5359a7"
          catchtap="clearDraw">清  除</van-button>
      </view>
      <view class="next-list">
        <van-button round custom-style='font-size:30rpx;width:60%;' type="info" color="#1417b7" catchtap="submitDraw">
          提  交</van-button>
      </view>
</view>

 .js

data: {
    iphonex_height: app.globalData.iphonex_safe_area_height, //inphonex安全区高度
    currentColor: '#000',
    canvasw: 0,
    canvash: 0,
    userId: '',
    signFile: '',
    base64: '',
  },

/**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      userId: options.userId,
      signFile: options.signFile,
      name: options.name,
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值