|
|
@@ -1,3 +1,4 @@
|
|
|
+import 'dart:async';
|
|
|
import 'dart:convert';
|
|
|
import 'dart:io';
|
|
|
|
|
|
@@ -27,14 +28,17 @@ class RegisteredPage extends StatefulWidget {
|
|
|
|
|
|
class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
TextEditingController _phoneNum = TextEditingController(text: '');
|
|
|
+ TextEditingController _verificationCode = TextEditingController(text: '');
|
|
|
TextEditingController _nickname = TextEditingController(text: '');
|
|
|
TextEditingController _pw = TextEditingController(text: '');
|
|
|
bool showPW = true;
|
|
|
int focus = -1;
|
|
|
bool haveRead = false;
|
|
|
+ String verificationCodeText = '发送验证码';
|
|
|
|
|
|
File _image;
|
|
|
final picker = ImagePicker();
|
|
|
+ Timer _timer;
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
@@ -152,14 +156,14 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
padding: EdgeInsets.only(left: 47, right: 47, top: 26),
|
|
|
child: Column(
|
|
|
children: [
|
|
|
- Container(
|
|
|
- child: Text(
|
|
|
- 'Hello Welcome !',
|
|
|
- style: TextStyle(
|
|
|
- color: MyColors.cFF4233, fontSize: 24),
|
|
|
- ),
|
|
|
- margin: EdgeInsets.only(bottom: 25),
|
|
|
- ),
|
|
|
+ // Container(
|
|
|
+ // child: Text(
|
|
|
+ // 'Hello Welcome !',
|
|
|
+ // style: TextStyle(
|
|
|
+ // color: MyColors.cFF4233, fontSize: 24),
|
|
|
+ // ),
|
|
|
+ // margin: EdgeInsets.only(bottom: 25),
|
|
|
+ // ),
|
|
|
Row(
|
|
|
children: [
|
|
|
Container(
|
|
|
@@ -262,62 +266,84 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
),
|
|
|
],
|
|
|
),
|
|
|
- // Row(
|
|
|
- // children: [
|
|
|
- // Container(
|
|
|
- // child: SvgPicture.asset(
|
|
|
- // 'images/svg/验证码.svg',
|
|
|
- // height: 22,
|
|
|
- // width: 22,
|
|
|
- // ),
|
|
|
- // height: 22,
|
|
|
- // width: 22,
|
|
|
- // ),
|
|
|
- // Expanded(
|
|
|
- // child: TextField(
|
|
|
- // controller: _verificationCode,
|
|
|
- // cursorColor: MyColors.cFF4233,
|
|
|
- // cursorWidth: 1.0,
|
|
|
- // onTap: () {
|
|
|
- // setState(() {
|
|
|
- // focus = 1;
|
|
|
- // });
|
|
|
- // },
|
|
|
- // decoration: InputDecoration(
|
|
|
- // border: InputBorder.none,
|
|
|
- // disabledBorder: InputBorder.none,
|
|
|
- // enabledBorder: InputBorder.none,
|
|
|
- // focusedBorder: InputBorder.none,
|
|
|
- // hintText: '请输入验证码',
|
|
|
- // hintStyle: TextStyle(
|
|
|
- // color: MyColors.c999999, fontSize: 16),
|
|
|
- // isDense: true,
|
|
|
- // contentPadding:
|
|
|
- // const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5)),
|
|
|
- // maxLines: 1,
|
|
|
- // style: TextStyle(
|
|
|
- // color: MyColors.c333333,
|
|
|
- // fontSize: 16,
|
|
|
- // height: 1.3,
|
|
|
- // letterSpacing: 0.2),
|
|
|
- // keyboardType: TextInputType.text,
|
|
|
- // onChanged: (t) {},
|
|
|
- // ),
|
|
|
- // ),
|
|
|
- // Container(
|
|
|
- // decoration: BoxDecoration(
|
|
|
- // color: MyColors.c19FF4233,
|
|
|
- // borderRadius:
|
|
|
- // BorderRadius.all(Radius.circular(4))),
|
|
|
- // height: 34,
|
|
|
- // width: 90,
|
|
|
- // )
|
|
|
- // ],
|
|
|
- // ),
|
|
|
Container(
|
|
|
height: 1,
|
|
|
color:
|
|
|
- focus == 2 ? MyColors.cFF4233 : MyColors.cD7D7D7,
|
|
|
+ focus == 2 ? MyColors.cFF4233 : MyColors.cD7D7D7,
|
|
|
+ margin: EdgeInsets.only(top: 8, bottom: 39),
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ child: SvgPicture.asset(
|
|
|
+ 'images/svg/验证码.svg',
|
|
|
+ height: 22,
|
|
|
+ width: 22,
|
|
|
+ ),
|
|
|
+ height: 22,
|
|
|
+ width: 22,
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: TextField(
|
|
|
+ controller: _verificationCode,
|
|
|
+ cursorColor: MyColors.cFF4233,
|
|
|
+ cursorWidth: 1.0,
|
|
|
+ inputFormatters: [
|
|
|
+ onlyInputNumberAndWorkFormatter(),
|
|
|
+ LengthLimitingTextInputFormatter(6)
|
|
|
+ ],
|
|
|
+ onTap: () {
|
|
|
+ setState(() {
|
|
|
+ focus = 1;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ decoration: InputDecoration(
|
|
|
+ border: InputBorder.none,
|
|
|
+ disabledBorder: InputBorder.none,
|
|
|
+ enabledBorder: InputBorder.none,
|
|
|
+ focusedBorder: InputBorder.none,
|
|
|
+ hintText: '请输入验证码',
|
|
|
+ hintStyle: TextStyle(
|
|
|
+ color: MyColors.c999999, fontSize: 16),
|
|
|
+ isDense: true,
|
|
|
+ contentPadding:
|
|
|
+ const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5)),
|
|
|
+ maxLines: 1,
|
|
|
+ style: TextStyle(
|
|
|
+ color: MyColors.c333333,
|
|
|
+ fontSize: 16,
|
|
|
+ height: 1.3,
|
|
|
+ letterSpacing: 0.2),
|
|
|
+ keyboardType: TextInputType.number,
|
|
|
+ onChanged: (t) {},
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ GestureDetector(
|
|
|
+ onTap: (){
|
|
|
+ if(verificationCodeText!='发送验证码'){
|
|
|
+ showToast('验证码发送中');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ sendTheVerificationCode();
|
|
|
+ },
|
|
|
+ behavior: HitTestBehavior.translucent,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: MyColors.c19FF4233,
|
|
|
+ borderRadius:
|
|
|
+ BorderRadius.all(Radius.circular(4))),
|
|
|
+ child: Text(verificationCodeText,style: TextStyle(color: MyColors.cFF4233,fontSize: 14),),
|
|
|
+ alignment: Alignment.center,
|
|
|
+ height: 34,
|
|
|
+ width: 90,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ height: 1,
|
|
|
+ color:
|
|
|
+ focus == 1 ? MyColors.cFF4233 : MyColors.cD7D7D7,
|
|
|
margin: EdgeInsets.only(top: 8, bottom: 39),
|
|
|
),
|
|
|
Row(
|
|
|
@@ -342,7 +368,7 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
cursorWidth: 1.0,
|
|
|
onTap: () {
|
|
|
setState(() {
|
|
|
- focus = 1;
|
|
|
+ focus = 3;
|
|
|
});
|
|
|
},
|
|
|
decoration: InputDecoration(
|
|
|
@@ -385,7 +411,7 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
Container(
|
|
|
height: 1,
|
|
|
color:
|
|
|
- focus == 1 ? MyColors.cFF4233 : MyColors.cD7D7D7,
|
|
|
+ focus == 3 ? MyColors.cFF4233 : MyColors.cD7D7D7,
|
|
|
margin: EdgeInsets.only(top: 8, bottom: 20),
|
|
|
),
|
|
|
Row(
|
|
|
@@ -455,6 +481,10 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
showToast('请填写昵称');
|
|
|
return;
|
|
|
}
|
|
|
+ if (_verificationCode.text.isEmpty) {
|
|
|
+ showToast('请填写验证码');
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (_image == null) {
|
|
|
showToast('请设置头像');
|
|
|
return;
|
|
|
@@ -463,7 +493,7 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
showToast('请阅读并同意《隐私政策》');
|
|
|
return;
|
|
|
}
|
|
|
- uploadAvatar();
|
|
|
+ verificationCode();
|
|
|
},
|
|
|
behavior: HitTestBehavior.translucent,
|
|
|
child: Container(
|
|
|
@@ -540,6 +570,7 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
// MyTools().toPage(
|
|
|
// context, LoginPage(), (then) {},
|
|
|
// noBack: true);
|
|
|
+ _timer.cancel();
|
|
|
loginAccount({
|
|
|
'user': _phoneNum.text,
|
|
|
'password': MyTools.base64Encode(_pw.text),
|
|
|
@@ -557,6 +588,59 @@ class _RegisteredPageState extends State<RegisteredPage> {
|
|
|
}
|
|
|
}, (error) {});
|
|
|
}
|
|
|
+
|
|
|
+ int countdown = 60;
|
|
|
+ void sendTheVerificationCode() {
|
|
|
+ if(_phoneNum.text.isEmpty||_phoneNum.text.length!=11){
|
|
|
+ showToast('请输入正确的手机号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ MyDio().post('/hms/sendCode', {
|
|
|
+ 'mobile':_phoneNum.text
|
|
|
+ }, (response, hasError) {
|
|
|
+ if(!hasError){
|
|
|
+
|
|
|
+ }
|
|
|
+ }, (error) {
|
|
|
+ showToast('发送失败');
|
|
|
+ countdown = 2;
|
|
|
+ });
|
|
|
+
|
|
|
+ setState(() {
|
|
|
+ setState(() {
|
|
|
+ verificationCodeText = '$countdown s';
|
|
|
+ countdown--;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ _timer = Timer.periodic(Duration(seconds: 1), (timer) {
|
|
|
+ if(countdown==0){
|
|
|
+ timer.cancel();
|
|
|
+ setState(() {
|
|
|
+ countdown = 60;
|
|
|
+ verificationCodeText = '发送验证码';
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ setState(() {
|
|
|
+ verificationCodeText = '$countdown s';
|
|
|
+ countdown--;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void verificationCode() {
|
|
|
+ MyDio().post('/hms/verifyCode', {
|
|
|
+ 'mobile':_phoneNum.text,
|
|
|
+ 'code':int.parse(_verificationCode.text),
|
|
|
+ }, (response, hasError) {
|
|
|
+ if(!hasError){
|
|
|
+ uploadAvatar();
|
|
|
+ }
|
|
|
+ }, (error) {
|
|
|
+ showToast('验证码错误');
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class PrivacyPolicyPage extends StatefulWidget {
|