Browse Source

no message

ios
ZHR007 4 months ago
parent
commit
4ec040a086
6 changed files with 138 additions and 90 deletions
  1. 2
      lib/controller/mine/login_controller.dart
  2. 15
      lib/controller/mine/user_controller.dart
  3. 6
      lib/main.dart
  4. 2
      lib/network/api_urls.dart
  5. 2
      lib/network/user_api.g.dart
  6. 201
      lib/pages/mine/user_info_page.dart

2
lib/controller/mine/login_controller.dart

@ -115,7 +115,7 @@ class LoginController extends GetxController {
GlobalData().userId = result.userId; GlobalData().userId = result.userId;
GlobalData().qnToken = result.token; GlobalData().qnToken = result.token;
await storage.write('token', result.token); await storage.write('token', result.token);
await storage.write('userId', result.userId);
// await storage.write('userId', result.userId);
// //
await _handleUserInfoRetrieval(result.userId); await _handleUserInfoRetrieval(result.userId);

15
lib/controller/mine/user_controller.dart

@ -91,19 +91,18 @@ class UserController extends GetxController {
// print(result.data); // print(result.data);
if (result.data.isSuccess) { if (result.data.isSuccess) {
if(result.data.data == null){ if(result.data.data == null){
var information = UserData();
information.matchmakerFlag = baseInfo.matchmakerFlag;
information.realName = baseInfo.realName;
information.phone = baseInfo.phone;
GlobalData().userData = information;
if(isMain){ if(isMain){
SmartDialog.showToast('转到完善信息'); SmartDialog.showToast('转到完善信息');
Get.to(() => UserInfoPage()); Get.to(() => UserInfoPage());
} else { } else {
Get.offAll(() => UserInfoPage()); Get.offAll(() => UserInfoPage());
} }
var information = UserData();
information.matchmakerFlag = baseInfo.matchmakerFlag;
information.realName = baseInfo.realName;
information.phone = baseInfo.phone;
GlobalData().userData = information;
await storage.write('userId', GlobalData().userId);
// await storage.write('userId', GlobalData().userId);
return; return;
} }
final information = result.data.data!; final information = result.data.data!;
@ -112,7 +111,7 @@ class UserController extends GetxController {
information.phone = baseInfo.phone; information.phone = baseInfo.phone;
GlobalData().userData = information; GlobalData().userData = information;
await storage.write('userId', GlobalData().userId);
// await storage.write('userId', GlobalData().userId);
if (_checkInformation(information)) { if (_checkInformation(information)) {
// //
SmartDialog.showToast('转到完善信息'); SmartDialog.showToast('转到完善信息');

6
lib/main.dart

@ -85,11 +85,11 @@ class MyApp extends StatelessWidget {
// token是否为空 // token是否为空
final storage = GetStorage(); final storage = GetStorage();
final token = storage.read<String>('token');
final userId = storage.read<String>('userId');
// token不为空token为空 // token不为空token为空
if (token != null && token.isNotEmpty) {
GlobalData().userId = storage.read<String>('userId');
if (userId != null && userId.isNotEmpty) {
GlobalData().userId = userId;
return MainPage(); return MainPage();
} else { } else {
return LoginPage(); return LoginPage();

2
lib/network/api_urls.dart

@ -10,7 +10,7 @@ class ApiUrls {
static const String getBaseUserInfo = 'dating-agency-uec/user/get/base-info'; static const String getBaseUserInfo = 'dating-agency-uec/user/get/base-info';
static const String updatePhone = 'dating-agency-uec/user/modify/phone'; static const String updatePhone = 'dating-agency-uec/user/modify/phone';
static const String getMarriageInformationDetail = static const String getMarriageInformationDetail =
'dating-agency-service/user/get/dongwo/marriage-information-detail';
'dating-agency-service/user/get/dongwo/own-marriage-information-detail';
static const String registerMarriageInformation = static const String registerMarriageInformation =
'dating-agency-service/user/register/marriage-information'; 'dating-agency-service/user/register/marriage-information';
static const String getHxUserToken = static const String getHxUserToken =

2
lib/network/user_api.g.dart

@ -97,7 +97,7 @@ class _UserApi implements UserApi {
Options(method: 'GET', headers: _headers, extra: _extra) Options(method: 'GET', headers: _headers, extra: _extra)
.compose( .compose(
_dio.options, _dio.options,
'dating-agency-service/user/get/dongwo/marriage-information-detail',
'dating-agency-service/user/get/dongwo/own-marriage-information-detail',
queryParameters: queryParameters, queryParameters: queryParameters,
data: _data, data: _data,
) )

201
lib/pages/mine/user_info_page.dart

@ -1,4 +1,5 @@
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:dating_touchme_app/extension/ex_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:dating_touchme_app/generated/assets.dart'; import 'package:dating_touchme_app/generated/assets.dart';
@ -8,8 +9,15 @@ import 'package:get/get.dart';
import 'package:dating_touchme_app/controller/mine/user_info_controller.dart'; import 'package:dating_touchme_app/controller/mine/user_info_controller.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart'; import 'package:tdesign_flutter/tdesign_flutter.dart';
class UserInfoPage extends StatelessWidget {
UserInfoPage({super.key});
class UserInfoPage extends StatefulWidget {
const UserInfoPage({super.key});
@override
_UserInfoState createState() => _UserInfoState();
}
class _UserInfoState extends State<UserInfoPage> {
// //
void _showAvatarPopup(UserInfoController controller){ void _showAvatarPopup(UserInfoController controller){
Navigator.of(Get.context!).push( Navigator.of(Get.context!).push(
@ -76,7 +84,7 @@ class UserInfoPage extends StatelessWidget {
// //
Future _showEducationPicker(UserInfoController controller) async { Future _showEducationPicker(UserInfoController controller) async {
final List<String> educationOptions = ['大专以下', '大专', '本科', '硕士及以上']; final List<String> educationOptions = ['大专以下', '大专', '本科', '硕士及以上'];
await showModalBottomSheet( await showModalBottomSheet(
context: Get.context!, context: Get.context!,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
@ -88,53 +96,53 @@ class UserInfoPage extends StatelessWidget {
builder: (BuildContext context) { builder: (BuildContext context) {
return Container( return Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white, //
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
decoration: BoxDecoration(
color: Colors.white, //
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
//
Stack(
alignment: Alignment.center,
children: [
// -
Align(
alignment: Alignment.centerLeft,
child: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
Navigator.pop(context);
},
),
),
// -
Text(
'学历',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
],
),
//
Stack(
alignment: Alignment.center,
children: [
// -
Align(
alignment: Alignment.centerLeft,
child: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
Navigator.pop(context);
},
),
),
// -
Text(
'学历',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16), const SizedBox(height: 16),
// //
for (String education in educationOptions)
for (String education in educationOptions)
Container( Container(
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), // 106 margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), // 106
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: controller.education.value == education
? const Color.fromRGBO(123, 104, 238, 1) //
: const Color.fromRGBO(247, 247, 247, 1),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 25), //
minimumSize: const Size(double.infinity, 48), // 48
backgroundColor: controller.education.value == education
? const Color.fromRGBO(123, 104, 238, 1) //
: const Color.fromRGBO(247, 247, 247, 1),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 25), //
minimumSize: const Size(double.infinity, 48), // 48
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32), borderRadius: BorderRadius.circular(32),
), ),
@ -153,7 +161,7 @@ class UserInfoPage extends StatelessWidget {
), ),
), ),
), ),
// //
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
@ -169,7 +177,7 @@ class UserInfoPage extends StatelessWidget {
final now = DateTime.now(); final now = DateTime.now();
final maxDate = DateTime(now.year - 18); // 18 final maxDate = DateTime(now.year - 18); // 18
final minDate = DateTime(now.year - 80); // 80 final minDate = DateTime(now.year - 80); // 80
// 25 // 25
DateTime initialDate = DateTime(now.year - 25); DateTime initialDate = DateTime(now.year - 25);
if (controller.birthday.value.isNotEmpty) { if (controller.birthday.value.isNotEmpty) {
@ -189,10 +197,10 @@ class UserInfoPage extends StatelessWidget {
print('解析日期失败: $e'); print('解析日期失败: $e');
} }
} }
// //
DateTime? selectedDate = initialDate; DateTime? selectedDate = initialDate;
await showCupertinoModalPopup( await showCupertinoModalPopup(
context: Get.context!, context: Get.context!,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -251,6 +259,10 @@ class UserInfoPage extends StatelessWidget {
} }
final FocusNode _blankFocusNode = FocusNode(); final FocusNode _blankFocusNode = FocusNode();
final TextEditingController _controller = TextEditingController();
final FocusNode _blankFocusNode2 = FocusNode();
final TextEditingController _controller2 = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetX<UserInfoController>( return GetX<UserInfoController>(
@ -303,14 +315,14 @@ class UserInfoPage extends StatelessWidget {
), ),
child: ClipOval( child: ClipOval(
child: (controller.avatarUrl.value.startsWith('http') child: (controller.avatarUrl.value.startsWith('http')
? Image.network(
controller.avatarUrl.value,
fit: BoxFit.cover,
)
: Image.asset(
Assets.imagesAvatarsExample,
fit: BoxFit.cover,
)),
? Image.network(
controller.avatarUrl.value,
fit: BoxFit.cover,
)
: Image.asset(
Assets.imagesAvatarsExample,
fit: BoxFit.cover,
)),
), ),
), ),
Positioned( Positioned(
@ -341,7 +353,7 @@ class UserInfoPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 25), const SizedBox(height: 25),
// //
const Align( const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
@ -403,7 +415,7 @@ class UserInfoPage extends StatelessWidget {
], ],
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// //
const Align( const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
@ -427,14 +439,26 @@ class UserInfoPage extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
child: TextField( child: TextField(
controller: TextEditingController(text: controller.nickname.value),
focusNode: _blankFocusNode,
controller: _controller,
onChanged: (value) { onChanged: (value) {
controller.nickname.value = value; controller.nickname.value = value;
}, },
onTapOutside: (e){
_blankFocusNode.unfocus();
},
onTap: (){
//
WidgetsBinding.instance.addPostFrameCallback((_) {
_controller.selection = TextSelection.fromPosition(
TextPosition(offset: _controller.text.length),
);
});
},
decoration: const InputDecoration( decoration: const InputDecoration(
border: InputBorder.none, border: InputBorder.none,
hintText: '请输入昵称', hintText: '请输入昵称',
hintStyle: TextStyle(color: Colors.grey),
hintStyle: TextStyle(color: Colors.grey),
), ),
), ),
), ),
@ -442,7 +466,7 @@ class UserInfoPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// //
const Align( const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
@ -458,8 +482,9 @@ class UserInfoPage extends StatelessWidget {
const SizedBox(height: 10), const SizedBox(height: 10),
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
FocusScope.of(context).requestFocus(_blankFocusNode);
// FocusScope.of(context).requestFocus(_blankFocusNode);
// Cupertino日期选择器 // Cupertino日期选择器
// _blankFocusNode.unfocus();
await _showDatePicker(controller); await _showDatePicker(controller);
}, },
child: Container( child: Container(
@ -487,7 +512,7 @@ class UserInfoPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// //
const Align( const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
@ -503,7 +528,8 @@ class UserInfoPage extends StatelessWidget {
const SizedBox(height: 10), const SizedBox(height: 10),
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
FocusScope.of(context).requestFocus(_blankFocusNode);
// FocusScope.of(context).requestFocus(_blankFocusNode);
// _blankFocusNode.unfocus();
// //
await _showEducationPicker(controller); await _showEducationPicker(controller);
}, },
@ -532,7 +558,7 @@ class UserInfoPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// //
const Align( const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
@ -553,9 +579,22 @@ class UserInfoPage extends StatelessWidget {
color: Color.fromRGBO(247, 247, 247, 1), color: Color.fromRGBO(247, 247, 247, 1),
), ),
child: TextField( child: TextField(
focusNode: _blankFocusNode2,
controller: _controller2,
onChanged: (value) { onChanged: (value) {
controller.invitationCode.value = value; controller.invitationCode.value = value;
}, },
onTapOutside: (e){
_blankFocusNode2.unfocus();
},
onTap: (){
//
WidgetsBinding.instance.addPostFrameCallback((_) {
_controller2.selection = TextSelection.fromPosition(
TextPosition(offset: _controller2.text.length),
);
});
},
decoration: const InputDecoration( decoration: const InputDecoration(
hintText: '请输入邀请码', hintText: '请输入邀请码',
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
@ -564,7 +603,7 @@ class UserInfoPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 24), const SizedBox(height: 24),
// //
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
@ -581,20 +620,20 @@ class UserInfoPage extends StatelessWidget {
), ),
child: controller.isSubmitting.value child: controller.isSubmitting.value
? const SizedBox( ? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
width: 20,
height: 20,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: const Text( : const Text(
'开始交友',
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
'开始交友',
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
@ -608,4 +647,14 @@ class UserInfoPage extends StatelessWidget {
}, },
); );
} }
@override
void dispose() {
// TODO: implement dispose
super.dispose();
_blankFocusNode.dispose();
_controller.dispose();
_blankFocusNode2.dispose();
_controller2.dispose();
}
} }
Loading…
Cancel
Save