Skip to content

Commit

Permalink
refine: sign
Browse files Browse the repository at this point in the history
  • Loading branch information
feige996 committed Feb 1, 2024
1 parent 50817a5 commit a0c0e7c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/pages/demo/page/sign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</route>

<template>
<view class="canvas-box flex flex-col box-border p-3" :class="{ 'full-screen': full }">
<view class="canvas-box flex flex-col box-border p-3" :class="{ 'full-screen': isFullScreen }">
<canvas
canvas-id="canvas"
class="w-full b b-dashed b-rd b-gray-300 canvas"
Expand All @@ -20,13 +20,13 @@
/>
<view class="btns flex justify-between text-center box-border">
<view class="btn-box flex">
<view class="btn bg-gray-100 b-rd b-gray-300 c-gray-500 p-1" @click="handFullScreen"
>全屏</view
>
<view class="btn bg-gray-100 b-rd b-gray-300 c-gray-500 p-1" @click="handFullScreen">
{{ isFullScreen ? '退出全屏' : '全屏' }}
</view>
<view class="btn bg-gray-100 b-rd b-gray-300 c-gray-500 p-1 ml-2" @click="clear">清空</view>
<view class="btn bg-gray-100 b-rd b-gray-300 c-gray-500 p-1 ml-2" @click="withdraw"
>撤回</view
>
<view class="btn bg-gray-100 b-rd b-gray-300 c-gray-500 p-1 ml-2" @click="withdraw">
撤回
</view>
</view>
<view class="btn-box flex">
<view class="btn bg-sky-500 b-rd c-white p-1" @click="save">保存</view>
Expand All @@ -36,12 +36,12 @@
</template>

<script lang="ts" setup name="sign">
const full = ref(false)
const isFullScreen = ref(false)
const isSigned = ref(false)
let ctx = null
let isButtonDown = false
let points = []
let allPoints = []
const isSigned = ref(false)
// 初始化画布
function initCanvas() {
Expand Down Expand Up @@ -120,7 +120,7 @@ function clear(reset?: boolean) {
// 全屏
function handFullScreen() {
clear(true)
full.value = !full.value
isFullScreen.value = !isFullScreen.value
const tid = setTimeout(() => {
onResize()
clearTimeout(tid)
Expand Down Expand Up @@ -186,7 +186,7 @@ const save = () => {
const name = `sign-${new Date().getTime()}`
saveCanvasAsImage(tempFilePath, name)
// #endif
console.log(res)
// #ifndef H5
uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
Expand All @@ -195,7 +195,9 @@ const save = () => {
title: '图片保存成功',
})
},
fail: () => {
fail: (err) => {
console.error(err)
uni.showToast({
title: '图片保存失败',
icon: 'none',
Expand Down

0 comments on commit a0c0e7c

Please sign in to comment.