diff --git a/lib/core/translations/language/en_us.dart b/lib/core/translations/language/en_us.dart index 6bc80e0ea..0a9131262 100644 --- a/lib/core/translations/language/en_us.dart +++ b/lib/core/translations/language/en_us.dart @@ -1391,4 +1391,9 @@ const Map enUS = { "yesterday": "Yesterday", //补充 "insufficientIntegral": "Insufficient integral", + + //余额不足弹窗 + 'recharge': 'Go to Recharge', + 'insufficientBalanceDesc': + 'Insufficient balance, please go to the corresponding recharge page to recharge.', }; diff --git a/lib/core/translations/language/zh_cn.dart b/lib/core/translations/language/zh_cn.dart index 9a5f062e2..332179f96 100644 --- a/lib/core/translations/language/zh_cn.dart +++ b/lib/core/translations/language/zh_cn.dart @@ -1275,4 +1275,8 @@ const Map zhCN = { 'earlyAccessNewFeatures': '新功能优先体验', 'crossDeviceSync': '跨设备同步', 'vipDisclaimer': '具体权益以实际套餐说明为准,可能随版本迭代调整。', + + //余额不足弹窗 + "insufficientBalanceDesc": "餘額不足,請前往對應充值界面進行充值", + "recharge": "前往充值", }; diff --git a/lib/core/translations/language/zh_hk.dart b/lib/core/translations/language/zh_hk.dart index 2c7e8d561..c75856db6 100644 --- a/lib/core/translations/language/zh_hk.dart +++ b/lib/core/translations/language/zh_hk.dart @@ -904,4 +904,8 @@ const Map zhHK = { 'earlyAccessNewFeatures': '新功能優先體驗', 'crossDeviceSync': '跨設備同步', 'vipDisclaimer': '具體權益以實際套餐說明為準,可能隨版本迭代調整。', + + //余额不足弹窗 + "insufficientBalanceDesc": "余额不足,请前往对应充值界面进行充值", + "recharge": "去充值", }; diff --git a/lib/modules/agent/controllers/agent_controller.dart b/lib/modules/agent/controllers/agent_controller.dart index 9c0ca7b42..4f70d6674 100644 --- a/lib/modules/agent/controllers/agent_controller.dart +++ b/lib/modules/agent/controllers/agent_controller.dart @@ -31,6 +31,7 @@ import 'package:path_provider/path_provider.dart'; import 'package:photo_view/photo_view.dart'; import '../../../core/utils/permission_util.dart'; import '../../../data/models/message_model.dart'; +import '../../common/widgets/recharge_dialog.dart'; // 语音输入模式枚举 enum VoiceInputMode { @@ -804,63 +805,8 @@ class AgentController extends GetxController with WidgetsBindingObserver { Get.snackbar('error'.tr, '${event.data['message']}'); } else if (code == 2001) { // 余额不足或需要充值,给出弹窗确认是否跳转充值界面 - final msg = '${event.data['message'] ?? '余额不足,请前往充值'}'; - Get.snackbar('error'.tr, msg); - Get.dialog( - Dialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(16, 20, 16, 16), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Text( - '提示', - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 12), - Text( - '$msg\n是否前往充值界面?', - textAlign: TextAlign.center, - ), - const SizedBox(height: 20), - SizedBox( - width: double.infinity, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.orangeAccent, - foregroundColor: Colors.white, - ), - onPressed: () { - Get.back(); - Get.toNamed(Routes.goodsvip); - }, - child: const Text('去充值'), - ), - ), - ], - ), - ), - Positioned( - right: 8, - top: 8, - child: IconButton( - icon: const Icon(Icons.close), - onPressed: () => Get.back(), - ), - ), - ], - ), - ), - barrierDismissible: true, - ); + + showRechargeDialog('agent'); } Logger.e(TAG, '代理服务错误: ${event.data['message']}'); break; diff --git a/lib/modules/common/widgets/recharge_dialog.dart b/lib/modules/common/widgets/recharge_dialog.dart new file mode 100644 index 000000000..be622f53d --- /dev/null +++ b/lib/modules/common/widgets/recharge_dialog.dart @@ -0,0 +1,67 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import '../../../routes/app_routes.dart'; + +void showRechargeDialog(String type) { + Get.dialog( + Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + child: Stack( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(16, 20, 16, 16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'tip'.tr, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 12), + Text( + 'insufficientBalanceDesc'.tr, //'余额不足,请前往对应充值界面进行充值', + textAlign: TextAlign.center, + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.orangeAccent, + foregroundColor: Colors.white, + ), + onPressed: () { + Get.back(); + if (type == 'agent') { + Get.toNamed(Routes.goodsvip); + } else if (type == 'translation') { + Get.toNamed(Routes.goodstrade); + } else if (type == 'meeting') { + Get.toNamed(Routes.goodsmeet); + } + }, + child: Text('recharge'.tr), + ), + ), + ], + ), + ), + Positioned( + right: 8, + top: 8, + child: IconButton( + icon: const Icon(Icons.close), + onPressed: () => Get.back(), + ), + ), + ], + ), + ), + barrierDismissible: true, + ); +} diff --git a/lib/modules/goods/views/goodsvip_view.dart b/lib/modules/goods/views/goodsvip_view.dart index bedbd4cbf..3efa834d5 100644 --- a/lib/modules/goods/views/goodsvip_view.dart +++ b/lib/modules/goods/views/goodsvip_view.dart @@ -45,7 +45,7 @@ class GoodsvipView extends GetView { for (final g in controller.items) { grouped.putIfAbsent(g.usagetype, () => []).add(g); } - final order = [UsageType.Vip, UsageType.Translation, UsageType.Meet]; + final order = [UsageType.Vip]; final children = []; children.add(_buildFeaturesSection(isDarkMode)); children.add(SizedBox(height: 16.h)); diff --git a/lib/modules/meeting/views/bottomSheet/generate_bottom_sheet.dart b/lib/modules/meeting/views/bottomSheet/generate_bottom_sheet.dart index e929fdfcf..e8268169d 100644 --- a/lib/modules/meeting/views/bottomSheet/generate_bottom_sheet.dart +++ b/lib/modules/meeting/views/bottomSheet/generate_bottom_sheet.dart @@ -7,6 +7,8 @@ import 'package:get_storage/get_storage.dart'; import '../../controllers/meeting_details_controller.dart'; import 'record_language_bottom_sheet.dart'; import '../template/template_view.dart'; +import '../../../../data/models/user_Info.dart'; +import '../../../common/widgets/recharge_dialog.dart'; class GenerateBottomSheet extends StatefulWidget { final bool isSummarizeAgain; @@ -300,6 +302,10 @@ class _GenerateBottomSheetState extends State { padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), child: GestureDetector( onTap: () { + if (User.isLoggedIn() && User.instance.meetintegral <= 0) { + showRechargeDialog('meeting'); + return; + } if (_templateData['id'] != _templateList[0]['id']) { int index = _templateList .indexWhere((v) => v['id'] == _templateData['id']); diff --git a/lib/modules/settings/views/settings_view.dart b/lib/modules/settings/views/settings_view.dart index bf5a7f72d..7691cba0a 100644 --- a/lib/modules/settings/views/settings_view.dart +++ b/lib/modules/settings/views/settings_view.dart @@ -243,59 +243,46 @@ class SettingsView extends GetView { ), ], ), - child: InkWell( - onTap: () => Get.toNamed(Routes.goodsvip), - borderRadius: BorderRadius.circular(16.r), - child: Row( - children: [ - Container( - width: 42.w, - height: 42.w, - decoration: BoxDecoration( - color: isDarkMode - ? Colors.amber[900]!.withOpacity(0.3) - : Colors.amber[100]!, - borderRadius: BorderRadius.circular(21.r), - ), - child: Icon( - Icons.workspace_premium, - size: 20.w, - color: isDarkMode ? Colors.amber[300]! : Colors.amber[600]!, - ), - ), - SizedBox(width: 12.w), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'premiumMember'.tr, - style: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.w600, - color: Colors.white, - ), - ), - SizedBox(height: 4.h), - Text( - '${'higherQuota'.tr} · ${'fastResponse'.tr}', - style: TextStyle( - fontSize: 12.sp, - color: Colors.white70, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ], - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 16.w, - color: Colors.white70, - ), - ], - ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _buildCategoryItem( + icon: Icons.workspace_premium, + label: 'premiumMember'.tr, + iconBg: isDarkMode + ? Colors.amber[900]!.withOpacity(0.3) + : Colors.amber[100]!, + iconColor: isDarkMode ? Colors.amber[300]! : Colors.amber[600]!, + onTap: () => Get.toNamed(Routes.goodsvip), + ), + _buildCategoryItem( + icon: Icons.translate, + label: 'interpretation'.tr, + iconBg: isDarkMode + ? Colors.indigo[900]!.withOpacity(0.3) + : Colors.indigo[100]!, + iconColor: isDarkMode ? Colors.indigo[300]! : Colors.indigo[600]!, + onTap: () => Get.toNamed(Routes.goodstrade), + ), + _buildCategoryItem( + icon: Icons.people, + label: 'conferenceAssistant'.tr, + iconBg: isDarkMode + ? Colors.pink[900]!.withOpacity(0.3) + : Colors.pink[100]!, + iconColor: isDarkMode ? Colors.pink[300]! : Colors.pink[600]!, + onTap: () => Get.toNamed(Routes.goodsmeet), + ), + // _buildCategoryItem( + // icon: Icons.smart_toy, + // label: 'aiFunction'.tr, + // iconBg: isDarkMode + // ? Colors.teal[900]!.withOpacity(0.3) + // : Colors.teal[100]!, + // iconColor: isDarkMode ? Colors.teal[300]! : Colors.teal[600]!, + // onTap: () => Get.toNamed(Routes.goodsai), + // ), + ], ), ); } @@ -328,16 +315,20 @@ class SettingsView extends GetView { SizedBox(height: 8.h), SizedBox( width: 72.w, - child: Text( - label, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.sp, - fontWeight: FontWeight.w500, - color: Colors.white, + height: 32.h, + child: Center( + child: Text( + label, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + fontWeight: FontWeight.w500, + color: Colors.white, + height: 1.2, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, ), - maxLines: 2, - overflow: TextOverflow.ellipsis, ), ), ], diff --git a/lib/modules/translation/controllers/translation_controller.dart b/lib/modules/translation/controllers/translation_controller.dart index f0c9a6c3b..1d0a4c32d 100644 --- a/lib/modules/translation/controllers/translation_controller.dart +++ b/lib/modules/translation/controllers/translation_controller.dart @@ -29,6 +29,8 @@ import 'record_timer_controller.dart'; import 'translation_history_controller.dart'; import '../models/translation_models.dart'; import '../views/dialogs/translation_mode_selector.dart'; +import '../../../data/models/user_Info.dart'; +import '../../common/widgets/recharge_dialog.dart'; /// 音频输出设备枚举 enum AudioOutputDevice { @@ -393,6 +395,11 @@ class TranslationController extends GetxController with WidgetsBindingObserver { /// [speakerId] 说话者ID Future _startFaceToFaceRecognition(int speakerId) async { try { + if (User.isLoggedIn() && User.instance.tradeintegral <= 0) { + showRechargeDialog('translation'); + activeSpeaker.value = 0; + return; + } if (_asrSessionStartTime == null) { await _initializeSession(); } @@ -842,6 +849,10 @@ class TranslationController extends GetxController with WidgetsBindingObserver { /// 开始语音识别 Future startRecognition() async { Logger.info('开始语音识别'); + if (User.isLoggedIn() && User.instance.tradeintegral <= 0) { + showRechargeDialog('translation'); + return; + } if (!await _checkPermissions()) return; if (isRecognizing.value) return;