2025-07-03 13:14:39 +08:00

27 lines
1.5 KiB
Plaintext

<!--case/pages/scan/scan.wxml-->
<view class="page">
<view class="camera-container" style="position: relative; width: 100%; height: 100vh;">
<camera
device-position="front"
flash="off"
mode="mode"
binderror="error"
style="width: {{cameraWidth}}px; height: {{cameraHeight}}px; position: absolute; top: {{cameraY}}px; left: {{cameraX}}px;"
></camera>
<!-- 四个角的拖拽手柄 -->
<view class="resize-handle tl" bindtouchstart="onResizeStart" bindtouchmove="onResizeMove" data-corner="tl"></view>
<view class="resize-handle tr" bindtouchstart="onResizeStart" bindtouchmove="onResizeMove" data-corner="tr"></view>
<view class="resize-handle bl" bindtouchstart="onResizeStart" bindtouchmove="onResizeMove" data-corner="bl"></view>
<view class="resize-handle br" bindtouchstart="onResizeStart" bindtouchmove="onResizeMove" data-corner="br"></view>
</view>
<canvas
canvas-id="myCanvas"
style="position: absolute; top: {{frameY}}px; left: {{frameX}}px; width: {{frameWidth}}px; height: {{frameHeight}}px;"
bindtouchstart="onTouchStart"
bindtouchmove="onTouchMove"
bindtouchend="onTouchEnd"
></canvas>
<!-- 临时 canvas 用于裁剪图片,隐藏处理 -->
<canvas canvas-id="tempCanvas" style="position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px;"></canvas>
<button type="primary" bindtap="takePhoto" class="btn">拍照</button>
</view>