新增支付流程,新增支付页面等待倒计时,自动检查订单状态等
This commit is contained in:
@@ -30,16 +30,28 @@ class BaseResponse<T> {
|
||||
|
||||
if (shouldDecrypt && cipherText.isNotEmpty && nonce.isNotEmpty) {
|
||||
try {
|
||||
KRLogUtil.kr_i('🔓 开始解密响应数据', tag: 'BaseResponse');
|
||||
print('═══════════════════════════════════════');
|
||||
print('🔐 检测到加密响应,开始解密...');
|
||||
print('📥 加密数据长度: ${cipherText.length} 字符');
|
||||
print('⏰ 时间戳: $nonce');
|
||||
|
||||
final decrypted = KRAesUtil.decryptData(cipherText, nonce, AppConfig.kr_encryptionKey);
|
||||
body = jsonDecode(decrypted);
|
||||
KRLogUtil.kr_i('✅ 解密成功', tag: 'BaseResponse');
|
||||
|
||||
// 打印完整的解密后数据,方便调试
|
||||
final bodyStr = jsonEncode(body);
|
||||
KRLogUtil.kr_i('📦 解密后数据(完整): $bodyStr', tag: 'BaseResponse');
|
||||
print('✅ 解密成功');
|
||||
print('');
|
||||
print('📦 解密后的完整数据:');
|
||||
// 格式化打印 JSON,方便调试
|
||||
final bodyStr = JsonEncoder.withIndent(' ').convert(body);
|
||||
print(bodyStr);
|
||||
print('═══════════════════════════════════════');
|
||||
|
||||
KRLogUtil.kr_i('🔓 解密成功', tag: 'BaseResponse');
|
||||
} catch (e) {
|
||||
KRLogUtil.kr_e('❌ 解密失败: $e,使用原始数据', tag: 'BaseResponse');
|
||||
print('❌ 解密失败: $e');
|
||||
print('⚠️ 将使用原始数据');
|
||||
print('═══════════════════════════════════════');
|
||||
KRLogUtil.kr_e('❌ 解密失败: $e', tag: 'BaseResponse');
|
||||
body = dataMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,6 +282,36 @@ class _KRSimpleHttpInterceptor extends Interceptor {
|
||||
print('>>> Request │ ${options.method} │ ${options.uri}');
|
||||
if (options.data != null) {
|
||||
print('Body: ${options.data}');
|
||||
|
||||
// 检查是否是加密数据(包含 data 和 time 字段)
|
||||
if (options.data is Map<String, dynamic>) {
|
||||
final data = options.data as Map<String, dynamic>;
|
||||
if (data.containsKey('data') && data.containsKey('time')) {
|
||||
try {
|
||||
print('');
|
||||
print('🔐 检测到加密请求,正在解密...');
|
||||
// 尝试解密并打印原始数据
|
||||
final encryptedData = data['data'] as String;
|
||||
final nonce = data['time'] as String;
|
||||
final decrypted = KRAesUtil.decryptData(
|
||||
encryptedData,
|
||||
nonce,
|
||||
AppConfig.kr_encryptionKey,
|
||||
);
|
||||
print('🔓 解密后的原始请求数据:');
|
||||
// 尝试格式化 JSON
|
||||
try {
|
||||
final jsonData = jsonDecode(decrypted);
|
||||
final prettyJson = JsonEncoder.withIndent(' ').convert(jsonData);
|
||||
print(prettyJson);
|
||||
} catch (_) {
|
||||
print(decrypted);
|
||||
}
|
||||
} catch (e) {
|
||||
print('⚠️ 请求解密失败: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.next(options);
|
||||
}
|
||||
@@ -291,6 +321,41 @@ class _KRSimpleHttpInterceptor extends Interceptor {
|
||||
print('<<< Response │ ${response.requestOptions.method} │ ${response.statusCode} ${response.statusMessage} │ ${response.requestOptions.uri}');
|
||||
if (response.data != null) {
|
||||
print('Body: ${response.data}');
|
||||
|
||||
// 检查响应是否是加密数据(包含 data 和 time 字段)
|
||||
if (response.data is Map<String, dynamic>) {
|
||||
final dataMap = response.data as Map<String, dynamic>;
|
||||
|
||||
// 检查是否包含嵌套的 data 字段(加密数据格式)
|
||||
final nestedData = dataMap['data'];
|
||||
if (nestedData is Map<String, dynamic> &&
|
||||
nestedData.containsKey('data') &&
|
||||
nestedData.containsKey('time')) {
|
||||
try {
|
||||
print('');
|
||||
print('🔐 检测到加密响应,正在解密...');
|
||||
// 尝试解密并打印原始响应数据
|
||||
final encryptedData = nestedData['data'] as String;
|
||||
final nonce = nestedData['time'] as String;
|
||||
final decrypted = KRAesUtil.decryptData(
|
||||
encryptedData,
|
||||
nonce,
|
||||
AppConfig.kr_encryptionKey,
|
||||
);
|
||||
print('🔓 解密后的原始响应数据:');
|
||||
// 尝试格式化 JSON
|
||||
try {
|
||||
final jsonData = jsonDecode(decrypted);
|
||||
final prettyJson = JsonEncoder.withIndent(' ').convert(jsonData);
|
||||
print(prettyJson);
|
||||
} catch (_) {
|
||||
print(decrypted);
|
||||
}
|
||||
} catch (e) {
|
||||
print('⚠️ 响应解密失败: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.next(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user