From c5d3304eecc1fc1b02d5b23a6743ae16719e04cf Mon Sep 17 00:00:00 2001
From: yuanlei <18627959669@163.com>
Date: Fri, 19 Dec 2025 15:38:46 +0800
Subject: [PATCH] 1
---
.../vrapile-cut-image/vrapile-cut-image.vue | 385 ++++++++++-----------
uni_modules/vrapile-cut-image/readme.md | 2 +-
2 files changed, 183 insertions(+), 204 deletions(-)
diff --git a/uni_modules/vrapile-cut-image/components/vrapile-cut-image/vrapile-cut-image.vue b/uni_modules/vrapile-cut-image/components/vrapile-cut-image/vrapile-cut-image.vue
index b0661e2..1149f80 100644
--- a/uni_modules/vrapile-cut-image/components/vrapile-cut-image/vrapile-cut-image.vue
+++ b/uni_modules/vrapile-cut-image/components/vrapile-cut-image/vrapile-cut-image.vue
@@ -1,92 +1,92 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
-
-
-
-
-
-
+
-
-
-
-
+
-
+
-
-
+
+
选择
-
+
重置
-
+
翻转
-
+
翻转
-
+
90
-
+
10
-
+
10
-
+
3
-
+
30
-
+
30
-
+
3
-
-
+
+
-
-
+
+
-
+
@@ -108,7 +108,7 @@
DRAFG_MOVE_RATIO = 1 //移动时候的比例,
export default {
- name: 'cutImage',
+ name: "cutImage",
props:{
avatar:{
type: String
@@ -236,7 +236,7 @@
})
this.getImageInfo()
},
- refresh(){
+ reset(){
this.setData({
cutL: 150,
cutT: 150,
@@ -263,7 +263,7 @@
// 获取图片
getImageInfo() {
// 将图片写入画布
- let ctx = uni.createCanvasContext('imageCanvas', this)
+ let ctx = uni.createCanvasContext("imageCanvas", this)
// 清除内容
ctx.clearRect(0, 0, this.rpxToPx(750), this.rpxToPx(750))
// 重置旋转内容
@@ -280,7 +280,7 @@
}
ctx.translate(this.rpxToPx(-375), this.rpxToPx(-375))
// 设置canvas背景色
- // ctx.fillStyle = 'black';
+ // ctx.fillStyle = "black";
// ctx.fillRect(0, 0, this.rpxToPx(750), this.rpxToPx(750))
ctx.drawImage(this.imageSrc, IMG_RATIO>=1?0:(IMG_REAL_H-IMG_REAL_W)/2, IMG_RATIO<=1?0:(IMG_REAL_W-IMG_REAL_H)/2, IMG_REAL_W, IMG_REAL_H)
// 用户反馈,此处ios旋转后无法预览,改true为false可解决问题
@@ -293,7 +293,7 @@
destWidth: this.rpxToPx(750 - this.cutL - this.cutR) * this.scaleTate,
destHeight: this.rpxToPx(750 - this.cutT - this.cutB) * this.scaleTate,
quality: 1,
- canvasId: 'imageCanvas',
+ canvasId: "imageCanvas",
success: (res)=> {
this.setData({
imageViewSrc: res.tempFilePath
@@ -306,7 +306,7 @@
})
},
saveImageInfo(){
- this.$emit('save', {
+ this.$emit("save", {
avatar: this.imageViewSrc
})
return this
@@ -363,22 +363,7 @@
dragMove(e) {
let dragType = e.target.dataset.drag
switch (dragType) {
- case 'right':
- let dragLengthR = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
- if (CUT_R + dragLengthR < 0) dragLengthR = -CUT_R
- this.setData({
- cutR: CUT_R + dragLengthR
- })
- break
- case 'left':
- let dragLengthL = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
- if (CUT_L - dragLengthL < 0) dragLengthL = CUT_L
- if ((CUT_L - dragLengthL) > (SCREEN_WIDTH - this.cutR)) dragLengthL = CUT_L - (SCREEN_WIDTH - this.cutR)
- this.setData({
- cutL: CUT_L - dragLengthL
- })
- break
- case 'top':
+ case "top":
let dragLengthT = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
if (CUT_T - dragLengthT < 0) dragLengthT = CUT_T
if ((CUT_T - dragLengthT) > (SCREEN_WIDTH - this.cutB)) dragLengthT = CUT_T - (SCREEN_WIDTH - this.cutB)
@@ -386,14 +371,29 @@
cutT: CUT_T - dragLengthT
})
break
- case 'bottom':
+ case "right":
+ let dragLengthR = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
+ if (CUT_R + dragLengthR < 0) dragLengthR = -CUT_R
+ this.setData({
+ cutR: CUT_R + dragLengthR
+ })
+ break
+ case "bottom":
let dragLengthB = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
if (CUT_B + dragLengthB < 0) dragLengthB = -CUT_B
this.setData({
cutB: CUT_B + dragLengthB
})
break
- case 'rightBottom':
+ case "left":
+ let dragLengthL = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
+ if (CUT_L - dragLengthL < 0) dragLengthL = CUT_L
+ if ((CUT_L - dragLengthL) > (SCREEN_WIDTH - this.cutR)) dragLengthL = CUT_L - (SCREEN_WIDTH - this.cutR)
+ this.setData({
+ cutL: CUT_L - dragLengthL
+ })
+ break
+ case "rightBottom":
let dragLengthRBX = (T_PAGE_X - e.touches[0].pageX) * DRAFG_MOVE_RATIO
let dragLengthRBY = (T_PAGE_Y - e.touches[0].pageY) * DRAFG_MOVE_RATIO
@@ -419,80 +419,16 @@
diff --git a/uni_modules/vrapile-cut-image/readme.md b/uni_modules/vrapile-cut-image/readme.md
index 5689ad3..9c618d0 100644
--- a/uni_modules/vrapile-cut-image/readme.md
+++ b/uni_modules/vrapile-cut-image/readme.md
@@ -17,7 +17,7 @@