From ec30eb24566740f88d4a1f336d1faab008f4031f Mon Sep 17 00:00:00 2001 From: Seven Tsui <16225583+youyouliangshao@user.noreply.gitee.com> Date: Mon, 15 Sep 2025 10:32:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B8=E9=94=80=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api/shop_api.dart | 3 +++ lib/pages/chat/index.dart | 18 +++++++++++++++--- lib/pages/chat/notify/system.dart | 30 +++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/lib/api/shop_api.dart b/lib/api/shop_api.dart index 4d43e66..43b9f0f 100644 --- a/lib/api/shop_api.dart +++ b/lib/api/shop_api.dart @@ -44,4 +44,7 @@ class ShopApi { // 确认核销 static const String confirmWriteOff= '/app/merchant/order/verify'; + + // 绑定推广码 + static const String bindSpreadCodeId= '/app/member/bind/spread'; } diff --git a/lib/pages/chat/index.dart b/lib/pages/chat/index.dart index 6437d61..9ae8b0a 100644 --- a/lib/pages/chat/index.dart +++ b/lib/pages/chat/index.dart @@ -10,6 +10,8 @@ import 'package:loopin/IM/im_service.dart'; import 'package:loopin/components/network_or_asset_image.dart'; import 'package:loopin/components/scan_util.dart'; import 'package:loopin/models/conversation_type.dart'; +import 'package:loopin/api/shop_api.dart'; +import 'package:loopin/service/http.dart'; import 'package:loopin/models/conversation_view_model.dart'; import 'package:loopin/utils/index.dart'; import 'package:loopin/utils/scan_code_type.dart'; // 导入外部枚举 @@ -98,9 +100,19 @@ class ChatPageState extends State { } // 处理推广码 - void _handlePromotionCode(String value) { - print('处理推广码: $value'); - Get.toNamed('/vloger', arguments: {'memberId':value}); + void _handlePromotionCode(String value)async { + try { + print('处理推广码111: $value'); + final res = await Http.post('${ShopApi.bindSpreadCodeId}', data: { + "socialCode": value + }); + if(res != null && res['code'] == 200){ + MyDialog.toast('推广码绑定失败', icon: const Icon(Icons.check_circle), style: ToastStyle(backgroundColor: Colors.green.withAlpha(200))); + Get.toNamed('/vloger', arguments: {'memberId':value}); + } + } catch (e) { + MyDialog.toast('推广码绑定失败'); + } } // 长按菜单 void showContextMenu(BuildContext context, ConversationViewModel item) { diff --git a/lib/pages/chat/notify/system.dart b/lib/pages/chat/notify/system.dart index 8f20525..7b3fa6e 100644 --- a/lib/pages/chat/notify/system.dart +++ b/lib/pages/chat/notify/system.dart @@ -169,9 +169,33 @@ class SystemState extends State { } // 处理推广码 - void _handlePromotionCode(String value) { - print('处理推广码: $value'); - Get.toNamed('/vloger', arguments: {'memberId':value}); + void _handlePromotionCode(String value)async { + try { + print('处理推广码111: $value'); + final res = await Http.post('${ShopApi.bindSpreadCodeId}', data: { + "socialCode": value + }); + if(res != null && res['code'] == 200){ + MyDialog.toast('推广码绑定失败', icon: const Icon(Icons.check_circle), style: ToastStyle(backgroundColor: Colors.green.withAlpha(200))); + Get.toNamed('/vloger', arguments: {'memberId':value}); + } + } catch (e) { + MyDialog.toast('推广码绑定失败'); + } + } + + // 绑定推广码和人员关系 + bindSpreadCode(code) async { + try { + final res = await Http.post('${ShopApi.bindSpreadCodeId}', data: { + "socialCode": "01901839908031348736" + }); + print('绑定结果-------------->${res['res']}'); + + } catch (e) { + + MyDialog.toast('推广码绑定失败'); + } } @override