diff --git a/android/app/src/main/res/xml/network_security_config.xml b/android/app/src/main/res/xml/network_security_config.xml index 61ebdf0..8b145c5 100644 --- a/android/app/src/main/res/xml/network_security_config.xml +++ b/android/app/src/main/res/xml/network_security_config.xml @@ -11,6 +11,6 @@ - dating-agency-test.oss-accelerate.aliyuncs.com + dating-agency-download-test.qniao.cn \ No newline at end of file diff --git a/lib/controller/discover/room_controller.dart b/lib/controller/discover/room_controller.dart index c5d184e..6342779 100644 --- a/lib/controller/discover/room_controller.dart +++ b/lib/controller/discover/room_controller.dart @@ -9,6 +9,7 @@ import 'package:dating_touchme_app/model/rtc/rtc_channel_data.dart'; import 'package:dating_touchme_app/model/rtc/rtc_channel_detail.dart'; import 'package:dating_touchme_app/network/network_service.dart'; import 'package:dating_touchme_app/pages/mine/edit_info_page.dart'; +import 'package:dating_touchme_app/pages/setting/match_league_page.dart'; import 'package:dating_touchme_app/rtc/rtc_manager.dart'; import 'package:dating_touchme_app/rtc/rtm_manager.dart'; import 'package:dating_touchme_app/service/live_chat_message_service.dart'; @@ -143,7 +144,6 @@ class RoomController extends GetxController with WidgetsBindingObserver { if (isLive.value) { return; } - // 检查是否正在通话中(包括呼叫中) try { // 先尝试使用 Get.find 获取已注册的实例,如果不存在再使用 instance @@ -749,7 +749,12 @@ class RoomController extends GetxController with WidgetsBindingObserver { } } - void registerMatch() async { + void registerMatch(int type) async { + if (GlobalData().userData!.profilePhoto == null || GlobalData().userData!.profilePhoto!.isEmpty) { + SmartDialog.showToast('请先上传头像'); + await Get.to(() => EditInfoPage()); + return; + } if (GlobalData().userData!.auditProfilePhoto != null) { showGeneralDialog( context: Get.context!, @@ -763,18 +768,16 @@ class RoomController extends GetxController with WidgetsBindingObserver { ); return; } - if (GlobalData().userData!.profilePhoto == null || GlobalData().userData!.profilePhoto!.isEmpty) { - SmartDialog.showToast('请先上传头像'); - await Get.to(() => EditInfoPage()); - return; - } if(GlobalData().userData!.identityCard == null || GlobalData().userData!.identityCard!.isEmpty){ SmartDialog.showToast('请先进行实名认证'); await Get.to(() => RealNamePage(type: 1)); return; } - await Get.to(() => MatchSpreadPage()); - matchmakerFlag.value = GlobalData().userData!.matchmakerFlag!; + if(type == 1){ + Get.to(() => MatchLeaguePage()); + } else { + await createRtcChannel(); + } } /// 踢出 RTC 频道用户 diff --git a/lib/controller/mine/auth_controller.dart b/lib/controller/mine/auth_controller.dart index 909a948..e2a70fe 100644 --- a/lib/controller/mine/auth_controller.dart +++ b/lib/controller/mine/auth_controller.dart @@ -116,18 +116,16 @@ class AuthController extends GetxController { GlobalData().userData!.name = name.value; SmartDialog.showToast('认证成功'); getInfo(); - final RoomController _roomController; - _roomController = Get.isRegistered() + final RoomController roomController = Get.isRegistered() ? Get.find() : Get.put(RoomController()); - _roomController.matchmakerFlag.value = GlobalData().userData!.matchmakerFlag!; - + roomController.matchmakerFlag.value = GlobalData().userData!.matchmakerFlag!; final HomeController hController = Get.find(); hController.refreshRecommendData(); hController.refreshNearbyData(); - if(type == 1){ + if(type == 1 && !GlobalData().userData!.matchmakerFlag!){ // 进入认证成功之后的下一个页面; Get.off(() => MatchSpreadPage()); } else { @@ -139,13 +137,9 @@ class AuthController extends GetxController { } catch (e) { // SmartDialog.showToast('网络请求失败,请检查网络连接'); // SmartDialog.showToast(response.data.message); - } finally { - } } - - getInfo() async { final result = await _userApi.getMarriageInformationDetail(); // print(result.data); diff --git a/lib/controller/mine/league_controller.dart b/lib/controller/mine/league_controller.dart index a3acee4..ca41aa6 100644 --- a/lib/controller/mine/league_controller.dart +++ b/lib/controller/mine/league_controller.dart @@ -1,110 +1,50 @@ import 'dart:async'; +import 'package:dating_touchme_app/model/mine/chat_static_data.dart'; +import 'package:dating_touchme_app/pages/setting/match_spread_page.dart'; import 'package:get/get.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import '../../network/user_api.dart'; -import '../../pages/setting/match_spread_page.dart'; import '../global.dart'; class LeagueController extends GetxController { + late UserApi _userApi; - final phone = ''.obs; - // 手机号输入 - final phoneNumber = ''.obs; - // 验证码输入 - final verificationCode = ''.obs; - // 是否正在发送验证码 - final isSendingCode = false.obs; - // 倒计时秒数 - final countdownSeconds = 0.obs; - final agree = false.obs; + final genderCode = 0.obs; + final consumption = ChatStaticData(liveDurationMins: 0).obs; + final hours = 0.obs; + final canApply = false.obs; @override void onInit() { super.onInit(); // 从全局依赖中获取UserApi _userApi = Get.find(); - phone.value = GlobalData().userData!.phone!; - } - - // 获取验证码 - Future getVerificationCode() async { - if (countdownSeconds.value > 0) { - return; - } - // 验证手机号格式 - if (phoneNumber.value.isEmpty || phoneNumber.value.length != 11) { - SmartDialog.showToast('请输入正确的手机号'); - return; - } - isSendingCode.value = true; - try { - // 构建请求参数 - final params = { - 'purpose': 2, // 红娘申请 - 'verifiableAccount': phoneNumber.value, - 'verifiableAccountType': 1, // 手机 - }; - // 调用UserApi中的验证码接口 - final response = await _userApi.getVerificationCode(params); - // 处理响应 - if (response.data.isSuccess) { - // 生产环境移除打印,可考虑使用正式的日志框架 - SmartDialog.showToast('验证码发送成功'); - // 开始倒计时 - countdownSeconds.value = 60; - startCountdown(); - } else { - SmartDialog.showToast(response.data.message); - } - } catch (e) { - SmartDialog.showToast('网络请求失败,请重试'); - } finally { - isSendingCode.value = false; - } + genderCode.value = GlobalData().userData!.genderCode!; + fetchData(); } - // 开始倒计时 - void startCountdown() { - Future.delayed(const Duration(seconds: 1), () { - if (countdownSeconds.value > 0) { - countdownSeconds.value--; - startCountdown(); - } else { - isSendingCode.value = false; - } - }); - } + fetchData() async { + try{ + final response = await _userApi.getChatStaticsInfo(); + if (response.data.isSuccess && response.data.data != null) { + consumption.value = response.data.data!; + } + final result = await _userApi.getMatchmakerRequirement(); + if (result.data.isSuccess && result.data.data != null) { + final roseList = result.data.data!; + hours.value = roseList[0].liveDurationHours!; + } + canApply.value = consumption.value.liveDurationMins! >= hours.value * 60; + } catch (e) { + print('spread: $e'); + } + } - Future submitInfo() async { - if(isSendingCode.value){ - return; - } - if (phoneNumber.value.isEmpty) { - SmartDialog.showToast('请输入手机号'); - return; - } - if (verificationCode.value.isEmpty) { - SmartDialog.showToast('请输入验证码'); - return; - } - isSendingCode.value = true; - try { - // 调用登录接口 - SmartDialog.showLoading(msg: '处理中'); - final param = { 'phone': phoneNumber.value, 'captcha': verificationCode.value}; - final response = await _userApi.updatePhone(param); - // 处理响应 - if (response.data.isSuccess) { - SmartDialog.showToast('提交成功'); - Get.off(() => MatchSpreadPage()); - } else { - SmartDialog.showToast(response.data.message); - } - } catch (e) { - SmartDialog.showToast('网络请求失败,请检查网络连接'); - } finally { - SmartDialog.dismiss(); - isSendingCode.value = true; + applyMatcher(){ + if(canApply.value){ + Get.off(() => MatchSpreadPage()); + } else { + Get.back(); } } diff --git a/lib/controller/mine/mine_controller.dart b/lib/controller/mine/mine_controller.dart index 381607c..e6d838d 100644 --- a/lib/controller/mine/mine_controller.dart +++ b/lib/controller/mine/mine_controller.dart @@ -9,6 +9,7 @@ import 'package:dating_touchme_app/pages/mine/real_name_page.dart'; import 'package:dating_touchme_app/pages/mine/rose_page.dart'; import 'package:dating_touchme_app/pages/mine/user_help_center_page.dart'; import 'package:dating_touchme_app/pages/setting/match_spread_page.dart'; +import 'package:dating_touchme_app/pages/setting/match_task_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -24,6 +25,7 @@ class MineController extends GetxController { final countData = UserCountData(friendNum: 0, friendApplyNum: 0, visitorNum:0).obs; late UserApi _userApi; + var matchmakerFlag = false.obs; @override void onInit() { @@ -31,9 +33,10 @@ class MineController extends GetxController { userData.value = GlobalData().userData; userId.value = GlobalData().userId; _userApi = Get.find(); + matchmakerFlag.value = GlobalData().userData!.matchmakerFlag!; } - void registerMatch() async { + void registerMatch(int type) async { if (GlobalData().userData!.auditProfilePhoto != null) { showGeneralDialog( context: Get.context!, @@ -57,7 +60,11 @@ class MineController extends GetxController { await Get.to(() => RealNamePage(type: 1)); return; } - await Get.to(() => MatchSpreadPage()); + if(type == 1){ + await Get.to(() => MatchSpreadPage()); + } else if(type == 2){ + Get.to(() => MatchTaskPage()); + } } } \ No newline at end of file diff --git a/lib/controller/mine/user_controller.dart b/lib/controller/mine/user_controller.dart index 72c2ca2..66430ca 100644 --- a/lib/controller/mine/user_controller.dart +++ b/lib/controller/mine/user_controller.dart @@ -98,10 +98,18 @@ class UserController extends GetxController { if (result.data.isSuccess) { if(result.data.data == null){ var information = UserData(); - information.matchmakerFlag = baseInfo.matchmakerFlag; - if(information.matchmakerFlag!){ - information.matchmakerType = baseInfo.matchmakerType; + + if(baseInfo.liveMatchmaker != null && baseInfo.liveMatchmaker!.enable!){ + information.matchmakerFlag = true; + information.matchmakerType = baseInfo.liveMatchmaker!.type; + } else { + information.matchmakerFlag = false; } + + // information.matchmakerFlag = baseInfo.matchmakerFlag; + // if(information.matchmakerFlag!){ + // information.matchmakerType = baseInfo.matchmakerType; + // } information.realName = baseInfo.realName; information.phone = baseInfo.phone; GlobalData().userData = information; @@ -115,9 +123,11 @@ class UserController extends GetxController { return; } final information = result.data.data!; - information.matchmakerFlag = baseInfo.matchmakerFlag; - if(information.matchmakerFlag!){ - information.matchmakerType = baseInfo.matchmakerType; + if(baseInfo.liveMatchmaker != null && baseInfo.liveMatchmaker!.enable!){ + information.matchmakerFlag = true; + information.matchmakerType = baseInfo.liveMatchmaker!.type; + } else { + information.matchmakerFlag = false; } information.realName = baseInfo.realName; information.phone = baseInfo.phone; diff --git a/lib/controller/setting/setting_controller.dart b/lib/controller/setting/setting_controller.dart index 5a175cb..a7d028f 100644 --- a/lib/controller/setting/setting_controller.dart +++ b/lib/controller/setting/setting_controller.dart @@ -5,6 +5,7 @@ import 'package:dating_touchme_app/controller/discover/room_controller.dart'; import 'package:dating_touchme_app/controller/overlay_controller.dart'; import 'package:dating_touchme_app/im/im_manager.dart'; import 'package:dating_touchme_app/extension/ex_widget.dart'; +import 'package:dating_touchme_app/pages/main/update_dialog.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -50,10 +51,12 @@ class SettingController extends GetxController { Future checkVersion() async { try { final response = await _userApi.getAppVersionInfo(os: 1, code: int.parse(buildNumber.value)); - print(response); if (response.data.isSuccess && response.data.data != null) { AppVersion version = response.data.data!; - _showUpdateDialog(version); + showDialog( + context: Get.context!, + builder: (context) => UpdateDialog(version: version) + ); } } catch (e) { print('检测版本跟新失败: $e'); @@ -100,149 +103,5 @@ class SettingController extends GetxController { GlobalData().logout(); } - void updateApplication(){ - - } - - // 弹出版本升级的dialog - void _showUpdateDialog(AppVersion version){ - Navigator.of(Get.context!).push(TDSlidePopupRoute( - modalBarrierColor: TDTheme.of(Get.context!).fontGyColor2, - slideTransitionFrom: SlideTransitionFrom.center, - builder: (context) { - return Material( - color: Colors.transparent, - child: Container( - color: Colors.transparent, - width: 299.w, - padding: EdgeInsets.only(top: 56.w), - child: Stack( - clipBehavior: Clip.none, - children: [ - Container( - width: 299.w, - padding: EdgeInsets.only( - top: 147.w, - left: 30.w, - right: 30.w, - bottom: 25.w - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(18.w)), - color: Colors.white - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - version.title!, - style: TextStyle( - fontSize: 16.w, - fontWeight: FontWeight.w500 - ), - ), - SizedBox(height: 14.w,), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 204.w, - child: Text( - version.description!, - style: TextStyle( - fontSize: 12.w, - ), - ), - ) - ], - ), - SizedBox(height: 32.w,), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - width: 113.w, - height: 40.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(9.w)), - color: const Color.fromRGBO(245, 245, 245, 1) - ), - child: Center( - child: Text( - "暂不更新", - style: TextStyle( - fontSize: 15.w, - color: const Color.fromRGBO(144, 144, 144, 1) - ), - ), - ), - ).onTap((){ - Navigator.of(context).pop(); - }), - Container( - width: 113.w, - height: 40.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(9.w)), - color: const Color.fromRGBO(245, 245, 245, 1), - gradient: const LinearGradient( - begin: Alignment.centerLeft, - end: Alignment.centerRight, // 对应 CSS 90deg - colors: [ - Color.fromRGBO(131, 89, 255, 1), // rgba(131, 89, 255, 1) - Color.fromRGBO(61, 138, 224, 1), // rgba(61, 138, 224, 1) - ], - ), - ), - child: Center( - child: Text( - "立即升级", - style: TextStyle( - fontSize: 15.w, - fontWeight: FontWeight.w500, - color: Colors.white - ), - ), - ), - ).onTap((){ - updateApplication(); - }), - ], - ) - ], - ), - ), - Positioned( - left: 0, - top: -56.w, - child: Image.asset( - Assets.imagesUpdataBg, - width: 299.w, - ), - ), - Positioned( - left: 11.w, - top: -14.w, - child: Image.asset( - Assets.imagesUpdataIcon, - width: 36.w, - ), - ), - Positioned( - left: 43.w, - top: 29.w, - child: Image.asset( - Assets.imagesUpdataFont, - width: 76.w, - ), - ) - ], - ), - ), - ); - })); - } - } diff --git a/lib/controller/setting/spread_controller.dart b/lib/controller/setting/spread_controller.dart index a02b00c..1493438 100644 --- a/lib/controller/setting/spread_controller.dart +++ b/lib/controller/setting/spread_controller.dart @@ -1,17 +1,17 @@ import 'package:dating_touchme_app/controller/global.dart'; -import 'package:dating_touchme_app/model/mine/rose_data.dart'; +import 'package:dating_touchme_app/model/mine/chat_static_data.dart'; +import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart'; import 'package:dating_touchme_app/network/user_api.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:fluwx/fluwx.dart'; import 'package:get/get.dart'; -class SpreadController extends GetxController with WidgetsBindingObserver { +class SpreadController extends GetxController { // UserApi实例 late UserApi _userApi; - final roseList = [].obs; - + final roseList = [].obs; + final loading = true.obs; final roseNum = 0.obs; final payChecked = true.obs; @@ -20,8 +20,8 @@ class SpreadController extends GetxController with WidgetsBindingObserver { final enableIndex = (-1).obs; final Fluwx fluwx = Fluwx(); final matchmakerFlag = false.obs; - final button = '去相亲'.obs; - bool canApply = false; + final button = '立即申请'.obs; + final canApply = false.obs; String paymentOrderId = ''; final revenue = [ {'icon': '1', 'desc': '礼物收益范围15%-30%,嘉宾消费的分成3%;'}, @@ -29,48 +29,109 @@ class SpreadController extends GetxController with WidgetsBindingObserver { {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, ].obs; + final userData = GlobalData().userData.obs; + final userId = GlobalData().userId.obs; + + final consumption = ChatStaticData().obs; + // final nowBankCard = BankCardData().obs; + + // changePayActive(int index){ + // if(index < enableIndex.value && enableIndex.value >= 0){ + // return; + // } + // activePay.value = index; + // if(matchmakerFlag.value){ + // if(activePay.value > enableIndex.value){ + // button.value = '立即升级'; + // } else if(activePay.value == 0){ + // button.value = '去直播'; + // } else { + // button.value = '立即续费'; + // } + // } else if(activePay.value == 0){ + // button.value = canApply.value ? '免费加入' : '去相亲'; + // } else { + // button.value = '立即加入'; + // } + // // 实习红娘 + // if(roseList[activePay.value].type == 88804){ + // revenue.value = [ + // {'icon': '1', 'desc': '礼物收益范围15%-30%,嘉宾消费的分成3%;'}, + // {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, + // {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, + // {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, + // ]; + // } else if(roseList[activePay.value].type == 88803){ + // revenue.value = [ + // {'icon': '1', 'desc': '礼物收益范围30%-40%,嘉宾消费的分成6%;'}, + // {'icon': '2', 'desc': '每天前5人连麦的礼物收益30%,第6-10人连麦的礼物收益35%,第11人以上连麦的礼物收益40%;'}, + // {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, + // {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, + // ]; + // } else if(roseList[activePay.value].type == 88802){ + // revenue.value = [ + // {'icon': '1', 'desc': '礼物收益范围40%,嘉宾消费的分成10%;'}, + // // {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, + // {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, + // {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, + // ]; + // } else if(roseList[activePay.value].type == 88801){ + // revenue.value = [ + // {'icon': '1', 'desc': '礼物收益范围40%,嘉宾消费的分成10%;'}, + // // {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, + // {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, + // {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, + // ]; + // } + // + // } + // 倒计时秒数 + final countdownSeconds = 0.obs; + + @override + void onInit() { + super.onInit(); + // WidgetsBinding.instance.addObserver(this); + _userApi = Get.find(); + if(GlobalData().userData!.matchmakerFlag != null && GlobalData().userData!.matchmakerFlag!){ + matchmakerFlag.value = true; + } + initDataList(); + } changePayActive(int index){ if(index < enableIndex.value && enableIndex.value >= 0){ return; } activePay.value = index; - if(matchmakerFlag.value){ - if(activePay.value > enableIndex.value){ - button.value = '立即升级'; - } else if(activePay.value == 0){ - button.value = '去直播'; - } else { - button.value = '立即续费'; + canApply.value = false; + int hours = roseList[activePay.value].liveDurationHours!; + int rose = roseList[activePay.value].liveConsumptionAmount!; + if(hours > 0 && consumption.value.liveDurationMins! >= 60 * hours){ + if(rose <= 0){ + canApply.value = true; + } else if(consumption.value.liveConsumptionAmount! >= rose){ + canApply.value = true; } - } else if(activePay.value == 0){ - button.value = canApply ? '免费加入' : '去相亲'; - } else { - button.value = '立即加入'; } + + button.value = canApply.value ? '立即申请' : '条件不满足'; // 实习红娘 - if(roseList[activePay.value].subCategory == 88804){ + if(roseList[activePay.value].type == 1){ revenue.value = [ {'icon': '1', 'desc': '礼物收益范围15%-30%,嘉宾消费的分成3%;'}, {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, ]; - } else if(roseList[activePay.value].subCategory == 88803){ + } else if(roseList[activePay.value].type == 2){ revenue.value = [ {'icon': '1', 'desc': '礼物收益范围30%-40%,嘉宾消费的分成6%;'}, {'icon': '2', 'desc': '每天前5人连麦的礼物收益30%,第6-10人连麦的礼物收益35%,第11人以上连麦的礼物收益40%;'}, {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, ]; - } else if(roseList[activePay.value].subCategory == 88802){ - revenue.value = [ - {'icon': '1', 'desc': '礼物收益范围40%,嘉宾消费的分成10%;'}, - // {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, - {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, - {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, - ]; - } else if(roseList[activePay.value].subCategory == 88801){ + } else if(roseList[activePay.value].type == 3){ revenue.value = [ {'icon': '1', 'desc': '礼物收益范围40%,嘉宾消费的分成10%;'}, // {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, @@ -80,85 +141,78 @@ class SpreadController extends GetxController with WidgetsBindingObserver { } } - // 倒计时秒数 - final countdownSeconds = 0.obs; - @override - void onInit() { - super.onInit(); - WidgetsBinding.instance.addObserver(this); - _userApi = Get.find(); - if(GlobalData().userData!.matchmakerFlag != null && GlobalData().userData!.matchmakerFlag!){ - matchmakerFlag.value = true; - } - initDataList(); - } - - @override - void didChangeAppLifecycleState(AppLifecycleState state) { - if(state == AppLifecycleState.resumed){ - if (countdownSeconds.value > 0) { - startCountdown(); - } - } - } + // @override + // void didChangeAppLifecycleState(AppLifecycleState state) { + // if(state == AppLifecycleState.resumed){ + // if (countdownSeconds.value > 0) { + // startCountdown(); + // } + // } + // } // 开始倒计时 - void startCountdown() async { - try{ - bool audit = false; - if(matchmakerFlag.value){ - // 如果是红娘,那么就要检测支付单是否支付成功, - - } else { - // 如果是不是红娘,那么就要检测用户是否变成了红娘, - final response = await _userApi.getAuditMatchmaker(); - if (response.data.isSuccess && response.data.data != null) { - audit = response.data.data['needAudit']; - } - } - if(audit){ - Future.delayed(const Duration(milliseconds: 300), () { - if (countdownSeconds.value > 0) { - countdownSeconds.value--; - startCountdown(); - } - }); - } else { - countdownSeconds.value = 0; - GlobalData().userData!.matchmakerFlag = true; - GlobalData().userData!.matchmakerType = roseList[activePay.value].subCategory; - Get.back(result: 1); - } - } catch (e) { - print('87$e'); - } - } + // void startCountdown() async { + // try{ + // bool audit = false; + // if(matchmakerFlag.value){ + // // 如果是红娘,那么就要检测支付单是否支付成功, + // + // } else { + // // 如果是不是红娘,那么就要检测用户是否变成了红娘, + // final response = await _userApi.getAuditMatchmaker(); + // if (response.data.isSuccess && response.data.data != null) { + // audit = response.data.data['needAudit']; + // } + // } + // if(audit){ + // Future.delayed(const Duration(milliseconds: 300), () { + // if (countdownSeconds.value > 0) { + // countdownSeconds.value--; + // startCountdown(); + // } + // }); + // } else { + // countdownSeconds.value = 0; + // GlobalData().userData!.matchmakerFlag = true; + // GlobalData().userData!.matchmakerType = roseList[activePay.value].type; + // Get.back(result: 1); + // } + // } catch (e) { + // print('87$e'); + // } + // } @override void onClose() { - WidgetsBinding.instance.removeObserver(this); + // WidgetsBinding.instance.removeObserver(this); super.onClose(); } initDataList() async { try{ - final result = await _userApi.getMatchmakerFee(); + loading.value = true; + final result = await _userApi.getMatchmakerRequirement(); if (result.data.isSuccess && result.data.data != null) { - roseList.value = result.data.data!.records; + roseList.value = result.data.data!; } final response = await _userApi.getChatStaticsInfo(); if (response.data.isSuccess && response.data.data != null) { - final data = response.data.data!; + consumption.value = response.data.data!; if(roseList[activePay.value].liveDurationHours != null){ - int hours = int.parse(roseList[activePay.value].liveDurationHours!); - if(hours > 0 && data.liveDurationMins >= 60 * hours && !matchmakerFlag.value){ - canApply = true; + int hours = roseList[activePay.value].liveDurationHours!; + int rose = roseList[activePay.value].liveConsumptionAmount!; + if(hours > 0 && consumption.value.liveDurationMins! >= 60 * hours){ + if(rose <= 0){ + canApply.value = true; + } else if(consumption.value.liveConsumptionAmount! >= rose){ + canApply.value = true; + } } } } if(matchmakerFlag.value){ - final index = roseList.indexWhere((item) => item.subCategory == GlobalData().userData!.matchmakerType!); + final index = roseList.indexWhere((item) => item.type == GlobalData().userData!.matchmakerType!); enableIndex.value = index >= 0 ? index : 0; changePayActive(enableIndex.value); } else { @@ -166,57 +220,26 @@ class SpreadController extends GetxController with WidgetsBindingObserver { } } catch (e) { print('spread: $e'); + } finally { + loading.value = false; } } submitOrder() async { - if(activePay.value == 0 && !canApply){ - Get.back(); + if(!canApply.value){ return; } try { - var matchmakerOrderType = 1; - var matchmakerType = roseList[activePay.value].subCategory; - if(GlobalData().userData!.matchmakerFlag!){ - if(matchmakerType != GlobalData().userData!.matchmakerType){ - matchmakerOrderType = 2; - } else { - matchmakerOrderType = 3; - } - } else { - await _userApi.applyMatchmaker({ - "phone": GlobalData().userData!.phone, - "name": GlobalData().userData!.name - }); - } - final response = await _userApi.submitMatchmakerOrder({ - "productSpecId": roseList[activePay.value].productSpecId, - "matchmakerOrderType": matchmakerOrderType + final response = await _userApi.applyLiveMatchmaker({ + "behavior": GlobalData().userData!.matchmakerFlag! ? 2 : 1, + "type": roseList[activePay.value].type }); - if (response.data.isSuccess && response.data.data != null) { - final data = response.data.data; - - if(data!.freeSettlement!){ - SmartDialog.showToast('加入成功'); - GlobalData().userData!.matchmakerFlag = true; - GlobalData().userData!.matchmakerType = roseList[activePay.value].subCategory; - Get.back(result: 1); - } else { - paymentOrderId = data.paymentOrderId!; - fluwx.open(target: MiniProgram( - username: 'gh_9ea8d46add6f', - path: "pages/index/index?amount=${roseList[activePay.value].unitSellingPrice}&paymentOrderId=${data.paymentOrderId}&url=match-fee", - miniProgramType: WXMiniProgramType.preview - )); - countdownSeconds.value = 3; - SmartDialog.showToast('开始支付'); - } - } else { - // 响应失败,抛出异常 - SmartDialog.showToast(response.data.message ?? '网络异常'); + if (response.data.isSuccess) { + SmartDialog.showToast('申请成功,请等待审核'); + Get.back(); } } catch (e) { - SmartDialog.showToast('下单失败'); + SmartDialog.showToast('申请失败'); } } diff --git a/lib/controller/setting/task_controller.dart b/lib/controller/setting/task_controller.dart index b3b3711..0461c49 100644 --- a/lib/controller/setting/task_controller.dart +++ b/lib/controller/setting/task_controller.dart @@ -1,9 +1,6 @@ -import 'package:dating_touchme_app/controller/global.dart'; -import 'package:dating_touchme_app/model/mine/chat_static_data.dart'; import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart'; import 'package:dating_touchme_app/network/user_api.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:fluwx/fluwx.dart'; import 'package:get/get.dart'; class TaskController extends GetxController { @@ -11,135 +8,30 @@ class TaskController extends GetxController { // UserApi实例 late UserApi _userApi; final roseList = [].obs; - - final roseNum = 0.obs; - - final payChecked = true.obs; - - final activePay = 0.obs; - final enableIndex = (-1).obs; - final Fluwx fluwx = Fluwx(); - final matchmakerFlag = false.obs; - final button = '立即申请'.obs; - final canApply = false.obs; - String paymentOrderId = ''; - final revenue = [ - {'icon': '1', 'desc': '礼物收益范围15%-30%,嘉宾消费的分成3%;'}, - {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, - {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, - {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, - ].obs; - final userData = GlobalData().userData.obs; - final userId = GlobalData().userId.obs; - - final consumption = ChatStaticData().obs; - final countdownSeconds = 0.obs; + final loading = true.obs; @override void onInit() { super.onInit(); _userApi = Get.find(); - if(GlobalData().userData!.matchmakerFlag != null && GlobalData().userData!.matchmakerFlag!){ - matchmakerFlag.value = true; - } initDataList(); } - changePayActive(int index){ - if(index < enableIndex.value && enableIndex.value >= 0){ - return; - } - activePay.value = index; - canApply.value = false; - int hours = roseList[activePay.value].liveDurationHours!; - int rose = roseList[activePay.value].liveConsumptionAmount!; - if(hours > 0 && consumption.value.liveDurationMins! >= 60 * hours){ - if(rose <= 0){ - canApply.value = true; - } else if(consumption.value.liveConsumptionAmount! >= rose){ - canApply.value = true; - } - } - - button.value = canApply.value ? '立即申请' : '条件不满足'; - // 实习红娘 - if(roseList[activePay.value].type == 1){ - revenue.value = [ - {'icon': '1', 'desc': '礼物收益范围15%-30%,嘉宾消费的分成3%;'}, - {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, - {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, - {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, - ]; - } else if(roseList[activePay.value].type == 2){ - revenue.value = [ - {'icon': '1', 'desc': '礼物收益范围30%-40%,嘉宾消费的分成6%;'}, - {'icon': '2', 'desc': '每天前5人连麦的礼物收益30%,第6-10人连麦的礼物收益35%,第11人以上连麦的礼物收益40%;'}, - {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, - {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, - ]; - } else if(roseList[activePay.value].type == 3){ - revenue.value = [ - {'icon': '1', 'desc': '礼物收益范围40%,嘉宾消费的分成10%;'}, - // {'icon': '2', 'desc': '每天前5人连麦的礼物收益15%,第6-10人连麦的礼物收益20%,第11-15人连麦的礼物收益25%,第16人以上连麦的礼物收益30%;'}, - {'icon': '3', 'desc': '红娘推荐的嘉宾成为红娘,赚取入驻费的20%分成;'}, - {'icon': '4', 'desc': '新徒弟首月收益的10%(平台奖励)'}, - ]; - } - - } - - @override - void onClose() { - // WidgetsBinding.instance.removeObserver(this); - super.onClose(); - } - initDataList() async { try{ + loading.value = true; final result = await _userApi.getMatchmakerRequirement(); if (result.data.isSuccess && result.data.data != null) { roseList.value = result.data.data!; } - final response = await _userApi.getChatStaticsInfo(); - if (response.data.isSuccess && response.data.data != null) { - consumption.value = response.data.data!; - if(roseList[activePay.value].liveDurationHours != null){ - int hours = roseList[activePay.value].liveDurationHours!; - int rose = roseList[activePay.value].liveConsumptionAmount!; - if(hours > 0 && consumption.value.liveDurationMins! >= 60 * hours){ - if(rose <= 0){ - canApply.value = true; - } else if(consumption.value.liveConsumptionAmount! >= rose){ - canApply.value = true; - } - } - } - } - if(matchmakerFlag.value){ - final index = roseList.indexWhere((item) => item.type == GlobalData().userData!.matchmakerType!); - enableIndex.value = index >= 0 ? index : 0; - changePayActive(enableIndex.value); - } else { - changePayActive(0); - } - } catch (e) { - print('spread: $e'); + } finally { + loading.value = false; } } submitOrder() async { - if(!canApply.value){ - return; - } try { - final response = await _userApi.applyLiveMatchmaker({ - "behavior": GlobalData().userData!.matchmakerFlag! ? 2 : 1, - "type": roseList[activePay.value].type - }); - if (response.data.isSuccess) { - SmartDialog.showToast('申请成功,请等待审核'); - Get.back(); - } + } catch (e) { SmartDialog.showToast('申请失败'); } diff --git a/lib/model/mine/chat_static_data.dart b/lib/model/mine/chat_static_data.dart index 8982190..3bbf42e 100644 --- a/lib/model/mine/chat_static_data.dart +++ b/lib/model/mine/chat_static_data.dart @@ -1,16 +1,18 @@ // 登录响应实体类 class ChatStaticData { - final int id; - final int liveDurationMins; - final int todayCrossMicCount; + int? id; + int? liveDurationMins; + int? liveConsumptionAmount; + int? todayCrossMicCount; - ChatStaticData({required this.id, required this.liveDurationMins, required this.todayCrossMicCount}); + ChatStaticData({this.id, this.liveDurationMins, this.todayCrossMicCount, this.liveConsumptionAmount}); // 从JSON映射创建实例 factory ChatStaticData.fromJson(Map json) { return ChatStaticData( id: json['id'] ?? '', liveDurationMins: json['liveDurationMins'] ?? 0, + liveConsumptionAmount: json['liveConsumptionAmount'] ?? 0, todayCrossMicCount: json['todayCrossMicCount'] ?? 0, ); } @@ -21,11 +23,13 @@ class ChatStaticData { 'id': id, 'liveDurationMins': liveDurationMins, 'todayCrossMicCount': todayCrossMicCount, + 'liveConsumptionAmount': liveConsumptionAmount, }; } @override String toString() { - return 'LoginData(id: $id, liveDurationMins: $liveDurationMins)'; + return 'LoginData(id: $id, liveDurationMins: $liveDurationMins, liveConsumptionAmount: $liveConsumptionAmount)'; } + } \ No newline at end of file diff --git a/lib/model/mine/user_base_data.dart b/lib/model/mine/user_base_data.dart index a75673c..febedcf 100644 --- a/lib/model/mine/user_base_data.dart +++ b/lib/model/mine/user_base_data.dart @@ -1,3 +1,40 @@ +class LiveMatchmaker { + final String? userId; + final String? remark; + final String? id; + final bool? enable; + final int? type; + + LiveMatchmaker({ + this.userId, + this.remark, + this.id, + this.enable, + this.type, + }); + + factory LiveMatchmaker.fromJson(Map json) { + return LiveMatchmaker( + userId: json['userId'] as String?, + remark: json['remark'] as String?, + id: json['id'] as String?, + enable: json['enable'] as bool?, + type: json['type'] as int?, + ); + } + + Map toJson() { + return { + 'userId': userId, + 'remark': remark, + 'id': id, + 'enable': enable, + 'type': type, + }; + } +} + + // 用户基础信息实体类 class UserBaseData { final bool matchmakerFlag; @@ -6,9 +43,11 @@ class UserBaseData { final String phone; final String realName; final String userId; + final LiveMatchmaker? liveMatchmaker; final int matchmakerType; final bool? isOnline; // 在线状态 + UserBaseData({ required this.matchmakerFlag, required this.matchmakingCornerFlag, @@ -17,6 +56,7 @@ class UserBaseData { required this.realName, required this.userId, required this.matchmakerType, + this.liveMatchmaker, this.isOnline, }); @@ -30,6 +70,7 @@ class UserBaseData { phone: json['phone'] ?? '', realName: json['realName'] ?? '', userId: json['userId'] ?? '', + liveMatchmaker: json['liveMatchmaker'] != null ? LiveMatchmaker.fromJson(json['liveMatchmaker'] as Map) : null, isOnline: json['isOnline'] as bool?, ); } @@ -44,6 +85,7 @@ class UserBaseData { 'phone': phone, 'realName': realName, 'userId': userId, + 'liveMatchmaker': liveMatchmaker?.toJson(), 'isOnline': isOnline, }; } diff --git a/lib/network/api_urls.dart b/lib/network/api_urls.dart index b0f62c6..2883f48 100644 --- a/lib/network/api_urls.dart +++ b/lib/network/api_urls.dart @@ -113,6 +113,9 @@ class ApiUrls { static const String listMatchmakerProduct = 'dating-agency-mall/user/page/product/by/matchmaker'; + static const String listMatchmakerRequirement = + 'dating-agency-uec/user/list/live-matchmaker-apply-requirement'; + static const String auditMatchmakerResult = 'dating-agency-uec/user/need-audit/matchmaker-audit'; @@ -152,4 +155,7 @@ class ApiUrls { static const String consumeOneOnOneRtcChannel = 'dating-agency-chat-audio/user/consume/one-on-one/rtc-channel'; + static const String applyLiveMatchmaker = + 'dating-agency-uec/user/apply/live-matchmaker'; + } diff --git a/lib/network/user_api.dart b/lib/network/user_api.dart index a547459..b58c3e2 100644 --- a/lib/network/user_api.dart +++ b/lib/network/user_api.dart @@ -6,6 +6,7 @@ import 'package:dating_touchme_app/model/mine/education_data.dart'; import 'package:dating_touchme_app/model/mine/friend_apply_data.dart'; import 'package:dating_touchme_app/model/mine/friend_data.dart'; import 'package:dating_touchme_app/model/mine/login_data.dart'; +import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart'; import 'package:dating_touchme_app/model/mine/occupation_data.dart'; import 'package:dating_touchme_app/model/mine/payment_detail_data.dart'; import 'package:dating_touchme_app/model/mine/rose_data.dart'; @@ -203,6 +204,9 @@ abstract class UserApi { @GET(ApiUrls.listMatchmakerProduct) Future>>> getMatchmakerFee(); + @GET(ApiUrls.listMatchmakerRequirement) + Future>>> getMatchmakerRequirement(); + @GET(ApiUrls.auditMatchmakerResult) Future>> getAuditMatchmaker(); @@ -276,4 +280,9 @@ abstract class UserApi { @Query('versionCode') required int code, }); + @POST(ApiUrls.applyLiveMatchmaker) + Future>> applyLiveMatchmaker( + @Body() Map data, + ); + } diff --git a/lib/network/user_api.g.dart b/lib/network/user_api.g.dart index 095ff32..5eee020 100644 --- a/lib/network/user_api.g.dart +++ b/lib/network/user_api.g.dart @@ -1204,6 +1204,49 @@ class _UserApi implements UserApi { return httpResponse; } + @override + Future>>> + getMatchmakerRequirement() async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + const Map? _data = null; + final _options = + _setStreamType>>>( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + 'dating-agency-uec/user/list/live-matchmaker-apply-requirement', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl), + ), + ); + final _result = await _dio.fetch>(_options); + late BaseResponse> _value; + try { + _value = BaseResponse>.fromJson( + _result.data!, + (json) => json is List + ? json + .map( + (i) => MatchmakerRequirement.fromJson( + i as Map, + ), + ) + .toList() + : List.empty(), + ); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + final httpResponse = HttpResponse(_value, _result); + return httpResponse; + } + @override Future>> getAuditMatchmaker() async { final _extra = {}; @@ -1672,6 +1715,40 @@ class _UserApi implements UserApi { return httpResponse; } + @override + Future>> applyLiveMatchmaker( + Map data, + ) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = {}; + _data.addAll(data); + final _options = _setStreamType>>( + Options(method: 'POST', headers: _headers, extra: _extra) + .compose( + _dio.options, + 'dating-agency-uec/user/apply/live-matchmaker', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); + final _result = await _dio.fetch>(_options); + late BaseResponse _value; + try { + _value = BaseResponse.fromJson( + _result.data!, + (json) => json as dynamic, + ); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + final httpResponse = HttpResponse(_value, _result); + return httpResponse; + } + RequestOptions _setStreamType(RequestOptions requestOptions) { if (T != dynamic && !(requestOptions.responseType == ResponseType.bytes || diff --git a/lib/pages/discover/discover_page.dart b/lib/pages/discover/discover_page.dart index 462411f..4a00c2b 100644 --- a/lib/pages/discover/discover_page.dart +++ b/lib/pages/discover/discover_page.dart @@ -89,11 +89,7 @@ class _DiscoverPageState extends State theme: roomController.matchmakerFlag.value ? TDButtonTheme.danger : TDButtonTheme.primary, textStyle: TextStyle(fontSize: 10.w), onTap: () async { - if(roomController.matchmakerFlag.value){ - await roomController.createRtcChannel(); - } else { - roomController.registerMatch(); - } + roomController.registerMatch(roomController.matchmakerFlag.value ? 2 : 1); }, ), ); diff --git a/lib/pages/main/update_dialog.dart b/lib/pages/main/update_dialog.dart index 29f7ced..0cbda2d 100644 --- a/lib/pages/main/update_dialog.dart +++ b/lib/pages/main/update_dialog.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:ota_update/ota_update.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:tdesign_flutter/tdesign_flutter.dart'; class UpdateDialog extends StatefulWidget { @@ -83,6 +84,7 @@ class _UpdateDialogState extends State { type: TDProgressType.button, strokeWidth: 40.w, value: progressValue, + onTap: manualApkInstaller, label: buttonLabel, ) : !widget.version.isForcingUpdate! ? Row( @@ -199,30 +201,63 @@ class _UpdateDialogState extends State { } downloadAndInstall(AppVersion version) async { - try { - if (mounted) { - setState(() { - updating = true; - }); + // 请求权限 + final status = await Permission.storage.status; + if (!status.isGranted) { + final requestStatus = await Permission.storage.request(); + if (!requestStatus.isGranted) { + throw Exception('需要存储权限才能下载更新'); } - Get.log('url:${version.url!}'); - OtaUpdate().execute(version.url!, destinationFilename: '趣恋恋_${version.version}.apk').listen((OtaEvent event) { - print(event.value); // 下载进度百分比 - print("event.value"); - print(event.status); // 下载状态 + } + if (mounted) { + setState(() { + progressValue = 0.0; + updating = true; + }); + } + Get.log('url:${version.url!}'); + try { + OtaUpdate().execute(version.url!, destinationFilename: '趣恋恋_${version.version}.apk').listen( + (OtaEvent event) { + if(event.status == OtaStatus.DOWNLOADING){ + setState(() { + progressValue = int.parse(event.value!) / 100; + buttonLabel = TDTextLabel('${(progressValue * 100).toInt()}%'); + }); + } else if(event.status == OtaStatus.INSTALLING){ + setState(() { + buttonLabel = const TDTextLabel('开始安装'); + }); + } + }, + onError: (error){ + if (mounted) { + setState(() { + progressValue = 0.0; + buttonLabel = const TDTextLabel('开始'); + updating = false; + }); + } }, + onDone: (){ + if(progressValue == 1){ + setState(() { + buttonLabel = const TDTextLabel('重新安装'); + }); + } + } ); } catch (e) { - if (mounted) { - setState(() { - progressValue = 0.0; - buttonLabel = const TDTextLabel('开始'); - updating = false; - }); - } print('Failed to make OTA update. Details: $e'); } } + + manualApkInstaller(){ + if(progressValue == 1){ + downloadAndInstall(widget.version); + } + } + } diff --git a/lib/pages/mine/mine_page.dart b/lib/pages/mine/mine_page.dart index c7f6018..01ed132 100644 --- a/lib/pages/mine/mine_page.dart +++ b/lib/pages/mine/mine_page.dart @@ -335,9 +335,20 @@ class _MinePageState extends State with AutomaticKeepAliveClientMixin{ fontSize: 14.w ), ), onClick: (cell) { - controller.registerMatch(); + controller.registerMatch(1); } ), + if(controller.matchmakerFlag.value)TDCell(arrow: true, + leftIconWidget: Image.asset('assets/images/matcher_task.png', height: 20.w, width: 18.w), + titleWidget: Text( + " 红娘任务", + style: TextStyle( + fontSize: 14.w + ), + ), onClick: (cell) { + controller.registerMatch(2); + } + ), ], ), diff --git a/lib/pages/setting/match_league_page.dart b/lib/pages/setting/match_league_page.dart index bbc4a5d..86d0eef 100644 --- a/lib/pages/setting/match_league_page.dart +++ b/lib/pages/setting/match_league_page.dart @@ -1,10 +1,11 @@ import 'package:dating_touchme_app/extension/ex_widget.dart'; +import 'package:dating_touchme_app/generated/assets.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:tdesign_flutter/tdesign_flutter.dart'; -import '../../components/page_appbar.dart'; import '../../controller/mine/league_controller.dart'; class MatchLeaguePage extends StatelessWidget { @@ -14,104 +15,140 @@ class MatchLeaguePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: Color(0xffFFFFFF), - appBar: PageAppbar(title: "填写申请资料"), - body: Column( - children: [ - SizedBox(height: 12), - TDInput( - type: TDInputType.cardStyle, - inputType: TextInputType.phone, - maxLength: 11, - cardStyle: TDCardStyle.topText, - width: MediaQuery.of(context).size.width - 40, - hintText: '请输入你的手机号', - onChanged: (text) { - } + appBar: AppBar( + leading: IconButton( + icon: Icon(TDIcons.chevron_left, size: 30, color: Colors.black), + onPressed: () => Get.back(), + ), + title: Obx(() => Text( + '申请${controller.genderCode.value == 0 ? '红娘' : '红娘'}', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + )), + centerTitle: true, + backgroundColor: Colors.white, + ), + body: Stack( + children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/matcher_apply.png'), + fit: BoxFit.cover, + ), ), - SizedBox(height: 24), - TDInput( - type: TDInputType.cardStyle, - inputType: TextInputType.number, - maxLength: 6, - cardStyle: TDCardStyle.topText, - width: MediaQuery.of(context).size.width - 40, - hintText: '请输入验证码', - onChanged: (text) { - controller.verificationCode.value = text; - }, - rightBtn: SizedBox( - width: 100, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: const EdgeInsets.only(right: 10), - child: Container( - width: 0.5, - height: 24, - color: TDTheme.of(context).grayColor3, - ), - ), - controller.countdownSeconds.value > 0 ? - TDText('${controller.countdownSeconds.value}秒后重试', textColor: TDTheme.of(context).fontGyColor4) - : TDText('获取验证码', textColor: Color(0xFF7562F9)), + ), + Column( + children: [ + Spacer(), + Container( + height: 320.h, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, // 0%:左边开始 + end: Alignment.bottomCenter, // 100%:右边结束 + colors: [ + Color.fromRGBO(204, 204, 204, 0),// 右侧深蓝 + Color.fromRGBO(176, 224, 137, 0.9), // 紫色 + Color.fromRGBO(176, 224, 137, 1), // 紫色 ], + stops: [0.0, 0.2, 1.0], // 对应 CSS 百分比:0%、77.53%、100% ), ), - needClear: false, - onBtnTap: () { - controller.getVerificationCode(); - } - ), - SizedBox(height: 24), - // 协议同意复选框 - Row( - crossAxisAlignment: CrossAxisAlignment.center, // 垂直居中 - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox(width: 8), - Obx(() => Checkbox( - value: controller.agree.value, - onChanged: (value) { - controller.agree.value = value ?? false; - }, - activeColor: Color(0xff7562F9), - side: const BorderSide(color: Colors.grey), - shape: const CircleBorder(), - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - )), - Text('阅读并同意', style: TextStyle( fontSize: 14, color: Colors.black54 )), - Text( - '《趣招亲红娘代理协议》', - style: TextStyle( fontSize: 14, color: Color(0xFFEE811B) ) - ).onTap((){ - - }), - ], - ), - SizedBox(height: 32), - - TDButton( - text: '下一步', - width: MediaQuery.of(context).size.width - 40, - size: TDButtonSize.large, - type: TDButtonType.fill, - shape: TDButtonShape.round, - style: TDButtonStyle( - textColor: Colors.white, - backgroundColor: Color(0xFF7562F9), - ), - activeStyle: TDButtonStyle( - textColor: Colors.white, - backgroundColor: Color(0xC37562F9), + ) + ], + ), + Obx(() { + return Padding( + padding: EdgeInsets.all(12.0), + child: Column( + children: [ + Spacer(), + Container( + height: 60.h, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.centerLeft, // 0%:左边开始 + end: Alignment.centerRight, // 100%:右边结束 + colors: [ + Color.fromRGBO(251, 74, 32, 1), // 紫色 + Color.fromRGBO(242, 253, 159, 1),// 右侧深蓝 + ] + ), + borderRadius: BorderRadius.only(topLeft: Radius.circular(12.0), topRight: Radius.circular(12.0), bottomLeft: Radius.circular(0), bottomRight: Radius.circular(0)), + ), + padding: EdgeInsets.only(bottom: 12), + child: Align( + alignment: Alignment.center, // 居中 + child: Text( + '申请${controller.genderCode.value == 0 ? '红娘' : '红娘'}', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold,color: Colors.white), + ), + ), + ), + Transform.translate( + offset: Offset(0, -12), // Y轴上移12像素 + child: Container( + height: 272.h, + // width: MediaQuery.of(context).size.width - 24, + padding: EdgeInsets.only(top: 24, bottom: 24, left: 16, right: 16), + decoration: BoxDecoration( + color: Colors.white, // 背景色 + borderRadius: BorderRadius.circular(12), // 圆角 + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + children: [ + TDTag('你已申请', style: TDTagStyle(borderRadius: BorderRadius.circular(6), backgroundColor: Color.fromRGBO(251, 76, 33, 1))), + SizedBox(width: 4), + TDText('累计连麦时长${controller.hours.value}小时即可申请红娘', style: TextStyle(fontSize: 16.w, fontWeight: FontWeight.bold)) + ], + ), + SizedBox(height: 24), + Row( + children: [ + SizedBox(width: 24), + TDText('我已累计连麦:', style: TextStyle(fontSize: 16)), + Spacer(), + Row( + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment, + children: [ + TDText('${controller.consumption.value.liveDurationMins}', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: Color.fromRGBO(251, 78, 35, 1))), + SizedBox(width: 4), + Padding( + padding: EdgeInsets.only(top: 4), + child: TDText('分钟', style: TextStyle(fontSize: 12)), + ), + ], + ), + SizedBox(width: 24), + ], + ), + Spacer(), + TDButton( + text: controller.canApply.value ? '去申请' : '去相亲', + textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white), + width: MediaQuery.of(context).size.width - 100, + size: TDButtonSize.large, + type: TDButtonType.fill, + shape: TDButtonShape.round, + gradient: LinearGradient(colors: [Color.fromRGBO(255, 85, 78, 1), Color.fromRGBO(254, 147, 72, 1)]), + onTap: (){ + controller.applyMatcher(); + }, + ) + ], + ), + ), + ), + ], ), - onTap: (){ - controller.submitInfo(); - }, - ), - ], - ), + ); + }), + ], + ), ); } diff --git a/lib/pages/setting/match_spread_page.dart b/lib/pages/setting/match_spread_page.dart index 6b3713e..d3b1022 100644 --- a/lib/pages/setting/match_spread_page.dart +++ b/lib/pages/setting/match_spread_page.dart @@ -1,7 +1,9 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:dating_touchme_app/components/page_appbar.dart'; +import 'package:dating_touchme_app/controller/global.dart'; import 'package:dating_touchme_app/extension/ex_widget.dart'; import 'package:dating_touchme_app/generated/assets.dart'; -import 'package:dating_touchme_app/model/mine/rose_data.dart'; +import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -17,6 +19,7 @@ class MatchSpreadPage extends StatelessWidget { return GetX( init: SpreadController(), builder: (controller){ + controller.userData.value = GlobalData().userData; return Container( decoration: BoxDecoration( gradient: LinearGradient( @@ -31,71 +34,174 @@ class MatchSpreadPage extends StatelessWidget { stops: [0.0, 0.32, 0.66, 1.0], // 对应 CSS 百分比:0%、77.53%、100% ), ), - child: controller.roseList.isNotEmpty ? Scaffold( + child: Scaffold( backgroundColor: Colors.transparent, appBar: PageAppbar(title: "入驻加盟", backgroundColor: Colors.transparent, color: Colors.white, iconColor: Colors.white), - body: SingleChildScrollView( - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(18.w)), - color: Colors.white - ), - padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 12.w), - margin: EdgeInsets.symmetric(vertical: 10.w, horizontal: 12.w), - child: Column( - children: [ - SizedBox(height: 6.w,), - Row( + body: controller.loading.value ? Center( + child: TDLoading( + size: TDLoadingSize.medium, + icon: TDLoadingIcon.activity, + text: '加载中…', + axis: Axis.vertical, + duration: 500, + ) + ) : SingleChildScrollView( + child: Column( + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 12.w), + child: Row( children: [ - Text( - "趣恋恋,让婚恋服务更高效", - style: TextStyle( - fontSize: 16.w, - fontWeight: FontWeight.w500 - ), + ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(80.w)), + child: (controller.userData.value?.profilePhoto?.isNotEmpty ?? false) ? CachedNetworkImage( + imageUrl: "${controller.userData.value?.profilePhoto ?? ""}?x-oss-process=image/format,webp/resize,w_120", + width: 80.w, + height: 80.w, + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + ) : Image.asset( + Assets.imagesUserAvatar, + width: 80.w, + height: 80.w, + ) + ), + SizedBox(width: 16.w,), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ConstrainedBox( + constraints: BoxConstraints( maxWidth: 120.w), + child: Text( + "${controller.userData.value?.nickName ?? ""}", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 24.w, + color: Colors.white, + fontWeight: FontWeight.w700 + ), + ), + ), + Text( + "ID:${controller.userId.value ?? ""}", + style: TextStyle( + fontSize: 16.w, + color: Colors.white, + fontWeight: FontWeight.w500 + ), + ) + ], ) ], ), - SizedBox(height: 15.w,), - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: [ - ...controller.roseList.asMap().entries.map((entry){ - return PayItem(item: entry.value, active: controller.activePay.value, index: entry.key, changeActive: controller.changePayActive); - }), - ], - ), - ), - SizedBox(height: 24.w), - Row( - mainAxisAlignment: MainAxisAlignment.center, + ), + SizedBox(width: 12.w,), + Container( + padding: EdgeInsets.only(top: 8.w, bottom: 10.w, left: 24.w, right: 24.w), + child: Row( children: [ - Text( - "新红娘入驻权益", - style: TextStyle( - fontSize: 22.w, - color: const Color.fromRGBO(48, 48, 48, 1), - fontWeight: FontWeight.w500 + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + children: [ + Image.asset(Assets.imagesRoseWhite, width: 8.w, height: 15.w), + const SizedBox(width: 4), + Text('已消费玫瑰', style: TextStyle(fontSize: 14.w, color: Colors.white)), + ], + ), + SizedBox(height: 4,), + Row( + children: [ + SizedBox(width: 12,), + Text( + "${controller.consumption.value.liveConsumptionAmount}", + style: TextStyle( + fontSize: 30.w, + color: Colors.white, + fontWeight: FontWeight.bold + ), + ), + ], + ), + ], + ), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + children: [ + Image.asset('assets/images/timer.png', width: 15.w, height: 15.w), + const SizedBox(width: 4), + Text('已连麦时间(分钟)', style: TextStyle(fontSize: 14.w, color: Colors.white)), + ], + ), + SizedBox(height: 4,), + Row( + children: [ + SizedBox(width: 12,), + Text( + "${controller.consumption.value.liveDurationMins}", + style: TextStyle( + fontSize: 30.w, + color: Colors.white, + fontWeight: FontWeight.bold + ), + ), + ], + ), + ], ), ), - SizedBox(width: 4.w,), - Image.asset( - Assets.imagesLimitTime, - width: 30.w, - height: 16.w, - ) ], ), - SizedBox(height: 16.w,), - ...controller.revenue.map((entry){ - return RevenueItem(item: entry); - }), - ], - ), - ), + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(18.w)), + color: Colors.white + ), + padding: EdgeInsets.symmetric(vertical: 12.w, horizontal: 16.w), + margin: EdgeInsets.symmetric(vertical: 10.w, horizontal: 12.w), + child: Column( + children: [ + SizedBox(height: 12.w,), + ...controller.roseList.asMap().entries.map((entry){ + return PayItem(item: entry.value, active: controller.activePay.value, index: entry.key, changeActive: controller.changePayActive); + }), + Row( + children: [ + SizedBox(width: 4.w), + Container( + width: 6, + height: 6, + decoration: BoxDecoration( + color: Color(0xFF999999), // 圆点颜色 + shape: BoxShape.circle, // 圆形 + ), + ), + SizedBox(width: 4.w), + Text('仅限直播间相亲消费和连麦', style: TextStyle(fontSize: 12.w, color: Color(0xFF999999))), + ], + ), + SizedBox(height: 12.w), + ], + ), + ) + ], + ) ), - bottomNavigationBar: SafeArea( + bottomNavigationBar: controller.roseList.isNotEmpty ? SafeArea( child: Container( height: 60, padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 20.w), @@ -105,6 +211,7 @@ class MatchSpreadPage extends StatelessWidget { size: TDButtonSize.large, type: TDButtonType.fill, shape: TDButtonShape.round, + disabled: !controller.canApply.value, style: TDButtonStyle( textColor: Colors.white, backgroundColor: Color(0xFF7562F9), @@ -113,13 +220,17 @@ class MatchSpreadPage extends StatelessWidget { textColor: Colors.white, backgroundColor: Color(0xC37562F9), ), + disableStyle: TDButtonStyle( + textColor: Colors.white, + backgroundColor: Color(0xFFAAAAAA), + ), onTap: (){ controller.submitOrder(); }, ), ) - ), - ) : null, + ) : null, + ), ); }, ); @@ -128,7 +239,7 @@ class MatchSpreadPage extends StatelessWidget { class PayItem extends StatefulWidget { - final RoseData item; + final MatchmakerRequirement item; final int active; final int index; final void Function(int) changeActive; @@ -144,69 +255,48 @@ class _PayItemState extends State { return Stack( children: [ Container( - width: 124.w, - height: 160.h, - margin: const EdgeInsets.only(right: 10), + // width: 124.w, + height: 108.h, + margin: EdgeInsets.only(bottom: 12.w), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(18.w)), color: Colors.white, border: widget.active == widget.index ? Border.all(width: 1, color: const Color(0xFF7562F9)) : Border.all(width: 1, color: const Color(0xFFEEEEEE)) ), child: Column( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - SizedBox(height: 40.h), + SizedBox(height: 20.h), + TDText(widget.item.liveConsumptionAmount! > 0 ? '累计消费' : '累计连麦相亲', style: TextStyle(color: Color(0xFF999999))), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.end, children: [ + Text( + widget.item.liveConsumptionAmount! > 0 ? "${widget.item.liveConsumptionAmount}" : "${widget.item.liveDurationHours}", + style: TextStyle( + fontSize: 30.w, + color: Color.fromRGBO(251, 78, 35, 1), + fontWeight: FontWeight.bold + ), + ), + const SizedBox(width: 2), Container( - padding: EdgeInsets.only(bottom: 5), + padding: EdgeInsets.only(bottom: 8.h), child: Text( - "¥", + widget.item.liveConsumptionAmount! > 0 ? '朵玫瑰' : '小时', style: TextStyle( fontSize: 16.w, - color: Color(0xFF7562F9), + color: Color.fromRGBO(251, 78, 35, 1), fontWeight: FontWeight.bold ), ), ), - const SizedBox(width: 2), - Text( - "${widget.item.unitSellingPrice}", - style: TextStyle( - fontSize: 26.w, - color: Color(0xFF7562F9), - fontWeight: FontWeight.bold - ), - ), ], ), - TDText("¥${widget.item.unitOriginalPrice}", isTextThrough: true, style: TextStyle(color: Color(0xFFCCCCCC)),), - Spacer(), - SizedBox( - height: 36.h, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - widget.item.validityPeriodDays != null ? Text( - "有效期:${widget.item.validityPeriodDays}天", - style: TextStyle( - fontSize: 14.w, - color: Color(0xFF333333), - fontWeight: FontWeight.bold - ), - ) : Text('+${widget.item.liveDurationHours ?? '10'}小时视频相亲', - style: TextStyle( - fontSize: 12.w, - color: Color(0xFF999999), - fontWeight: FontWeight.bold - ), - ) - ], - ), - ), + // TDText("¥${widget.item.unitOriginalPrice}", isTextThrough: true, style: TextStyle(color: Color(0xFFCCCCCC)),), + Spacer() ], ), ), @@ -223,7 +313,7 @@ class _PayItemState extends State { color: widget.active == widget.index ? const Color(0xFF7562F9) : Color(0xFFCCCCCC) ), child: Center( - child: Text(widget.item.productTitle!.replaceAll('加盟费', ''), style: TextStyle(fontSize: 12, color: Colors.white)), + child: Text(_getNameByType(widget.item.type!), style: TextStyle(fontSize: 12, color: Colors.white)), ), ), ) @@ -232,6 +322,20 @@ class _PayItemState extends State { widget.changeActive(widget.index); }); } + + String _getNameByType(int type) { + if(type == 1){ + return '实习红娘'; + } + if(type == 2){ + return '线上红娘'; + } + if(type == 3){ + return '签约红娘'; + } + return '实习红娘'; // 直播显示直播间按钮(放在HI位置) + } + } diff --git a/lib/pages/setting/match_task_page.dart b/lib/pages/setting/match_task_page.dart index 851ab2a..d2fbb45 100644 --- a/lib/pages/setting/match_task_page.dart +++ b/lib/pages/setting/match_task_page.dart @@ -1,9 +1,6 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:dating_touchme_app/components/page_appbar.dart'; import 'package:dating_touchme_app/controller/global.dart'; import 'package:dating_touchme_app/controller/setting/task_controller.dart'; -import 'package:dating_touchme_app/extension/ex_widget.dart'; -import 'package:dating_touchme_app/generated/assets.dart'; import 'package:dating_touchme_app/model/mine/matchmaker_requirement_data.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -18,171 +15,80 @@ class MatchTaskPage extends StatelessWidget { return GetX( init: TaskController(), builder: (controller){ - controller.userData.value = GlobalData().userData; - return Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topLeft, // 0%:左边开始 - end: Alignment.bottomCenter, // 100%:右边结束 - colors: [ - Color.fromRGBO(172, 89, 255, 1), // 紫色 - Color.fromRGBO(117, 98, 249, 1), // 中间淡蓝 - Color.fromRGBO(255, 255, 255, 1), - Color.fromRGBO(255, 255, 255, 1),// 右侧深蓝 - ], - stops: [0.0, 0.32, 0.66, 1.0], // 对应 CSS 百分比:0%、77.53%、100% - ), - ), - child: controller.roseList.isNotEmpty ? Scaffold( - backgroundColor: Colors.transparent, - appBar: PageAppbar(title: "入驻加盟", backgroundColor: Colors.transparent, color: Colors.white, iconColor: Colors.white), - body: SingleChildScrollView( + return Scaffold( + appBar: PageAppbar(title: "红娘任务"), + body: controller.loading.value ? Center( + child: TDLoading( + size: TDLoadingSize.medium, + icon: TDLoadingIcon.activity, + text: '加载中…', + axis: Axis.vertical, + duration: 500, + ) + ) : SingleChildScrollView( child: Column( children: [ Container( - padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 12.w), - child: Row( + padding: EdgeInsets.symmetric(vertical: 12.w, horizontal: 18.w), + child: Column( children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(80.w)), - child: (controller.userData.value?.profilePhoto?.isNotEmpty ?? false) ? CachedNetworkImage( - imageUrl: "${controller.userData.value?.profilePhoto ?? ""}?x-oss-process=image/format,webp/resize,w_120", - width: 80.w, - height: 80.w, - imageBuilder: (context, imageProvider) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, - fit: BoxFit.cover, - ), - ), - ), - ) : Image.asset( - Assets.imagesUserAvatar, - width: 80.w, - height: 80.w, - ) - ), - SizedBox(width: 16.w,), - Column( - crossAxisAlignment: CrossAxisAlignment.start, + Row( children: [ - ConstrainedBox( - constraints: BoxConstraints( maxWidth: 120.w), - child: Text( - "${controller.userData.value?.nickName ?? ""}", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 24.w, - color: Colors.white, - fontWeight: FontWeight.w700 - ), + TDText('日任务', style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)), + SizedBox(width: 4.w), + Container( + width: 4, + height: 4, + decoration: BoxDecoration( + color: Color(0xFF999999), // 圆点颜色 + shape: BoxShape.circle, // 圆形 ), ), - Text( - "ID:${controller.userId.value ?? ""}", - style: TextStyle( - fontSize: 16.w, - color: Colors.white, - fontWeight: FontWeight.w500 - ), - ) + SizedBox(width: 4.w), + TDText('任务时间:截止 23:25', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)), ], - ) - ], - ), - ), - SizedBox(width: 12.w,), - Container( - padding: EdgeInsets.only(top: 8.w, bottom: 10.w, left: 24.w, right: 24.w), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - children: [ - Image.asset(Assets.imagesRoseWhite, width: 8.w, height: 15.w), - const SizedBox(width: 4), - Text('已消费玫瑰', style: TextStyle(fontSize: 14.w, color: Colors.white)), - ], - ), - SizedBox(height: 4,), - Row( - children: [ - SizedBox(width: 12,), - Text( - "${controller.consumption.value.liveConsumptionAmount}", - style: TextStyle( - fontSize: 30.w, - color: Colors.white, - fontWeight: FontWeight.bold - ), - ), - ], - ), - ], - ), ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - children: [ - Image.asset('assets/images/timer.png', width: 15.w, height: 15.w), - const SizedBox(width: 4), - Text('已连麦时间(分钟)', style: TextStyle(fontSize: 14.w, color: Colors.white)), - ], - ), - SizedBox(height: 4,), - Row( - children: [ - SizedBox(width: 12,), - Text( - "${controller.consumption.value.liveDurationMins}", - style: TextStyle( - fontSize: 30.w, - color: Colors.white, - fontWeight: FontWeight.bold - ), - ), - ], - ), - ], - ), - ), - ], - ), - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(18.w)), - color: Colors.white - ), - padding: EdgeInsets.symmetric(vertical: 12.w, horizontal: 16.w), - margin: EdgeInsets.symmetric(vertical: 10.w, horizontal: 12.w), - child: Column( - children: [ SizedBox(height: 12.w,), ...controller.roseList.asMap().entries.map((entry){ - return PayItem(item: entry.value, active: controller.activePay.value, index: entry.key, changeActive: controller.changePayActive); + return TaskItem(item: entry.value); }), + SizedBox(height: 24.w,), Row( children: [ + TDText('月任务', style: TextStyle(color: Color(0xFF333333), fontWeight: FontWeight.bold, fontSize: 16.w)), SizedBox(width: 4.w), Container( - width: 6, - height: 6, + width: 4, + height: 4, decoration: BoxDecoration( color: Color(0xFF999999), // 圆点颜色 shape: BoxShape.circle, // 圆形 ), ), SizedBox(width: 4.w), - Text('仅限直播间相亲消费和连麦', style: TextStyle(fontSize: 12.w, color: Color(0xFF999999))), + TDText('任务时间:截止 03/15 23:59', style: TextStyle(color: Color(0xFF666666), fontSize: 16.w)), + ], + ), + SizedBox(height: 12.w,), + ...controller.roseList.asMap().entries.map((entry){ + return TaskItem(item: entry.value); + }), + SizedBox(height: 12.w,), + Row( + children: [ + TDText('注意事项', style: TextStyle(color: Color(0xFF333333), fontSize: 16.w)), + ], + ), + SizedBox(height: 4.w,), + Row( + children: [ + Text('1.月任务未通过将受到惩罚;', style: TextStyle(fontSize: 12.w, color: Color(0xFF999999))), + ], + ), + SizedBox(height: 4.w,), + Row( + children: [ + Text('2.任务开始时间为成为红娘的那一刻起;', style: TextStyle(fontSize: 12.w, color: Color(0xFF999999))), ], ), SizedBox(height: 12.w), @@ -191,196 +97,37 @@ class MatchTaskPage extends StatelessWidget { ) ], ) - ), - bottomNavigationBar: SafeArea( - child: Container( - height: 60, - padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 20.w), - child: TDButton( - text: controller.button.value, - width: MediaQuery.of(context).size.width - 40, - size: TDButtonSize.large, - type: TDButtonType.fill, - shape: TDButtonShape.round, - disabled: !controller.canApply.value, - style: TDButtonStyle( - textColor: Colors.white, - backgroundColor: Color(0xFF7562F9), - ), - activeStyle: TDButtonStyle( - textColor: Colors.white, - backgroundColor: Color(0xC37562F9), - ), - disableStyle: TDButtonStyle( - textColor: Colors.white, - backgroundColor: Color(0xFFAAAAAA), - ), - onTap: (){ - controller.submitOrder(); - }, - ), - ) - ), - ) : null, + ) ); }, ); } } - -class PayItem extends StatefulWidget { +class TaskItem extends StatelessWidget { final MatchmakerRequirement item; - final int active; - final int index; - final void Function(int) changeActive; - const PayItem({super.key, required this.item, required this.active, required this.index, required this.changeActive, }); - - @override - State createState() => _PayItemState(); -} - -class _PayItemState extends State { - @override - Widget build(BuildContext context) { - return Stack( - children: [ - Container( - // width: 124.w, - height: 108.h, - margin: EdgeInsets.only(bottom: 12.w), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(18.w)), - color: Colors.white, - border: widget.active == widget.index ? Border.all(width: 1, color: const Color(0xFF7562F9)) : Border.all(width: 1, color: const Color(0xFFEEEEEE)) - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(height: 20.h), - TDText(widget.item.liveConsumptionAmount! > 0 ? '累计消费' : '累计连麦相亲', style: TextStyle(color: Color(0xFF999999))), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - widget.item.liveConsumptionAmount! > 0 ? "${widget.item.liveConsumptionAmount}" : "${widget.item.liveDurationHours}", - style: TextStyle( - fontSize: 30.w, - color: Color.fromRGBO(251, 78, 35, 1), - fontWeight: FontWeight.bold - ), - ), - const SizedBox(width: 2), - Container( - padding: EdgeInsets.only(bottom: 8.h), - child: Text( - widget.item.liveConsumptionAmount! > 0 ? '朵玫瑰' : '小时', - style: TextStyle( - fontSize: 16.w, - color: Color.fromRGBO(251, 78, 35, 1), - fontWeight: FontWeight.bold - ), - ), - ), - ], - ), - // TDText("¥${widget.item.unitOriginalPrice}", isTextThrough: true, style: TextStyle(color: Color(0xFFCCCCCC)),), - Spacer() - ], - ), - ), - Positioned( - left: 0, - top: 0, - child: Container( - padding: EdgeInsets.symmetric(vertical: 4.w, horizontal: 12.w), - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(18.w), - bottomRight: Radius.circular(18.w), - ), - color: widget.active == widget.index ? const Color(0xFF7562F9) : Color(0xFFCCCCCC) - ), - child: Center( - child: Text(_getNameByType(widget.item.type!), style: TextStyle(fontSize: 12, color: Colors.white)), - ), - ), - ) - ], - ).onTap((){ - widget.changeActive(widget.index); - }); - } - - String _getNameByType(int type) { - if(type == 1){ - return '实习红娘'; - } - if(type == 2){ - return '线上红娘'; - } - if(type == 3){ - return '签约红娘'; - } - return '实习红娘'; // 直播显示直播间按钮(放在HI位置) - } - -} - - -class RevenueItem extends StatefulWidget { - final dynamic item; - const RevenueItem({super.key, required this.item}); - - @override - State createState() => _RevenueItemState(); -} - -class _RevenueItemState extends State { + const TaskItem({super.key, required this.item }); @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.all(17.w), - margin: EdgeInsets.only(bottom: 8.w), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(16.w)), - color: const Color.fromRGBO(117, 98, 249, .1) - ), - child: Row( + margin: EdgeInsets.only(bottom: 12.w, left: 8.w, top: 8.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - _getButtonImage(widget.item['icon']), - width: 26.w, - height: 26.w, + TDText(item.liveConsumptionAmount! > 0 ? '累计消费' : '累计连麦相亲', style: TextStyle(color: Color(0xFF333333), fontSize: 16.w)), + SizedBox(height: 4.w), + TDProgress( + type: TDProgressType.linear, + value: 0.5, + strokeWidth: 6, + progressLabelPosition: TDProgressLabelPosition.right, + color: Color(0xFF7562F9), ), - SizedBox(width: 14.w,), - Expanded( - child: Text( - widget.item['desc'], - style: TextStyle( - fontSize: 12.w, - color: Color(0xFF999999) - ), - ), - ) + SizedBox(height: 2.w), + TDText('目前有效金额:22.66元', style: TextStyle(color: Color(0xFF999999), fontSize: 12.w)), ], ), ); } - - String _getButtonImage(String icon) { - if(icon == '1'){ - return Assets.imagesMatchmakerIcon1; - } - if(icon == '2'){ - return Assets.imagesMatchmakerIcon2; - } - if(icon == '3'){ - return Assets.imagesMatchmakerIcon3; - } - return Assets.imagesMatchmakerIcon4; // 直播显示直播间按钮(放在HI位置) - } -} \ No newline at end of file +}