From 1d2a89a80a41acdc9c29954db28e185066b78a17 Mon Sep 17 00:00:00 2001 From: speakeloudest Date: Tue, 13 Jan 2026 01:19:13 -0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=AE=A2=E6=9C=8D2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/hi_menu/views/hi_menu_view.dart | 5 ++ .../bindings/kr_chatwoot_binding.dart | 12 +++++ .../controllers/kr_chatwoot_controller.dart | 21 ++++++++ .../kr_chatwoot/views/kr_chatwoot_view.dart | 52 +++++++++++++++++++ .../controllers/kr_crisp_controller.dart | 2 +- lib/app/routes/app_pages.dart | 8 +++ lib/app/routes/app_routes.dart | 2 + 7 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 lib/app/modules/kr_chatwoot/bindings/kr_chatwoot_binding.dart create mode 100644 lib/app/modules/kr_chatwoot/controllers/kr_chatwoot_controller.dart create mode 100644 lib/app/modules/kr_chatwoot/views/kr_chatwoot_view.dart diff --git a/lib/app/modules/hi_menu/views/hi_menu_view.dart b/lib/app/modules/hi_menu/views/hi_menu_view.dart index cb4b01c..d965f4f 100755 --- a/lib/app/modules/hi_menu/views/hi_menu_view.dart +++ b/lib/app/modules/hi_menu/views/hi_menu_view.dart @@ -61,6 +61,11 @@ class HIMenuView extends GetView implements HasSwipeConfig { title: '在线客服', onTap: () => KRCommonUtil.kr_openCustomerService(), ), + const MenuItem( + iconName: 'icon-5', + title: '在线客服2', + route: Routes.KR_CHATWOOT, + ), ]; return HIBaseScaffold( diff --git a/lib/app/modules/kr_chatwoot/bindings/kr_chatwoot_binding.dart b/lib/app/modules/kr_chatwoot/bindings/kr_chatwoot_binding.dart new file mode 100644 index 0000000..1b214ac --- /dev/null +++ b/lib/app/modules/kr_chatwoot/bindings/kr_chatwoot_binding.dart @@ -0,0 +1,12 @@ +import 'package:get/get.dart'; +import '../controllers/kr_chatwoot_controller.dart'; + +/// 客服2(Chatwoot)依赖绑定 +class KRChatwootBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut( + () => KRChatwootController(), + ); + } +} diff --git a/lib/app/modules/kr_chatwoot/controllers/kr_chatwoot_controller.dart b/lib/app/modules/kr_chatwoot/controllers/kr_chatwoot_controller.dart new file mode 100644 index 0000000..1be9758 --- /dev/null +++ b/lib/app/modules/kr_chatwoot/controllers/kr_chatwoot_controller.dart @@ -0,0 +1,21 @@ +import 'package:get/get.dart'; + +/// 客服2(Chatwoot)控制器 +class KRChatwootController extends GetxController { + /// Chatwoot 客服链接 + final String kr_chatwootUrl = 'https://app.chatwoot.com/widget?website_token=YXQmh16ymNYW1SVybhnoQQ9w'; + + /// 加载状态 + final RxBool kr_isLoading = true.obs; + + @override + void onInit() { + super.onInit(); + } + + /// 设置加载状态 + /// [loading] 是否正在加载 + void kr_setLoading(bool loading) { + kr_isLoading.value = loading; + } +} diff --git a/lib/app/modules/kr_chatwoot/views/kr_chatwoot_view.dart b/lib/app/modules/kr_chatwoot/views/kr_chatwoot_view.dart new file mode 100644 index 0000000..c73bb10 --- /dev/null +++ b/lib/app/modules/kr_chatwoot/views/kr_chatwoot_view.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:kaer_with_panels/app/widgets/hi_base_scaffold.dart'; +import 'package:kaer_with_panels/app/widgets/kr_simple_loading.dart'; +import '../controllers/kr_chatwoot_controller.dart'; + +/// 客服2(Chatwoot)视图页面 +class KRChatwootView extends GetView { + const KRChatwootView({super.key}); + + @override + Widget build(BuildContext context) { + return HIBaseScaffold( + showBack: true, + topContentAreaHeight: 0, + child: Stack( + children: [ + InAppWebView( + initialUrlRequest: URLRequest( + url: WebUri(controller.kr_chatwootUrl), + ), + initialSettings: InAppWebViewSettings( + javaScriptEnabled: true, + domStorageEnabled: true, + allowsInlineMediaPlayback: true, + ), + onLoadStart: (controller, url) { + this.controller.kr_setLoading(true); + }, + onLoadStop: (controller, url) { + this.controller.kr_setLoading(false); + }, + onReceivedError: (controller, request, error) { + this.controller.kr_setLoading(false); + }, + ), + Obx(() { + if (controller.kr_isLoading.value) { + return const Center( + child: KRSimpleLoading( + size: 40, + ), + ); + } + return const SizedBox.shrink(); + }), + ], + ), + ); + } +} diff --git a/lib/app/modules/kr_crisp_chat/controllers/kr_crisp_controller.dart b/lib/app/modules/kr_crisp_chat/controllers/kr_crisp_controller.dart index f7b5871..7133310 100755 --- a/lib/app/modules/kr_crisp_chat/controllers/kr_crisp_controller.dart +++ b/lib/app/modules/kr_crisp_chat/controllers/kr_crisp_controller.dart @@ -57,7 +57,7 @@ class KRCrispController extends GetxController { _nativeConfig = native_crisp.CrispConfig( websiteID: AppConfig.getInstance().kr_website_id, user: native_crisp.User( - email: identifier, + email: null, nickName: identifier, ), ); diff --git a/lib/app/routes/app_pages.dart b/lib/app/routes/app_pages.dart index d57a324..21e2467 100755 --- a/lib/app/routes/app_pages.dart +++ b/lib/app/routes/app_pages.dart @@ -10,6 +10,8 @@ import 'package:kaer_with_panels/app/modules/hi_user_info/views/hi_user_info_vie import 'package:kaer_with_panels/app/modules/hi_anti_lost/bindings/hi_anti_lost_binding.dart'; import 'package:kaer_with_panels/app/modules/hi_anti_lost/views/hi_anti_lost_view.dart'; +import '../modules/kr_chatwoot/bindings/kr_chatwoot_binding.dart'; +import '../modules/kr_chatwoot/views/kr_chatwoot_view.dart'; import '../modules/kr_crisp_chat/bindings/kr_crisp_binding.dart'; import '../modules/kr_crisp_chat/views/kr_crisp_view.dart'; import '../modules/kr_delete_account/bindings/kr_delete_account_binding.dart'; @@ -138,5 +140,11 @@ class AppPages { binding: HIAntiLostBinding(), popGesture: false, ), + GetPage( + name: _Paths.KR_CHATWOOT, + page: () => SwipeWrapper.detect(() => const KRChatwootView()), + binding: KRChatwootBinding(), + popGesture: false, + ), ]; } diff --git a/lib/app/routes/app_routes.dart b/lib/app/routes/app_routes.dart index 60534f3..0984f46 100755 --- a/lib/app/routes/app_routes.dart +++ b/lib/app/routes/app_routes.dart @@ -25,6 +25,7 @@ abstract class Routes { static const HI_HELP = _Paths.HI_HELP; static const HI_USER_INFO = _Paths.HI_USER_INFO; static const HI_ANTI_LOST = _Paths.HI_ANTI_LOST; + static const KR_CHATWOOT = _Paths.KR_CHATWOOT; } abstract class _Paths { @@ -50,4 +51,5 @@ abstract class _Paths { static const HI_HELP = '/hi_help'; static const HI_USER_INFO = '/hi-user-info'; static const HI_ANTI_LOST = '/hi-anti-lost'; + static const KR_CHATWOOT = '/kr-chatwoot'; }