hookehuyr

feat(图片上传): 为图片上传接口添加审核参数并完善审核失败处理

在多个页面的图片上传功能中,添加image_audit=1参数启用审核功能
当服务器返回审核不通过时,显示模态框提示用户
统一处理上传成功和失败的反馈逻辑
<!--
* @Date: 2025-08-27 17:44:53
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-03 22:01:38
* @LastEditTime: 2025-09-04 17:59:11
* @FilePath: /lls_program/src/pages/CreateFamily/index.vue
* @Description: 文件描述
-->
......@@ -340,7 +340,7 @@ const uploadImage = (filePath) => {
});
wx.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
filePath,
name: 'file',
header: {
......@@ -350,11 +350,24 @@ const uploadImage = (filePath) => {
let upload_data = JSON.parse(res.data);
Taro.hideLoading({
success: () => {
if (data.code == 0) {
if (upload_data.code == 0 && upload_data.data) {
familyAvatar.value = upload_data.data.src;
showToast('上传成功', 'success');
} else {
showToast('服务器错误,稍后重试!', 'none');
// 检查是否为审核不通过
if (upload_data.code == 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
Taro.showModal({
title: '温馨提示',
content: '您上传的内容未通过审核',
showCancel: false
}).then(res => {
if (res.confirm) {
// 点击了确认按钮
}
});
} else {
showToast('服务器错误,稍后重试!', 'none');
}
}
},
});
......
<!--
* @Date: 2025-08-27 17:44:53
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-03 21:59:36
* @LastEditTime: 2025-09-04 17:39:21
* @FilePath: /lls_program/src/pages/EditFamily/index.vue
* @Description: 文件描述
-->
......@@ -326,7 +326,7 @@ const uploadImage = (filePath) => {
});
wx.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
filePath,
name: 'file',
header: {
......@@ -336,11 +336,24 @@ const uploadImage = (filePath) => {
let upload_data = JSON.parse(res.data);
Taro.hideLoading({
success: () => {
if (data.code == 0) {
if (upload_data.code === 0 && upload_data.data) {
familyAvatar.value = upload_data.data.src;
showToast('上传成功', 'success');
} else {
showToast('服务器错误,稍后重试!', 'none');
// 检查是否为审核不通过
if (upload_data.code === 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
Taro.showModal({
title: '温馨提示',
content: '您上传的内容未通过审核',
showCancel: false
}).then(res => {
if (res.confirm) {
// 点击了确认按钮
}
});
} else {
showToast('服务器错误,稍后重试!', 'none');
}
}
},
});
......
......@@ -181,7 +181,7 @@ const uploadImage = (filePath) => {
});
wx.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
filePath,
name: 'file',
header: {
......@@ -191,14 +191,27 @@ const uploadImage = (filePath) => {
let upload_data = JSON.parse(res.data);
Taro.hideLoading({
success: () => {
if (data.code == 0) {
if (upload_data.code === 0 && upload_data.data) {
screenshots.value.push({
url: upload_data.data.src,
localPath: filePath
});
showToast('上传成功', 'success');
} else {
showToast('服务器错误,稍后重试!', 'error');
// 检查是否为审核不通过
if (upload_data.code === 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
Taro.showModal({
title: '温馨提示',
content: '您上传的内容未通过审核',
showCancel: false
}).then(res => {
if (res.confirm) {
// 点击了确认按钮
}
});
} else {
showToast('服务器错误,稍后重试!', 'error');
}
}
},
});
......
......@@ -342,18 +342,18 @@ const posterConfig = computed(() => {
*/
onMounted(() => {
Taro.setNavigationBarTitle({ title: '海报打卡' })
// 获取页面参数
const instance = Taro.getCurrentInstance()
const params = instance.router?.params || {}
pageParams.value = {
id: params.id || '',
marker_id: params.marker_id || ''
}
console.log('海报打卡页面接收到的参数:', pageParams.value)
// 页面加载时生成当前海报
generateCurrentPoster()
})
......@@ -457,17 +457,30 @@ const uploadBackgroundImage = (filePath) => {
Taro.showLoading({ title: '上传中...' })
Taro.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
filePath,
name: 'file',
success: (uploadRes) => {
Taro.hideLoading()
const data = JSON.parse(uploadRes.data)
if (data.code === 0) {
if (data.code === 0 && data.data) {
backgroundImage.value = data.data.src
Taro.showToast({ title: '上传成功', icon: 'success' })
} else {
Taro.showToast({ title: data.msg || '上传失败', icon: 'none' })
// 检查是否为审核不通过
if (data.code === 0 && !data.data && data.msg && data.msg.includes('审核不通过')) {
Taro.showModal({
title: '温馨提示',
content: '您上传的内容未通过审核',
showCancel: false
}).then(res => {
if (res.confirm) {
// 点击了确认按钮
}
})
} else {
Taro.showToast({ title: data.msg || '上传失败', icon: 'none' })
}
}
},
fail: () => {
......
......@@ -249,7 +249,7 @@ const chooseMedia = () => {
Taro.hideLoading();
Taro.showToast({
title: '上传失败,请重试',
icon: 'error',
icon: 'none',
duration: 2000
});
}
......@@ -380,7 +380,7 @@ const formatDuration = (seconds) => {
const uploadFileToServer = (filePath) => {
return new Promise((resolve, reject) => {
Taro.uploadFile({
url: BASE_URL + '/admin/?m=srv&a=upload',
url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
filePath,
name: 'file',
header: {
......@@ -392,6 +392,18 @@ const uploadFileToServer = (filePath) => {
if (upload_data.code === 0 && upload_data.data) {
resolve(upload_data.data.src);
} else {
// 检查是否为审核不通过
if (upload_data.code === 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
Taro.showModal({
title: '温馨提示',
content: '您上传的内容未通过审核',
showCancel: false
}).then(res => {
if (res.confirm) {
// 点击了确认按钮
}
});
}
reject(new Error(upload_data.msg || '服务器错误'));
}
} catch (error) {
......