From 2ca7bb98170cb69e15c6499a87241b8b7ac62de9 Mon Sep 17 00:00:00 2001
From: 15233722133 <15233722133@163.com>
Date: Mon, 15 Jun 2026 10:24:15 +0800
Subject: [PATCH 1/3] =?UTF-8?q?feat=EF=BC=9A=E8=A3=81=E5=89=AA=E5=A4=B4?=
=?UTF-8?q?=E5=83=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/avatar_uploader/avatar_cropper.vue | 308 ++++++++++++++++++
pages.json | 12 +
pages/public/avatarCrop.vue | 105 ++++++
pages/public/setting.vue | 41 +--
4 files changed, 433 insertions(+), 33 deletions(-)
create mode 100644 components/avatar_uploader/avatar_cropper.vue
create mode 100644 pages/public/avatarCrop.vue
diff --git a/components/avatar_uploader/avatar_cropper.vue b/components/avatar_uploader/avatar_cropper.vue
new file mode 100644
index 0000000..9d9156d
--- /dev/null
+++ b/components/avatar_uploader/avatar_cropper.vue
@@ -0,0 +1,308 @@
+
+
+
+
+
+
+
+
+
+
+ 选择图片
+
+
+
+
+
+
+ 重新选择
+ 确定裁剪
+
+
+
+
+
+
+
+
+
diff --git a/pages.json b/pages.json
index 5b042c5..decdad5 100644
--- a/pages.json
+++ b/pages.json
@@ -467,6 +467,18 @@
"group": "通用"
}
},
+ {
+ "path": "avatarCrop",
+ "style": {
+ "navigationBarTitleText": "裁剪头像",
+ "navigationStyle": "custom"
+ },
+ "meta": {
+ "sync": true,
+ "title": "裁剪头像",
+ "group": "通用"
+ }
+ },
{
"path": "richtext",
"style": {
diff --git a/pages/public/avatarCrop.vue b/pages/public/avatarCrop.vue
new file mode 100644
index 0000000..84e3ec2
--- /dev/null
+++ b/pages/public/avatarCrop.vue
@@ -0,0 +1,105 @@
+
+
+
+
+
+ 上传中...
+
+
+
+
+
+
+
+
+
diff --git a/pages/public/setting.vue b/pages/public/setting.vue
index 5ed9086..26a38b4 100644
--- a/pages/public/setting.vue
+++ b/pages/public/setting.vue
@@ -30,7 +30,6 @@
import { ref, computed, reactive, onMounted } from 'vue';
import AuthUtil from '@/sheep/api/member/auth';
import card_list from '@/components/card_list/card_list.vue';
- import { baseUrl } from '@/sheep/config';
import UserApi from '@/sheep/api/member/user';
const appInfo = computed(() => sheep.$store('app').info);
const isLogin = computed(() => sheep.$store('user').isLogin);
@@ -177,38 +176,14 @@
}
const upImg = () => {
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- success: function (res) {
- const tempFilePaths = res.tempFilePaths;
- const tempFiles = res.tempFiles;
- let resSize = tempFiles[0].size;
- if (resSize > 1048576) {
- uni.showToast({
- title: '上传图片大小不能超过1MB',
- icon: 'error',
- });
- return;
- }
- const token = uni.getStorageSync('token') ? uni.getStorageSync('token') : undefined;
- let tenant_id = uni.getStorageSync('tenant-id');
- uni.uploadFile({
- url: baseUrl + '/app-api/infra/file/upload', //仅为示例,非真实的接口地址
- filePath: tempFilePaths[0],
- name: 'file',
- formData: {
- directory: 'head',
- 'tenant-id': tenant_id,
- token: token,
- },
- header: {},
- success: (uploadFileRes) => {
- let url = JSON.parse(uploadFileRes.data).data;
- upData({
- avatar: url,
- });
- },
+ uni.navigateTo({
+ url: '/pages/public/avatarCrop',
+ success: (res) => {
+ const eventChannel = res?.eventChannel;
+ if (!eventChannel) return;
+ eventChannel.on('success', ({ url }) => {
+ if (!url) return;
+ upData({ avatar: url });
});
},
});
From 8ec0ad482bb95c7b2344731af73f6392061c665d Mon Sep 17 00:00:00 2001
From: 15233722133 <15233722133@163.com>
Date: Mon, 15 Jun 2026 10:28:55 +0800
Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=B8=BA?=
=?UTF-8?q?=E5=85=88=E9=80=89=E6=8B=A9=E5=9B=BE=E7=89=87=E5=86=8D=E8=A3=81?=
=?UTF-8?q?=E5=89=AA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/public/avatarCrop.vue | 7 ++++---
pages/public/setting.vue | 30 +++++++++++++++++++++++-------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/pages/public/avatarCrop.vue b/pages/public/avatarCrop.vue
index 84e3ec2..09fa2f2 100644
--- a/pages/public/avatarCrop.vue
+++ b/pages/public/avatarCrop.vue
@@ -1,7 +1,7 @@
-
+
上传中...
@@ -16,10 +16,12 @@
import avatarCropper from '@/components/avatar_uploader/avatar_cropper.vue';
const { proxy } = getCurrentInstance();
+ const src = ref('');
const uploading = ref(false);
const eventChannel = ref(null);
- onLoad(() => {
+ onLoad((options) => {
+ src.value = decodeURIComponent(String(options?.src || '').trim());
eventChannel.value = proxy.getOpenerEventChannel ? proxy.getOpenerEventChannel() : null;
});
@@ -102,4 +104,3 @@
font-size: 28rpx;
}
-
diff --git a/pages/public/setting.vue b/pages/public/setting.vue
index 26a38b4..beb666d 100644
--- a/pages/public/setting.vue
+++ b/pages/public/setting.vue
@@ -176,14 +176,30 @@
}
const upImg = () => {
- uni.navigateTo({
- url: '/pages/public/avatarCrop',
+ uni.chooseImage({
+ count: 1,
+ sizeType: ['original', 'compressed'],
success: (res) => {
- const eventChannel = res?.eventChannel;
- if (!eventChannel) return;
- eventChannel.on('success', ({ url }) => {
- if (!url) return;
- upData({ avatar: url });
+ const filePath = res?.tempFilePaths?.[0] || '';
+ const size = res?.tempFiles?.[0]?.size;
+ if (typeof size === 'number' && size > 1048576) {
+ uni.showToast({
+ title: '上传图片大小不能超过1MB',
+ icon: 'none',
+ });
+ return;
+ }
+ if (!filePath) return;
+ uni.navigateTo({
+ url: `/pages/public/avatarCrop?src=${encodeURIComponent(filePath)}`,
+ success: (navRes) => {
+ const eventChannel = navRes?.eventChannel;
+ if (!eventChannel) return;
+ eventChannel.on('success', ({ url }) => {
+ if (!url) return;
+ upData({ avatar: url });
+ });
+ },
});
},
});
From 104d63a73db63d6adf63d98921f8380f999d1025 Mon Sep 17 00:00:00 2001
From: 15233722133 <15233722133@163.com>
Date: Mon, 15 Jun 2026 11:02:13 +0800
Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E8=A3=81=E5=89=AA=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E6=94=BE=E5=A4=A7=E7=BC=A9=E5=B0=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/avatar_uploader/avatar_cropper.vue | 278 +++++++++++++++---
pages/public/avatarCrop.vue | 18 ++
2 files changed, 256 insertions(+), 40 deletions(-)
diff --git a/components/avatar_uploader/avatar_cropper.vue b/components/avatar_uploader/avatar_cropper.vue
index 9d9156d..b7829d8 100644
--- a/components/avatar_uploader/avatar_cropper.vue
+++ b/components/avatar_uploader/avatar_cropper.vue
@@ -1,33 +1,54 @@
-
-
+
+
-
+
+
选择图片
-
+
+
+
+
+
+
+
+
+
+
+
重新选择
- 确定裁剪
+ 确认