232 lines
8.1 KiB
Dart
232 lines
8.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
import '../../../common/EventBusUtil.dart';
|
|
import '../../../common/func.dart';
|
|
import '../../../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
|
|
super.dispose();
|
|
subscription.cancel();
|
|
_nameController.dispose();
|
|
_codeController.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final t18 = size.width / 20;
|
|
final c22 = size.width / 16.36363636363636;
|
|
final l11 = size.width / 32.727272727272;
|
|
final s7 = size.width / 51.428571428571;
|
|
final h10 = size.width / 36;
|
|
final s6 = size.width / 60;
|
|
final c2 = size.width / 180;
|
|
final w129 = size.width / 2.7906976744186;
|
|
final s5 = size.width / 72;
|
|
final w45 = size.width / 8;
|
|
final h14 = size.width / 25.714285714285;
|
|
final t34 = size.width / 10.588235294117;
|
|
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF17181A),
|
|
body: Column(
|
|
children: [
|
|
Container(
|
|
width: size.width,
|
|
height: l11,
|
|
margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top + h10),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Text(
|
|
"实名认证",
|
|
style: TextStyle(fontSize: s7, color: const Color(0xFFD6D6D7)),
|
|
),
|
|
Positioned(
|
|
left: l11,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Image(
|
|
width: l11,
|
|
height: l11,
|
|
image: const AssetImage('assets/images/btn_fanhui.png'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(top: t18),
|
|
child: Text(
|
|
"请使用有效身份证信息完成认证",
|
|
style: TextStyle(fontSize: s7, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
width: w129,
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(top: t18),
|
|
child: Text(
|
|
"姓名",
|
|
style: TextStyle(fontSize: s5, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
width: w129,
|
|
height: t18,
|
|
margin: EdgeInsets.only(top: s6),
|
|
padding: EdgeInsets.only(left: s6),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(c2)),
|
|
),
|
|
child: TextField(
|
|
controller: _nameController,
|
|
cursorColor: const Color(0xFF074CE7),
|
|
style: TextStyle(fontSize: s5, color: Colors.white),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
hintText: '请输入姓名',
|
|
hintStyle: TextStyle(fontSize: s5, color: Color(0xFF9D9D9D)),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: w129,
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.only(top: h14),
|
|
child: Text(
|
|
"身份证号码",
|
|
style: TextStyle(fontSize: s5, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
width: w129,
|
|
height: t18,
|
|
margin: EdgeInsets.only(top: s6),
|
|
padding: EdgeInsets.only(left: s6),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.all(Radius.circular(c2)),
|
|
),
|
|
child: TextField(
|
|
controller: _codeController,
|
|
cursorColor: const Color(0xFF074CE7),
|
|
style: TextStyle(fontSize: s5, color: Colors.white),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
hintText: '请输入身份证号',
|
|
hintStyle: TextStyle(fontSize: s5, color: Color(0xFF9D9D9D)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
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: w45,
|
|
height: h14,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: t34),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF074CE7),
|
|
borderRadius: BorderRadius.all(Radius.circular(c22)),
|
|
),
|
|
child: Text(
|
|
btText,
|
|
style: TextStyle(fontSize: s6, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|