9 changed files with 302 additions and 47 deletions
Unified View
Diff Options
-
32lib/controller/discover/room_controller.dart
-
10lib/controller/mine/auth_controller.dart
-
112lib/controller/mine/league_controller.dart
-
1lib/controller/mine/mine_controller.dart
-
57lib/pages/discover/discover_page.dart
-
4lib/pages/mine/auth_center_page.dart
-
5lib/pages/mine/real_name_page.dart
-
118lib/pages/setting/match_league_page.dart
-
10lib/widget/live/live_room_notice_chat_panel.dart
@ -0,0 +1,112 @@ |
|||||
|
import 'dart:async'; |
||||
|
import 'package:get/get.dart'; |
||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
|
import '../../network/user_api.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; |
||||
|
|
||||
|
@override |
||||
|
void onInit() { |
||||
|
super.onInit(); |
||||
|
// 从全局依赖中获取UserApi |
||||
|
_userApi = Get.find<UserApi>(); |
||||
|
phone.value = GlobalData().userData!.phone!; |
||||
|
} |
||||
|
|
||||
|
// 获取验证码 |
||||
|
Future<void> 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; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 开始倒计时 |
||||
|
void startCountdown() { |
||||
|
Future.delayed(const Duration(seconds: 1), () { |
||||
|
if (countdownSeconds.value > 0) { |
||||
|
countdownSeconds.value--; |
||||
|
startCountdown(); |
||||
|
} else { |
||||
|
isSendingCode.value = false; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
Future<void> changePhone() 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) { |
||||
|
GlobalData().userData!.phone = phoneNumber.value; |
||||
|
SmartDialog.showToast('更换成功'); |
||||
|
Get.back(result: 1); |
||||
|
} else { |
||||
|
SmartDialog.showToast(response.data.message); |
||||
|
} |
||||
|
} catch (e) { |
||||
|
SmartDialog.showToast('网络请求失败,请检查网络连接'); |
||||
|
} finally { |
||||
|
SmartDialog.dismiss(); |
||||
|
isSendingCode.value = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
@ -0,0 +1,118 @@ |
|||||
|
import 'package:dating_touchme_app/extension/ex_widget.dart'; |
||||
|
import 'package:flutter/cupertino.dart'; |
||||
|
import 'package:flutter/material.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 { |
||||
|
MatchLeaguePage({super.key}); |
||||
|
final LeagueController controller = Get.put(LeagueController()); |
||||
|
// 是否同意协议 |
||||
|
@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) { |
||||
|
} |
||||
|
), |
||||
|
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)), |
||||
|
], |
||||
|
), |
||||
|
), |
||||
|
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), |
||||
|
), |
||||
|
onTap: (){ |
||||
|
// controller.startAuthing(); |
||||
|
}, |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save