hookehuyr

feat(反馈页面): 实现真实图片上传功能并移除返回按钮

替换模拟上传逻辑为真实API调用,使用wx.uploadFile上传图片至服务器
移除未使用的返回按钮相关代码和Left图标导入
......@@ -122,8 +122,9 @@
<script setup>
import { ref, computed } from 'vue'
import Taro from '@tarojs/taro'
import { Left, Plus, Close } from '@nutui/icons-vue-taro'
import { Plus, Close } from '@nutui/icons-vue-taro'
import { Toast } from '@nutui/nutui-taro'
import BASE_URL from '@/utils/config'
import './index.less'
// 反馈分类
......@@ -154,13 +155,6 @@ const canSubmit = computed(() => {
})
/**
* 返回上一页
*/
const goBack = () => {
Taro.navigateBack()
}
/**
* 选择反馈分类
*/
const selectCategory = (categoryId) => {
......@@ -192,26 +186,56 @@ const triggerUpload = () => {
/**
* 上传图片到服务器
* @param {String} filePath - 图片文件路径
*/
const uploadImage = (filePath) => {
Taro.showLoading({ title: '上传中', mask: true })
// 模拟上传成功(实际项目中替换为真实的上传逻辑)
setTimeout(() => {
Taro.hideLoading()
// 模拟服务器返回的图片URL
const mockImageUrl = filePath // 在实际项目中,这里应该是服务器返回的URL
// 显示上传中提示
Taro.showLoading({
title: '上传中',
mask: true
})
// 使用wx.uploadFile进行真实上传
wx.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
filePath,
name: 'file',
header: {
'content-type': 'multipart/form-data',
},
success: function (res) {
let upload_data = JSON.parse(res.data);
Taro.hideLoading({
success: () => {
if (res.statusCode === 200) {
// 添加到已上传图片列表
uploadedImages.value.push(mockImageUrl)
uploadedImages.value.push(upload_data.data.src);
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 2000
icon: 'success'
})
}, 1500)
} else {
Taro.showToast({
icon: 'error',
title: '服务器错误,稍后重试!',
mask: true
})
}
}
});
},
fail: function (res) {
Taro.hideLoading({
success: () => {
Taro.showToast({
icon: 'error',
title: '上传失败,稍后重试!',
mask: true
})
}
})
}
});
}
/**
......