18 changed files with 927 additions and 158 deletions
Unified View
Diff Options
-
BINassets/images/btn_bg_icon.png
-
BINassets/images/hi_icon.png
-
BINassets/images/live_icon.png
-
BINassets/images/online_icon.png
-
BINassets/images/send_message_icon.png
-
BINassets/images/tab_change_icon.png
-
BINassets/images/verified_icon.png
-
43ios/Podfile
-
65ios/Podfile.lock
-
18ios/Runner.xcodeproj/project.pbxproj
-
78lib/controller/mine/user_info_controller.dart
-
7lib/generated/assets.dart
-
2lib/main.dart
-
398lib/pages/home/home_page.dart
-
2lib/pages/main/main_page.dart
-
174lib/pages/mine/login_controller.dart
-
18lib/pages/mine/user_info_page.dart
-
280pubspec.lock
@ -0,0 +1,43 @@ |
|||||
|
# Uncomment this line to define a global platform for your project |
||||
|
# platform :ios, '13.0' |
||||
|
|
||||
|
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. |
||||
|
ENV['COCOAPODS_DISABLE_STATS'] = 'true' |
||||
|
|
||||
|
project 'Runner', { |
||||
|
'Debug' => :debug, |
||||
|
'Profile' => :release, |
||||
|
'Release' => :release, |
||||
|
} |
||||
|
|
||||
|
def flutter_root |
||||
|
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) |
||||
|
unless File.exist?(generated_xcode_build_settings_path) |
||||
|
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" |
||||
|
end |
||||
|
|
||||
|
File.foreach(generated_xcode_build_settings_path) do |line| |
||||
|
matches = line.match(/FLUTTER_ROOT\=(.*)/) |
||||
|
return matches[1].strip if matches |
||||
|
end |
||||
|
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" |
||||
|
end |
||||
|
|
||||
|
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) |
||||
|
|
||||
|
flutter_ios_podfile_setup |
||||
|
|
||||
|
target 'Runner' do |
||||
|
use_frameworks! |
||||
|
|
||||
|
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) |
||||
|
target 'RunnerTests' do |
||||
|
inherit! :search_paths |
||||
|
end |
||||
|
end |
||||
|
|
||||
|
post_install do |installer| |
||||
|
installer.pods_project.targets.each do |target| |
||||
|
flutter_additional_ios_build_settings(target) |
||||
|
end |
||||
|
end |
||||
@ -0,0 +1,65 @@ |
|||||
|
PODS: |
||||
|
- AgoraInfra_iOS (1.2.13.1) |
||||
|
- Flutter (1.0.0) |
||||
|
- flutter_native_splash (2.4.3): |
||||
|
- Flutter |
||||
|
- HyphenateChat (4.15.0): |
||||
|
- AgoraInfra_iOS (~> 1.2.13) |
||||
|
- im_flutter_sdk_ios (4.14.0): |
||||
|
- Flutter |
||||
|
- HyphenateChat (= 4.15.0) |
||||
|
- image_picker_ios (0.0.1): |
||||
|
- Flutter |
||||
|
- path_provider_foundation (0.0.1): |
||||
|
- Flutter |
||||
|
- FlutterMacOS |
||||
|
- permission_handler_apple (9.3.0): |
||||
|
- Flutter |
||||
|
- shared_preferences_foundation (0.0.1): |
||||
|
- Flutter |
||||
|
- FlutterMacOS |
||||
|
|
||||
|
DEPENDENCIES: |
||||
|
- Flutter (from `Flutter`) |
||||
|
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) |
||||
|
- im_flutter_sdk_ios (from `.symlinks/plugins/im_flutter_sdk_ios/ios`) |
||||
|
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) |
||||
|
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) |
||||
|
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) |
||||
|
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) |
||||
|
|
||||
|
SPEC REPOS: |
||||
|
trunk: |
||||
|
- AgoraInfra_iOS |
||||
|
- HyphenateChat |
||||
|
|
||||
|
EXTERNAL SOURCES: |
||||
|
Flutter: |
||||
|
:path: Flutter |
||||
|
flutter_native_splash: |
||||
|
:path: ".symlinks/plugins/flutter_native_splash/ios" |
||||
|
im_flutter_sdk_ios: |
||||
|
:path: ".symlinks/plugins/im_flutter_sdk_ios/ios" |
||||
|
image_picker_ios: |
||||
|
:path: ".symlinks/plugins/image_picker_ios/ios" |
||||
|
path_provider_foundation: |
||||
|
:path: ".symlinks/plugins/path_provider_foundation/darwin" |
||||
|
permission_handler_apple: |
||||
|
:path: ".symlinks/plugins/permission_handler_apple/ios" |
||||
|
shared_preferences_foundation: |
||||
|
:path: ".symlinks/plugins/shared_preferences_foundation/darwin" |
||||
|
|
||||
|
SPEC CHECKSUMS: |
||||
|
AgoraInfra_iOS: 3691b2b277a1712a35ae96de25af319de0d73d08 |
||||
|
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 |
||||
|
flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29 |
||||
|
HyphenateChat: 4523c7fb2075771c49a2c492b31544d6cc82ff50 |
||||
|
im_flutter_sdk_ios: 2348d34baa17e98d8c490d92023410956c8afee1 |
||||
|
image_picker_ios: 4f2f91b01abdb52842a8e277617df877e40f905b |
||||
|
path_provider_foundation: 0b743cbb62d8e47eab856f09262bb8c1ddcfe6ba |
||||
|
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 |
||||
|
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6 |
||||
|
|
||||
|
PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e |
||||
|
|
||||
|
COCOAPODS: 1.16.2 |
||||
@ -0,0 +1,174 @@ |
|||||
|
import 'dart:async'; |
||||
|
import 'package:dating_touchme_app/pages/main/main_page.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
import 'package:get_storage/get_storage.dart'; |
||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
|
import 'package:dating_touchme_app/network/user_api.dart'; |
||||
|
import 'package:dating_touchme_app/pages/mine/user_info_page.dart'; |
||||
|
|
||||
|
|
||||
|
class LoginController extends GetxController { |
||||
|
// 手机号输入 |
||||
|
final phoneNumber = ''.obs; |
||||
|
// 验证码输入 |
||||
|
final verificationCode = ''.obs; |
||||
|
// 是否正在发送验证码 |
||||
|
final isSendingCode = false.obs; |
||||
|
// 倒计时秒数 |
||||
|
final countdownSeconds = 0.obs; |
||||
|
// 是否正在登录中 |
||||
|
final isLoggingIn = false.obs; |
||||
|
|
||||
|
// 从GetX依赖注入中获取UserApi实例 |
||||
|
late UserApi _userApi; |
||||
|
// GetStorage实例,用于存储token等信息 |
||||
|
final storage = GetStorage(); |
||||
|
|
||||
|
@override |
||||
|
void onInit() { |
||||
|
super.onInit(); |
||||
|
// 从全局依赖中获取UserApi |
||||
|
_userApi = Get.find<UserApi>(); |
||||
|
} |
||||
|
|
||||
|
// 获取验证码 |
||||
|
Future<void> getVerificationCode() async { |
||||
|
// 验证手机号格式 |
||||
|
if (phoneNumber.value.isEmpty || phoneNumber.value.length != 11) { |
||||
|
SmartDialog.showToast('请输入正确的手机号'); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
isSendingCode.value = true; |
||||
|
|
||||
|
try { |
||||
|
// 构建请求参数 |
||||
|
final params = { |
||||
|
'purpose': 1, // 认证 |
||||
|
'verifiableAccount': phoneNumber.value, |
||||
|
'verifiableAccountType': 1, // 手机 |
||||
|
}; |
||||
|
|
||||
|
// 调用UserApi中的验证码接口 |
||||
|
final response = await _userApi.getVerificationCode(params); |
||||
|
|
||||
|
// 处理响应 |
||||
|
if (response.data.isSuccess) { |
||||
|
// 生产环境移除打印,可考虑使用正式的日志框架 |
||||
|
// print('验证码发送成功'); |
||||
|
// 开始倒计时 |
||||
|
startCountdown(); |
||||
|
} else { |
||||
|
SmartDialog.showToast(response.data.message); |
||||
|
} |
||||
|
} catch (e) { |
||||
|
SmartDialog.showToast('网络请求失败,请重试'); |
||||
|
} finally { |
||||
|
isSendingCode.value = false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 开始倒计时 |
||||
|
void startCountdown() { |
||||
|
countdownSeconds.value = 60; |
||||
|
Timer.periodic(const Duration(seconds: 1), (timer) { |
||||
|
countdownSeconds.value--; |
||||
|
if (countdownSeconds.value <= 0) { |
||||
|
timer.cancel(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// 清除错误信息 - 由于使用SmartDialog,此方法不再需要 |
||||
|
// void clearErrorMessage() {} |
||||
|
|
||||
|
|
||||
|
// 登录方法 |
||||
|
Future<void> login() async { |
||||
|
// 验证输入 |
||||
|
if (phoneNumber.value.isEmpty || phoneNumber.value.length != 11) { |
||||
|
SmartDialog.showToast('请输入正确的手机号'); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (verificationCode.value.isEmpty) { |
||||
|
SmartDialog.showToast('请输入验证码'); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
isLoggingIn.value = true; |
||||
|
|
||||
|
try { |
||||
|
// 构建登录请求参数 |
||||
|
final params = { |
||||
|
'account': phoneNumber.value, |
||||
|
'accountType': 2, // 手机号类型 |
||||
|
'captcha': verificationCode.value, |
||||
|
}; |
||||
|
|
||||
|
// 调用登录接口 |
||||
|
final response = await _userApi.login(params); |
||||
|
|
||||
|
// 处理响应 |
||||
|
if (response.data.isSuccess) { |
||||
|
// 保存token和用户信息 |
||||
|
if (response.data.data != null) { |
||||
|
final loginData = response.data.data!; |
||||
|
await storage.write('token', loginData.token); |
||||
|
await storage.write('userId', loginData.userId); |
||||
|
// 保存用户信息 |
||||
|
await storage.write('userInfo', loginData.toJson()); |
||||
|
|
||||
|
// 登录成功后获取用户基础信息 |
||||
|
await _getBaseUserInfo(loginData.userId); |
||||
|
} |
||||
|
} else { |
||||
|
SmartDialog.showToast(response.data.message); |
||||
|
} |
||||
|
} catch (e) { |
||||
|
SmartDialog.showToast('网络请求失败,请检查网络连接'); |
||||
|
} finally { |
||||
|
isLoggingIn.value = false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 获取用户基础信息 |
||||
|
Future<void> _getBaseUserInfo(String userId) async { |
||||
|
try { |
||||
|
final response = await _userApi.getBaseUserInfo(userId); |
||||
|
|
||||
|
if (response.data.isSuccess && response.data.data != null) { |
||||
|
// 成功获取基础信息后,调用获取婚姻信息详情接口 |
||||
|
await _getMarriageInformationDetail(); |
||||
|
} else { |
||||
|
SmartDialog.showToast(response.data.message); |
||||
|
} |
||||
|
} catch (e) { |
||||
|
// 获取用户信息失败不影响登录流程 |
||||
|
SmartDialog.showToast('获取用户信息失败'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 获取用户婚姻信息详情 |
||||
|
Future<void> _getMarriageInformationDetail() async { |
||||
|
try { |
||||
|
final response = await _userApi.getMarriageInformationDetail(); |
||||
|
if (response.data.isSuccess) { |
||||
|
// 检查data是否为null或者是空对象 |
||||
|
if(response.data.data == null){ |
||||
|
//跳转到完善信息 |
||||
|
SmartDialog.showToast('转到完善信息'); |
||||
|
// 导航到完善信息页面 |
||||
|
Get.offAll(() => UserInfoPage()); |
||||
|
}else{ |
||||
|
Get.offAll(MainPage()); |
||||
|
} |
||||
|
} else { |
||||
|
// 获取婚姻信息失败不影响登录流程 |
||||
|
} |
||||
|
} catch (e) { |
||||
|
// 获取婚姻信息失败不影响登录流程 |
||||
|
print('获取婚姻信息异常: $e'); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
280
pubspec.lock
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save