国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微信小程序手寫(xiě)簽名

這篇具有很好參考價(jià)值的文章主要介紹了微信小程序手寫(xiě)簽名。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

wxml

<view class="container">
  <canvas class="canvas" id="canvas" canvas-id="canvas" disable-scroll="true" bindtouchstart="canvasStart"
    bindtouchmove="canvasMove" bindtouchend="canvasEnd" touchcancel="canvasEnd"
    binderror="canvasIdErrorCallback"></canvas>
  <view class="tips">
    請(qǐng)?jiān)诳騼?nèi)簽字
  </view>
  <view class='addBtn'>
    <button type="default" class='txt' bindtap="cleardraw">重新簽名</button>
    <button type="default" class='txt' bindtap="getimg">提交簽字</button>
  </view>
</view>

js

const fileManager = wx.getFileSystemManager();
 
// canvas 全局配置
var context = null; // 使用 wx.createContext 獲取繪圖上下文 context
var isButtonDown = false;
var arrx = [];
var arry = [];
var arrz = [];
var canvasw = 0;
var canvash = 0;
//獲取系統(tǒng)信息
wx.getSystemInfo({
  success: function (res) {
    canvasw = res.windowHeight * 3.0; //設(shè)備寬度
    // canvash = res.windowWidth * 7 / 15;
    canvash = res.windowWidth * 1.2;
  }
});
//注冊(cè)頁(yè)面
Page({
 
  /**
 1. 頁(yè)面的初始數(shù)據(jù)
   */
  data: {
    signFlag: false,
  },
 
  /**
 2. 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
   */
  onLoad: function (options) {
    context = wx.createCanvasContext('canvas');
    context.setFillStyle('#fff')
    context.fillRect(0, 0, canvasw, canvash)
    context.draw(true)
    context.beginPath()
    context.setStrokeStyle('#000000');
    context.setLineWidth(4);
    context.setLineCap('round');
    context.setLineJoin('round');
  },
  onShow() {
    arrx = [];
    arry = [];
    arrz = [];
  },
 
  isJSON(str) {
    if (typeof str == 'string') {
      try {
        var obj = JSON.parse(str);
        if (typeof obj == 'object' && obj) {
          return true;
        } else {
          return false;
        }
      } catch (e) {
        return false;
      }
    }
  },
 
  canvasIdErrorCallback: function (e) { },
  //開(kāi)始
  canvasStart: function (event) {
    isButtonDown = true;
    arrz.push(0);
    arrx.push(event.changedTouches[0].x);
    arry.push(event.changedTouches[0].y);
    //context.moveTo(event.changedTouches[0].x, event.changedTouches[0].y);
 
  },
  //過(guò)程
  canvasMove: function (event) {
    if (isButtonDown) {
      arrz.push(1);
      arrx.push(event.changedTouches[0].x);
      arry.push(event.changedTouches[0].y);
      // context.lineTo(event.changedTouches[0].x, event.changedTouches[0].y);
      // context.stroke();
      // context.draw()
    };
 
    this.setData({
      signFlag: true,
    })
 
    for (var i = 0; i < arrx.length; i++) {
      if (arrz[i] == 0) {
        context.moveTo(arrx[i], arry[i])
      } else {
        context.lineTo(arrx[i], arry[i])
      };
 
    };
 
    context.setStrokeStyle('#000000');
    context.setLineWidth(4);
    context.setLineCap('round');
    context.setLineJoin('round');
    context.stroke();
    context.draw(true);
  },
  canvasEnd: function (event) {
    isButtonDown = false;
  },
  cleardraw: function () {
    //清除畫(huà)布
    arrx = [];
    arry = [];
    arrz = [];
    context.clearRect(0, 0, canvasw, canvash);
    context.draw(true);
  },
  //導(dǎo)出圖片
  getimg: function () {
    let that = this
    if (arrx.length == 0) {
      wx.showModal({
        title: '提示',
        content: '簽名內(nèi)容不能為空!',
        showCancel: false
      });
      return false;
    };
    console.log(this.data.signFlag);
    if (!this.data.signFlag) {
      wx.showModal({
        title: '提示',
        content: '簽名內(nèi)容不能為空!',
        showCancel: false
      });
      return false;
    }
    //生成圖片
    wx.canvasToTempFilePath({
      canvasId: 'canvas',
      success: function (res) {
        //將圖片轉(zhuǎn)換為base64 的格式
        //let base64 = 'data:image/jpg;base64,' + fileManager.readFileSync(res.tempFilePath,'base64'); 
        //文件圖片類(lèi)型上傳
          wx.uploadFile({
          url: app.globalData.apiBaseUrl + app.globalData.uploadUrl,
          filePath: res.tempFilePath,//要上傳文件資源的路徑(本地路徑)
          name:'file',
          header: {
            'X-Access-Token': app.globalData.accessToken
          },
          success: function (res){
            const jsom = JSON.parse(res.data)
             //簽名圖片 oss地址
            let data = {}
            data.signature = jsom.message
            data.userId = that.data.userId
             api.contractSigning(JSON.stringify(data)).then(res => {
                  if (res.success){
                    util.showErrorToast("簽署成功");
                    setTimeout(()=>{
                      wx.navigateTo({
                        url: "/pages/index/index"
                      })

                    },1000)
                  }else {

                  }
             })
          },
          fail:function (err){
            
          }
        })
      }
    })
 
  },
 
})

wxss

page{
  background: #fff;
}
.container {
  width: 95%;
  position: absolute;
  height: 95%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  background: #fff;
  border-radius: 5px;
}
.canvas {
  width: 100%;
  height: 70%;
  border: 1px solid #aaa;
  box-sizing: border-box;
}
.tips{
  height: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #aaa;
}
  
.addBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 18%;
  position: fixed;
  bottom: 0;
  width: 100%;
  background: #fff;
  z-index: 100;
}
  
.addBtn .txt {
  text-align: center;
  width: 90%;
  font-size: 13px;
  border-radius: 100px;
  background: #0097fe;
  color: #fff;
  box-sizing: border-box;
  margin: 0 10px;
  padding: 10px;
  z-index: 100;
}

開(kāi)啟橫屏
json文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-718459.html

 "pageOrientation": "landscape

到了這里,關(guān)于微信小程序手寫(xiě)簽名的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 微信小程序手寫(xiě)簽字版

    在這里插入圖片描述 請(qǐng)?jiān)谙旅娴陌卓蛑泻灻?重置 提交 # js Page({ data: { signPath: [], cardNo: \\\'\\\', preX: \\\'\\\', preY: \\\'\\\', }, onLoad(options) { this.setData({ cardNo: options.cardNo }) wx.createSelectorQuery().select(\\\'#myCanvas\\\').fields({ node: true, size: true }).exec(this.init.bind(this)) }, init(data) { console.log(data); const width = dat

    2024年02月12日
    瀏覽(17)
  • 微信小程序簽名

    微信小程序簽名

    ? ? ? ? 最近項(xiàng)目中,甲方要求實(shí)現(xiàn)小程序簽名功能,功能已經(jīng)實(shí)現(xiàn),趁著空閑把代碼記錄一下。其實(shí)簽名的實(shí)現(xiàn)就是使用canvas,把手指經(jīng)過(guò)的路徑畫(huà)出來(lái),然后保存成圖片 先來(lái)看一下效果圖 ?我只實(shí)現(xiàn)了橫屏,畢竟豎屏簽字也不怎么方便(\\\"pageOrientation\\\":\\\"landscape\\\") 1、先來(lái)

    2024年02月16日
    瀏覽(17)
  • 微信小程序電子簽名組件

    微信小程序電子簽名組件

    微信小程序電子簽名組件,封裝抽離可復(fù)用,簽名成功輸出base64和臨時(shí)文件路徑,解決vant彈窗中使用導(dǎo)致背景滾動(dòng)問(wèn)題,寬度自適應(yīng),高度設(shè)置百分比,開(kāi)箱即用! 。 小程序根目錄創(chuàng)建components文件夾,簽名組件放在這個(gè)文件夾下,components文件夾下新建signature目錄, 代碼如下

    2024年02月16日
    瀏覽(17)
  • 微信小程序電子簽名及圖片生成

    在微信小程序中實(shí)現(xiàn)電子簽名及圖片生成的功能,可以通過(guò)使用canvas來(lái)實(shí)現(xiàn)。下面是實(shí)現(xiàn)步驟的簡(jiǎn)要介紹: 1. 在wxml文件中使用canvas標(biāo)簽創(chuàng)建畫(huà)布,指定畫(huà)布的寬度和高度,并設(shè)置一個(gè)唯一的id來(lái)標(biāo)識(shí)該canvas。 2. 在js文件中獲取到該canvas的上下文對(duì)象,可以使用wx.createCanvasCo

    2024年02月07日
    瀏覽(27)
  • 【微信小程序支付計(jì)算簽名值-前端】

    1、后端通過(guò)JSAPI下單接口獲取到發(fā)起支付的必要參數(shù)prepay_id,前端取到prepay_id就可以調(diào)用wx.requestPayment發(fā)起支付。調(diào)起支付的參數(shù)需要按照簽名規(guī)則進(jìn)行簽名計(jì)算。微信支付文檔 2、前端得到prepay_id后就可以按照規(guī)則計(jì)算簽名了。 2.1 構(gòu)造簽名串,簽名串一共有四行,每一行為

    2024年02月16日
    瀏覽(25)
  • uniapp寫(xiě)微信小程序?qū)崿F(xiàn)電子簽名

    uniapp寫(xiě)微信小程序?qū)崿F(xiàn)電子簽名

    寫(xiě)電子簽名一定要注意的是一切全部按照手機(jī)上的適配來(lái),為啥這么說(shuō)呢,因?yàn)槟阍谖⑿砰_(kāi)發(fā)者工具中調(diào)試的時(shí)候認(rèn)為是好的,正常的非常nice,當(dāng)你發(fā)布版本的時(shí)候你會(huì)發(fā)現(xiàn)問(wèn)題出來(lái)了。我下邊的寫(xiě)法你可以直接用很簡(jiǎn)單。就是要記住canvas的幾個(gè)屬性和用法。 直接上干貨 1.簽

    2024年01月18日
    瀏覽(19)
  • 微信小程序動(dòng)態(tài)生成表單來(lái)啦!你再也不需要手寫(xiě)表單了!

    微信小程序動(dòng)態(tài)生成表單來(lái)啦!你再也不需要手寫(xiě)表單了!

    由于我們?cè)谛〕绦蛏仙婕暗綌?shù)據(jù)采集業(yè)務(wù),需要經(jīng)常使用表單,微信小程序的表單使用起來(lái)非常麻煩,數(shù)據(jù)和表單是分離的,每個(gè)輸入框都需要做數(shù)據(jù)處理才能實(shí)現(xiàn)響應(yīng)式數(shù)據(jù),所以我開(kāi)發(fā)了 dc-vant-form ,針對(duì)原生微信小程序+ vant 組件構(gòu)建的自定義表單,開(kāi)發(fā)者可以通過(guò)表單

    2024年01月17日
    瀏覽(20)
  • uniapp微信小程序JSAPI支付前端生成簽名,并調(diào)起微信支付

    簽名方式使用的是SHA256withRSA 插件 npm install jsrsasign 使用

    2024年01月17日
    瀏覽(97)
  • 【微信小程序】基于jsrsasign的RSA簽名計(jì)算工具類(lèi)的實(shí)現(xiàn)

    微信小程序在后端進(jìn)行預(yù)付單操作后,由前端調(diào)起支付接口,此時(shí)需要對(duì)參數(shù)進(jìn)行 SHA256withRSA 簽名計(jì)算。 廢話(huà)少說(shuō),直接看東西 運(yùn)用以上代碼,就可以實(shí)現(xiàn)對(duì)消息體的SHA256 RSA簽名的計(jì)算,最后得到的是 Base64 的數(shù)據(jù)。 注意 :其中 privateKey 需要將密鑰文件完整的傳入,包括

    2024年02月11日
    瀏覽(41)
  • uni-app 微信小程序中如何通過(guò) canvas 畫(huà)布實(shí)現(xiàn)電子簽名?

    uni-app 微信小程序中如何通過(guò) canvas 畫(huà)布實(shí)現(xiàn)電子簽名?

    一、實(shí)際應(yīng)用場(chǎng)景 電子簽名軟件應(yīng)用場(chǎng)景:電子簽名在金融、銀行、貸款行業(yè)中可以用于對(duì)內(nèi)日常辦公流轉(zhuǎn)的文檔的蓋章簽字,對(duì)外涉及業(yè)務(wù)合作協(xié)議,采購(gòu)合同,貸款申請(qǐng)、信用評(píng)估、貸款合同、貸款文件表、說(shuō)明函等等。 可以說(shuō),只要是涉及紙質(zhì)文檔簽字蓋章的場(chǎng)景,

    2024年02月10日
    瀏覽(26)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包