feat: 上传图片的逻辑处理

This commit is contained in:
2025-10-21 18:59:53 +08:00
parent 5e981b6de3
commit a3aabc2752
6 changed files with 90 additions and 0 deletions

View File

@@ -35,11 +35,25 @@
>
<view class="font-500 line-height-22 mb-12">需求信息描述</view>
<textarea
class="h-80"
placeholder="请输入需求信息描述"
placeholder-class="font-size-14 font-400"
maxlength="100"
v-model="contactText"
/>
</view>
<view
class="bg-F5F7FA border-box p-12 rounded-10 font-size-14 font-500 color-171717 mb-12"
>
<view class="font-500 line-height-22 mb-12">照片上传</view>
<view
class="bg-white p-24 rounded-5 inline-block"
@click="handleChooseImage"
>
<uni-icons type="closeempty" size="24" color="#6A717F" />
</view>
</view>
</view>
<view v-else class="border-box card-content flex flex-items-center p-12">
@@ -76,6 +90,7 @@
import { ref, onMounted, nextTick } from "vue";
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
import { createWorkOrder } from "@/request/api/OrderApi";
import { updateImageFile } from "@/request/api/UpdateFile";
const workOrderTypeId = ref("");
const roomId = ref("");
@@ -85,6 +100,35 @@ const contentImgUrl = ref("");
const isCallSuccess = ref(false); // 呼叫成功状态
const workOrderId = ref(0); // 工单ID
// 处理图片上传
const handleChooseImage = () => {
console.log("选择图片");
uni.chooseImage({
count: 1,
success: (res) => {
const file = res.tempFilePaths[0];
updateImagehandle(file);
},
fail: (err) => {
console.error("选择图片失败:", err);
uni.showToast({
title: "选择图片失败",
icon: "none",
duration: 2000,
});
},
});
};
const updateImagehandle = (file) => {
if (!file) {
return;
}
updateImageFile(file).then((res) => {
contentImgUrl.value = res.data?.url || "";
});
};
const handleCall = async () => {
if (isCallSuccess.value) {
// 查看工单