From c03a699ab95053c79e0644d84f726f53adc60c8e Mon Sep 17 00:00:00 2001 From: zzc <1761997216@qq.com> Date: Wed, 20 May 2026 23:28:57 +0800 Subject: [PATCH] feat: release --- pages/release/index.vue | 24 +++++++++++++++++++----- utils/common.js | 5 +++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/pages/release/index.vue b/pages/release/index.vue index 2bf74fe..d09c0b1 100644 --- a/pages/release/index.vue +++ b/pages/release/index.vue @@ -37,7 +37,7 @@ @@ -74,7 +74,7 @@ @@ -160,10 +160,11 @@ import { reactive, ref } from "vue"; import { onLoad } from "@dcloudio/uni-app"; import { getStatusBarHeight } from "@/utils/system"; -import { releaseTopic, fetchTopicCategories } from "@/api/release"; +import { releaseTopic, fetchTopicCategories } from "@/api/topic"; import { smartNavigateBack } from "@/utils/page"; import { uploadImage, + FILE_BASE_URL, } from "@/utils/common.js"; const statusBarHeight = ref(getStatusBarHeight() || 0); @@ -277,8 +278,21 @@ const onAvatarSelect = async (url) => { const chooseParticipantAvatar = (index) => { uni.chooseImage({ count: 1, - success: (res) => { - participants.value[index].avatar = res.tempFilePaths[0]; + success: async (res) => { + const url = res.tempFilePaths[0]; + uni.showLoading({ title: '上传中...' }); + try { + const imageUrl = await uploadImage(url); + participants.value[index].avatar = imageUrl; + uni.hideLoading(); + } catch (e) { + uni.hideLoading(); + uni.showToast({ + title: "上传失败", + icon: "none", + }); + console.error(e); + } }, }); }; diff --git a/utils/common.js b/utils/common.js index 1b404ec..bccc097 100644 --- a/utils/common.js +++ b/utils/common.js @@ -6,6 +6,8 @@ import { createTracking, } from "@/api/system"; +export const FILE_BASE_URL = "https://file.lihailezzc.com/"; + export const generateObjectId = ( m = Math, d = Date, @@ -29,8 +31,7 @@ export const uploadImage = (filePath) => { if (keyJson?.data?.result === "auditFailed") { reject("图片不符合发布规范,请稍作修改后再试"); } else { - const url = `https://file.lihailezzc.com/${keyJson?.data.key}`; - resolve(url); + resolve(keyJson?.data.key); } } catch (e) { reject(e);