欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

小程序?qū)崿F(xiàn)手寫板簽名

 更新時(shí)間:2022年07月08日 08:03:58   作者:李湘湘  
這篇文章主要為大家詳細(xì)介紹了小程序?qū)崿F(xiàn)手寫板簽名,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了小程序?qū)崿F(xiàn)手寫板簽名的具體代碼,供大家參考,具體內(nèi)容如下

1.wxss代碼

page {
? ? background: #F8F8F8;
}
/* 簽名 */
.qianming {
? ? background: #fff;
? ? padding: 20rpx 30rpx;
? ? font-size: 32rpx;
? ? color: #333;
? ? padding-bottom: 0;
? ? position: fixed;
? ? bottom: 0;
? ? left: 0;
? ? width: 92%;
? ? height: 47%;
}

.qianming .clear {
? ? font-size: 26rpx;
? ? color: #669AF2;
}

.flex-def {
? ? display: flex;
}

.flex-one {
? ? flex: 1;
}

.flex-cCenter {
? ? align-items: center;
}

/* 底部按鈕 */
.bottom_btn {
? ? font-size: 32rpx;
? ? color: #fff;
? ? padding: 30rpx 0;
? ? background: #fff;
? ? width: 100%;
}

.bottom_btn view {
? ? width: 100%;
? ? background: #FF083C;
? ? border-radius: 40rpx;
? ? height: 80rpx;
? ? line-height: 80rpx;
? ? text-align: center;
}

/*隱藏滾動(dòng)條*/
::-webkit-scrollbar {
? ? width: 0;
? ? height: 0;
? ? color: transparent;
? ? display: none;
}

2.wxml代碼

<view class="qianming">
? ? <view class="qianming_top flex-def flex-cCenter" wx:if="{{is_sign==1}}">
? ? ? ? <view class="flex-one">簽名</view>
? ? ? ? <view class="clear" bindtap="clear">清空</view>
? ? </view>
? ? <view class="canvas">
? ? ? ? <canvas style="width: 100%;height: 360rpx;border: 1px #eee solid;background-color: #fff;border-radius: 16rpx;margin-top: 20rpx;" canvas-id="firstCanvas" id='firstCanvas' bindtouchstart="bindtouchstart" bindtouchmove="bindtouchmove"></canvas>
? ? </view>
? ? <view class="bottom_btn">
? ? ? ? <view class="skin-bg-{{theme}}" bindtap='export'>我已知悉并同意</view>
? ? </view>
</view>

3.js代碼

data: {
? ? ? ? context: null,
? ? ? ? imgUrl: "",
? ? ? ? index:0,//用來(lái)判斷是否簽名
? ? },
? ? /**記錄開始點(diǎn) */
? ? bindtouchstart: function (e) {
? ? ? ? this.data.context.moveTo(e.changedTouches[0].x, e.changedTouches[0].y)
? ? ? ? // 記錄已經(jīng)開始簽名
? ? ? ? this.setData({
? ? ? ? ? ? index:1
? ? ? ? })
? ? },
? ? /**記錄移動(dòng)點(diǎn),刷新繪制 */
? ? bindtouchmove: function (e) {
? ? ? ? this.data.context.lineTo(e.changedTouches[0].x, e.changedTouches[0].y);
? ? ? ? this.data.context.stroke();
? ? ? ? this.data.context.draw(true);
? ? ? ? this.data.context.moveTo(e.changedTouches[0].x, e.changedTouches[0].y);
? ? ? ? // 記錄已經(jīng)開始簽名
? ? ? ? this.setData({
? ? ? ? ? ? index:1
? ? ? ? })
? ? },
? ? /**清空畫布 */
? ? clear: function () {
? ? ? ? this.data.context.draw();
? ? ? ? this.setData({
? ? ? ? ? ? index:0
? ? ? ? })
? ? },
? ? /**導(dǎo)出圖片 點(diǎn)擊確定按鈕*/
? ? export: function () {
? ? ? ? const that = this;
? ? ? ??
? ? ? ? ? ? if (that.data.index==0) {
? ? ? ? ? ? ? ? wx.showToast({
? ? ? ? ? ? ? ? ? ? title: '請(qǐng)閱讀并簽名',
? ? ? ? ? ? ? ? ? ? icon: 'none',
? ? ? ? ? ? ? ? ? ? duration: 2000
? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? return
? ? ? ? ? ? ? ? }
? ? ? ? ? ? that.data.context.draw(true,
? ? ? ? ? ? ? ? wx.canvasToTempFilePath({
? ? ? ? ? ? ? ? ? ? x: 0,
? ? ? ? ? ? ? ? ? ? y: 0,
? ? ? ? ? ? ? ? ? ? fileType: 'png',
? ? ? ? ? ? ? ? ? ? canvasId: 'firstCanvas',
? ? ? ? ? ? ? ? ? ? success(res) {
? ? ? ? ? ? ? ? ? ? ? ? that.upload_image(res.tempFilePath)
? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? fail() {
? ? ? ? ? ? ? ? ? ? ? ? wx.showToast({
? ? ? ? ? ? ? ? ? ? ? ? ? ? title: '簽名失敗',
? ? ? ? ? ? ? ? ? ? ? ? ? ? icon: 'none',
? ? ? ? ? ? ? ? ? ? ? ? ? ? duration: 2000
? ? ? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? })
? ? ? ? ? ? )
? ? ? ? }

? ? ? ??
? ? },
? ? // 將圖片保存到服務(wù)器
? ? upload_image(imgurl) {
? ? ? ? var that = this;
? ? },

4.注意json文件必須加這個(gè)參數(shù)為true,否則簽名時(shí)晃動(dòng)

{
"disableScroll": true
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論