233 lines
8.6 KiB
Dart
233 lines
8.6 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 '../../../common/func.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
|
|
super.dispose();
|
|
subscription.cancel();
|
|
_nameController.dispose();
|
|
_codeController.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final h50 = size.width / 7.2;
|
|
final s16 = size.width / 22.5;
|
|
final l14 = size.width / 25.71428571428571;
|
|
final w19 = size.width / 18.94736842105263;
|
|
final h26 = size.width / 13.84615384615385;
|
|
final t18 = size.width / 20;
|
|
final h43 = size.width / 8.372093023255814;
|
|
final h44 = size.width / 8.181818181818182;
|
|
final t36 = size.width / 10;
|
|
final c22 = size.width / 16.36363636363636;
|
|
final s14 = size.width / 25.714285714285;
|
|
final s11 = size.width / 32.727272727272;
|
|
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF17181A),
|
|
body: Column(
|
|
children: [
|
|
Container(
|
|
width: size.width,
|
|
height: h50,
|
|
margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Text(
|
|
"实名认证",
|
|
style: TextStyle(fontSize: s16, color: const Color(0xFFD6D6D7)),
|
|
),
|
|
Positioned(
|
|
left: l14,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Image(
|
|
width: w19,
|
|
height: h26,
|
|
image: const AssetImage('assets/images/btn_fanhui.png'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
width: size.width,
|
|
margin: EdgeInsets.only(top: t18, left: l14, right: l14),
|
|
decoration: const BoxDecoration(color: Color(0xFF202530), borderRadius: BorderRadius.all(Radius.circular(11))),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(top: t18),
|
|
child: Text(
|
|
"请使用有效身份证信息完成认证",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: s11, top: t18),
|
|
child: Text(
|
|
"姓名",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
height: h43,
|
|
margin: EdgeInsets.only(left: s11, right: s11, top: s11),
|
|
padding: EdgeInsets.only(left: s11),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF111319),
|
|
borderRadius: BorderRadius.all(Radius.circular(s11)),
|
|
),
|
|
child: TextField(
|
|
controller: _nameController,
|
|
cursorColor: const Color(0xFF074CE7),
|
|
style: TextStyle(fontSize: s11, color: Colors.white),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
hintText: '请输入姓名',
|
|
hintStyle: TextStyle(fontSize: s11, color: Color(0xFF44474F)),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(left: s11, top: t18),
|
|
child: Text(
|
|
"身份证号码",
|
|
style: TextStyle(fontSize: s14, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
height: h43,
|
|
margin: EdgeInsets.only(left: s11, right: s11, top: s11, bottom: t18),
|
|
padding: EdgeInsets.only(left: s11),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF111319),
|
|
borderRadius: BorderRadius.all(Radius.circular(s11)),
|
|
),
|
|
child: TextField(
|
|
controller: _codeController,
|
|
cursorColor: const Color(0xFF074CE7),
|
|
style: TextStyle(fontSize: s11, color: Colors.white),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
hintText: '请输入身份证号',
|
|
hintStyle: TextStyle(fontSize: s11, color: Color(0xFF44474F)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
if (NetworkConfig.userInfoBean!.isRealName! && !NetworkConfig.userInfoBean!.isJuveniles!) {
|
|
EasyLoading.showToast("已实名,无需重新认证");
|
|
return;
|
|
}
|
|
|
|
if (_nameController.text == "") {
|
|
EasyLoading.showToast("请输入姓名");
|
|
return;
|
|
}
|
|
if (_codeController.text == "") {
|
|
EasyLoading.showToast("请输入身份证号");
|
|
return;
|
|
}
|
|
FunctionUtil.loading();
|
|
_viewModel.realAuthentication(_nameController.text, _codeController.text);
|
|
},
|
|
child: Container(
|
|
width: size.width,
|
|
height: h44,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(left: l14, right: l14, top: t36),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF074CE7),
|
|
borderRadius: BorderRadius.all(Radius.circular(c22)),
|
|
),
|
|
child: Text(
|
|
btText,
|
|
style: TextStyle(fontSize: s14, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|