205 lines
6.8 KiB
Dart
205 lines
6.8 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:game/common/EventBusUtil.dart';
|
|
import 'package:game/network/NetworkConfig.dart';
|
|
|
|
import '../me_model.dart';
|
|
|
|
class RealNamePage extends StatefulWidget {
|
|
const RealNamePage({super.key});
|
|
|
|
@override
|
|
State<RealNamePage> createState() => _RealNamePageState();
|
|
}
|
|
|
|
class _RealNamePageState extends State<RealNamePage> {
|
|
final TextEditingController _nameController = TextEditingController();
|
|
final TextEditingController _codeController = TextEditingController();
|
|
|
|
late StreamSubscription subscription;
|
|
final MeModel _viewModel = MeModel();
|
|
|
|
String btText = "提交";
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
|
|
subscription = _viewModel.streamController.stream.listen((event) {
|
|
String code = event['code'];
|
|
if (code.isNotEmpty) {
|
|
switch (code) {
|
|
case "realAuthentication":
|
|
EasyLoading.showToast(event['data']);
|
|
EventBusUtil.fire(RefreshUserdata());
|
|
Navigator.pop(context);
|
|
break;
|
|
case "realError":
|
|
EasyLoading.showToast(event['data']);
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
if (NetworkConfig.userInfoBean!.isRealName! && NetworkConfig.userInfoBean!.isJuveniles!) {
|
|
btText = "重新认证";
|
|
setState(() {});
|
|
}
|
|
|
|
if (NetworkConfig.userInfoBean?.idCard != "") {
|
|
_nameController.text = NetworkConfig.userInfoBean!.userName!;
|
|
_codeController.text = NetworkConfig.userInfoBean!.idCard!;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// TODO: implement dispose
|
|
subscription.cancel();
|
|
_nameController.dispose();
|
|
_codeController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF17181A),
|
|
body: Column(
|
|
children: [
|
|
Container(
|
|
width: size.width,
|
|
height: 50,
|
|
margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Text(
|
|
"实名认证",
|
|
style: TextStyle(fontSize: 16, color: Color(0xFFD6D6D7)),
|
|
),
|
|
Positioned(
|
|
left: 14,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Image(
|
|
width: 19,
|
|
height: 26,
|
|
image: AssetImage('assets/images/btn_fanhui.png'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: size.width,
|
|
margin: EdgeInsets.only(top: 18, left: 14, right: 14),
|
|
decoration: BoxDecoration(color: Color(0xFF202530), borderRadius: BorderRadius.all(Radius.circular(11))),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(top: 18),
|
|
child: Text(
|
|
"请使用有效身份证信息完成认证",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: 11, top: 18),
|
|
child: Text(
|
|
"姓名",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
height: 43,
|
|
margin: EdgeInsets.only(left: 11, right: 11, top: 11),
|
|
padding: EdgeInsets.only(left: 11),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF111319),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: TextField(
|
|
controller: _nameController,
|
|
cursorColor: Color(0xFF074CE7),
|
|
style: TextStyle(fontSize: 11, color: Colors.white),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
hintText: '请输入姓名',
|
|
hintStyle: TextStyle(fontSize: 11, color: Color(0xFF44474F)),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: 11, top: 18),
|
|
child: Text(
|
|
"身份证号码",
|
|
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
height: 43,
|
|
margin: EdgeInsets.only(left: 11, right: 11, top: 11, bottom: 18),
|
|
padding: EdgeInsets.only(left: 11),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF111319),
|
|
borderRadius: BorderRadius.all(Radius.circular(11)),
|
|
),
|
|
child: TextField(
|
|
controller: _codeController,
|
|
cursorColor: Color(0xFF074CE7),
|
|
style: TextStyle(fontSize: 11, color: Colors.white),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
hintText: '请输入身份证号',
|
|
hintStyle: TextStyle(fontSize: 11, color: Color(0xFF44474F)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
if (_nameController.text == "") {
|
|
EasyLoading.showToast("请输入姓名");
|
|
return;
|
|
}
|
|
if (_codeController.text == "") {
|
|
EasyLoading.showToast("请输入身份证号");
|
|
return;
|
|
}
|
|
|
|
_viewModel.realAuthentication(_nameController.text, _codeController.text);
|
|
},
|
|
child: Container(
|
|
width: size.width,
|
|
height: 44,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(left: 14, right: 14, top: 36),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF074CE7),
|
|
borderRadius: BorderRadius.all(Radius.circular(22)),
|
|
),
|
|
child: Text(
|
|
btText,
|
|
style: TextStyle(fontSize: 14, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|