hookehuyr

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

在多个页面的图片上传功能中,添加image_audit=1参数启用审核功能
当服务器返回审核不通过时,显示模态框提示用户
统一处理上传成功和失败的反馈逻辑
1 <!-- 1 <!--
2 * @Date: 2025-08-27 17:44:53 2 * @Date: 2025-08-27 17:44:53
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-09-03 22:01:38 4 + * @LastEditTime: 2025-09-04 17:59:11
5 * @FilePath: /lls_program/src/pages/CreateFamily/index.vue 5 * @FilePath: /lls_program/src/pages/CreateFamily/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -340,7 +340,7 @@ const uploadImage = (filePath) => { ...@@ -340,7 +340,7 @@ const uploadImage = (filePath) => {
340 }); 340 });
341 341
342 wx.uploadFile({ 342 wx.uploadFile({
343 - url: BASE_URL + '/admin/?m=srv&a=upload', 343 + url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
344 filePath, 344 filePath,
345 name: 'file', 345 name: 'file',
346 header: { 346 header: {
...@@ -350,11 +350,24 @@ const uploadImage = (filePath) => { ...@@ -350,11 +350,24 @@ const uploadImage = (filePath) => {
350 let upload_data = JSON.parse(res.data); 350 let upload_data = JSON.parse(res.data);
351 Taro.hideLoading({ 351 Taro.hideLoading({
352 success: () => { 352 success: () => {
353 - if (data.code == 0) { 353 + if (upload_data.code == 0 && upload_data.data) {
354 familyAvatar.value = upload_data.data.src; 354 familyAvatar.value = upload_data.data.src;
355 showToast('上传成功', 'success'); 355 showToast('上传成功', 'success');
356 } else { 356 } else {
357 - showToast('服务器错误,稍后重试!', 'none'); 357 + // 检查是否为审核不通过
358 + if (upload_data.code == 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
359 + Taro.showModal({
360 + title: '温馨提示',
361 + content: '您上传的内容未通过审核',
362 + showCancel: false
363 + }).then(res => {
364 + if (res.confirm) {
365 + // 点击了确认按钮
366 + }
367 + });
368 + } else {
369 + showToast('服务器错误,稍后重试!', 'none');
370 + }
358 } 371 }
359 }, 372 },
360 }); 373 });
......
1 <!-- 1 <!--
2 * @Date: 2025-08-27 17:44:53 2 * @Date: 2025-08-27 17:44:53
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-09-03 21:59:36 4 + * @LastEditTime: 2025-09-04 17:39:21
5 * @FilePath: /lls_program/src/pages/EditFamily/index.vue 5 * @FilePath: /lls_program/src/pages/EditFamily/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -326,7 +326,7 @@ const uploadImage = (filePath) => { ...@@ -326,7 +326,7 @@ const uploadImage = (filePath) => {
326 }); 326 });
327 327
328 wx.uploadFile({ 328 wx.uploadFile({
329 - url: BASE_URL + '/admin/?m=srv&a=upload', 329 + url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
330 filePath, 330 filePath,
331 name: 'file', 331 name: 'file',
332 header: { 332 header: {
...@@ -336,11 +336,24 @@ const uploadImage = (filePath) => { ...@@ -336,11 +336,24 @@ const uploadImage = (filePath) => {
336 let upload_data = JSON.parse(res.data); 336 let upload_data = JSON.parse(res.data);
337 Taro.hideLoading({ 337 Taro.hideLoading({
338 success: () => { 338 success: () => {
339 - if (data.code == 0) { 339 + if (upload_data.code === 0 && upload_data.data) {
340 familyAvatar.value = upload_data.data.src; 340 familyAvatar.value = upload_data.data.src;
341 showToast('上传成功', 'success'); 341 showToast('上传成功', 'success');
342 } else { 342 } else {
343 - showToast('服务器错误,稍后重试!', 'none'); 343 + // 检查是否为审核不通过
344 + if (upload_data.code === 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
345 + Taro.showModal({
346 + title: '温馨提示',
347 + content: '您上传的内容未通过审核',
348 + showCancel: false
349 + }).then(res => {
350 + if (res.confirm) {
351 + // 点击了确认按钮
352 + }
353 + });
354 + } else {
355 + showToast('服务器错误,稍后重试!', 'none');
356 + }
344 } 357 }
345 }, 358 },
346 }); 359 });
......
...@@ -181,7 +181,7 @@ const uploadImage = (filePath) => { ...@@ -181,7 +181,7 @@ const uploadImage = (filePath) => {
181 }); 181 });
182 182
183 wx.uploadFile({ 183 wx.uploadFile({
184 - url: BASE_URL + '/admin/?m=srv&a=upload', 184 + url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
185 filePath, 185 filePath,
186 name: 'file', 186 name: 'file',
187 header: { 187 header: {
...@@ -191,14 +191,27 @@ const uploadImage = (filePath) => { ...@@ -191,14 +191,27 @@ const uploadImage = (filePath) => {
191 let upload_data = JSON.parse(res.data); 191 let upload_data = JSON.parse(res.data);
192 Taro.hideLoading({ 192 Taro.hideLoading({
193 success: () => { 193 success: () => {
194 - if (data.code == 0) { 194 + if (upload_data.code === 0 && upload_data.data) {
195 screenshots.value.push({ 195 screenshots.value.push({
196 url: upload_data.data.src, 196 url: upload_data.data.src,
197 localPath: filePath 197 localPath: filePath
198 }); 198 });
199 showToast('上传成功', 'success'); 199 showToast('上传成功', 'success');
200 } else { 200 } else {
201 - showToast('服务器错误,稍后重试!', 'error'); 201 + // 检查是否为审核不通过
202 + if (upload_data.code === 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
203 + Taro.showModal({
204 + title: '温馨提示',
205 + content: '您上传的内容未通过审核',
206 + showCancel: false
207 + }).then(res => {
208 + if (res.confirm) {
209 + // 点击了确认按钮
210 + }
211 + });
212 + } else {
213 + showToast('服务器错误,稍后重试!', 'error');
214 + }
202 } 215 }
203 }, 216 },
204 }); 217 });
......
...@@ -342,18 +342,18 @@ const posterConfig = computed(() => { ...@@ -342,18 +342,18 @@ const posterConfig = computed(() => {
342 */ 342 */
343 onMounted(() => { 343 onMounted(() => {
344 Taro.setNavigationBarTitle({ title: '海报打卡' }) 344 Taro.setNavigationBarTitle({ title: '海报打卡' })
345 - 345 +
346 // 获取页面参数 346 // 获取页面参数
347 const instance = Taro.getCurrentInstance() 347 const instance = Taro.getCurrentInstance()
348 const params = instance.router?.params || {} 348 const params = instance.router?.params || {}
349 - 349 +
350 pageParams.value = { 350 pageParams.value = {
351 id: params.id || '', 351 id: params.id || '',
352 marker_id: params.marker_id || '' 352 marker_id: params.marker_id || ''
353 } 353 }
354 - 354 +
355 console.log('海报打卡页面接收到的参数:', pageParams.value) 355 console.log('海报打卡页面接收到的参数:', pageParams.value)
356 - 356 +
357 // 页面加载时生成当前海报 357 // 页面加载时生成当前海报
358 generateCurrentPoster() 358 generateCurrentPoster()
359 }) 359 })
...@@ -457,17 +457,30 @@ const uploadBackgroundImage = (filePath) => { ...@@ -457,17 +457,30 @@ const uploadBackgroundImage = (filePath) => {
457 Taro.showLoading({ title: '上传中...' }) 457 Taro.showLoading({ title: '上传中...' })
458 458
459 Taro.uploadFile({ 459 Taro.uploadFile({
460 - url: BASE_URL + '/admin/?m=srv&a=upload', 460 + url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
461 filePath, 461 filePath,
462 name: 'file', 462 name: 'file',
463 success: (uploadRes) => { 463 success: (uploadRes) => {
464 Taro.hideLoading() 464 Taro.hideLoading()
465 const data = JSON.parse(uploadRes.data) 465 const data = JSON.parse(uploadRes.data)
466 - if (data.code === 0) { 466 + if (data.code === 0 && data.data) {
467 backgroundImage.value = data.data.src 467 backgroundImage.value = data.data.src
468 Taro.showToast({ title: '上传成功', icon: 'success' }) 468 Taro.showToast({ title: '上传成功', icon: 'success' })
469 } else { 469 } else {
470 - Taro.showToast({ title: data.msg || '上传失败', icon: 'none' }) 470 + // 检查是否为审核不通过
471 + if (data.code === 0 && !data.data && data.msg && data.msg.includes('审核不通过')) {
472 + Taro.showModal({
473 + title: '温馨提示',
474 + content: '您上传的内容未通过审核',
475 + showCancel: false
476 + }).then(res => {
477 + if (res.confirm) {
478 + // 点击了确认按钮
479 + }
480 + })
481 + } else {
482 + Taro.showToast({ title: data.msg || '上传失败', icon: 'none' })
483 + }
471 } 484 }
472 }, 485 },
473 fail: () => { 486 fail: () => {
......
...@@ -249,7 +249,7 @@ const chooseMedia = () => { ...@@ -249,7 +249,7 @@ const chooseMedia = () => {
249 Taro.hideLoading(); 249 Taro.hideLoading();
250 Taro.showToast({ 250 Taro.showToast({
251 title: '上传失败,请重试', 251 title: '上传失败,请重试',
252 - icon: 'error', 252 + icon: 'none',
253 duration: 2000 253 duration: 2000
254 }); 254 });
255 } 255 }
...@@ -380,7 +380,7 @@ const formatDuration = (seconds) => { ...@@ -380,7 +380,7 @@ const formatDuration = (seconds) => {
380 const uploadFileToServer = (filePath) => { 380 const uploadFileToServer = (filePath) => {
381 return new Promise((resolve, reject) => { 381 return new Promise((resolve, reject) => {
382 Taro.uploadFile({ 382 Taro.uploadFile({
383 - url: BASE_URL + '/admin/?m=srv&a=upload', 383 + url: BASE_URL + '/admin/?m=srv&a=upload&image_audit=1',
384 filePath, 384 filePath,
385 name: 'file', 385 name: 'file',
386 header: { 386 header: {
...@@ -392,6 +392,18 @@ const uploadFileToServer = (filePath) => { ...@@ -392,6 +392,18 @@ const uploadFileToServer = (filePath) => {
392 if (upload_data.code === 0 && upload_data.data) { 392 if (upload_data.code === 0 && upload_data.data) {
393 resolve(upload_data.data.src); 393 resolve(upload_data.data.src);
394 } else { 394 } else {
395 + // 检查是否为审核不通过
396 + if (upload_data.code === 0 && !upload_data.data && upload_data.msg && upload_data.msg.includes('审核不通过')) {
397 + Taro.showModal({
398 + title: '温馨提示',
399 + content: '您上传的内容未通过审核',
400 + showCancel: false
401 + }).then(res => {
402 + if (res.confirm) {
403 + // 点击了确认按钮
404 + }
405 + });
406 + }
395 reject(new Error(upload_data.msg || '服务器错误')); 407 reject(new Error(upload_data.msg || '服务器错误'));
396 } 408 }
397 } catch (error) { 409 } catch (error) {
......