fix(c2c): 修复付款水单图片无法显示的问题
1. 后端: proofs 图片端点添加 @Public() 装饰器, Image.network 无法携带 JWT token 2. 前端: paymentProofUrl 是相对路径,拼接 baseUrl 构建完整 URL 供 Image.network 加载 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f9835c388e
commit
a1c3657390
|
|
@ -25,6 +25,7 @@ import {
|
|||
} from '@nestjs/swagger';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { Public } from '../../shared/guards/jwt-auth.guard';
|
||||
import { C2cService } from '../../application/services/c2c.service';
|
||||
import {
|
||||
CreateC2cOrderDto,
|
||||
|
|
@ -295,6 +296,7 @@ export class C2cController {
|
|||
return this.toResponseDto(order);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get('proofs/:filename')
|
||||
@ApiOperation({ summary: '获取付款水单图片' })
|
||||
@ApiParam({ name: 'filename', description: '文件名' })
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import '../../../core/constants/app_constants.dart';
|
||||
import '../../../core/utils/format_utils.dart';
|
||||
import '../../../data/models/c2c_order_model.dart';
|
||||
import '../../providers/c2c_providers.dart';
|
||||
|
|
@ -881,6 +882,12 @@ class _C2cOrderDetailPageState extends ConsumerState<C2cOrderDetailPage> {
|
|||
);
|
||||
}
|
||||
|
||||
/// 将后端返回的相对路径转为完整图片 URL
|
||||
String _buildProofImageUrl(String relativePath) {
|
||||
if (relativePath.startsWith('http')) return relativePath;
|
||||
return '${AppConstants.baseUrl}$relativePath';
|
||||
}
|
||||
|
||||
Widget _buildPaymentProofCard(C2cOrderModel order, bool isBuyer) {
|
||||
final hasProof = order.paymentProofUrl != null && order.paymentProofUrl!.isNotEmpty;
|
||||
|
||||
|
|
@ -934,11 +941,11 @@ class _C2cOrderDetailPageState extends ConsumerState<C2cOrderDetailPage> {
|
|||
const SizedBox(height: 16),
|
||||
if (hasProof)
|
||||
GestureDetector(
|
||||
onTap: () => _showProofFullScreen(order.paymentProofUrl!),
|
||||
onTap: () => _showProofFullScreen(_buildProofImageUrl(order.paymentProofUrl!)),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.network(
|
||||
order.paymentProofUrl!,
|
||||
_buildProofImageUrl(order.paymentProofUrl!),
|
||||
height: 200,
|
||||
width: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
|
|
|
|||
Loading…
Reference in New Issue