|
|
@@ -52,35 +52,24 @@ class LoginSecondState extends State<LoginSecond> {
|
|
|
SliverToBoxAdapter(
|
|
|
child: Container(
|
|
|
color: BG_SUB_COLOR,
|
|
|
- padding:
|
|
|
- EdgeInsets.symmetric(vertical: 30, horizontal: 15),
|
|
|
+ padding: EdgeInsets.symmetric(vertical: 30, horizontal: 15),
|
|
|
child: Column(
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
children: <Widget>[
|
|
|
Text(
|
|
|
'验证码已发送至',
|
|
|
- style: TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontSize: 28,
|
|
|
- fontWeight: FontWeight.w600),
|
|
|
+ style: TextStyle(color: Colors.white, fontSize: 28, fontWeight: FontWeight.w600),
|
|
|
),
|
|
|
Container(
|
|
|
margin: EdgeInsets.only(top: 45),
|
|
|
child: Row(
|
|
|
- mainAxisAlignment:
|
|
|
- MainAxisAlignment.spaceBetween,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: <Widget>[
|
|
|
- Text(widget.phone,
|
|
|
- style: TextStyle(
|
|
|
- color: Color(0xFFF15436),
|
|
|
- fontSize: 20,
|
|
|
- fontWeight: FontWeight.w500)),
|
|
|
+ Text(widget.phone, style: TextStyle(color: Color(0xFFF15436), fontSize: 20, fontWeight: FontWeight.w500)),
|
|
|
FlatButton(
|
|
|
highlightColor: BG_SUB_COLOR,
|
|
|
textColor: PRIMARY_COLOR,
|
|
|
- child: Text(isSend
|
|
|
- ? '(' + '$sendTime' + '秒)'
|
|
|
- : '重新发送'),
|
|
|
+ child: Text(isSend ? '(' + '$sendTime' + '秒)' : '重新发送'),
|
|
|
disabledTextColor: Color(0xFF8D8E9C),
|
|
|
onPressed: isSend
|
|
|
? null
|
|
|
@@ -115,8 +104,7 @@ class LoginSecondState extends State<LoginSecond> {
|
|
|
inputCode = content;
|
|
|
});
|
|
|
},
|
|
|
- counterStyle:
|
|
|
- TextStyle(color: BG_SUB_COLOR, fontSize: 0),
|
|
|
+ counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0),
|
|
|
),
|
|
|
),
|
|
|
Container(
|
|
|
@@ -130,24 +118,16 @@ class LoginSecondState extends State<LoginSecond> {
|
|
|
child: Text("注册/登录"),
|
|
|
onPressed: () async {
|
|
|
if (_sessionID == null) {
|
|
|
- Toast.show(
|
|
|
- context, '请发送验证码', 1500, 'info');
|
|
|
+ Toast.show(context, '请发送验证码', 1500, 'info');
|
|
|
} else if (inputCode.length != 6) {
|
|
|
- Toast.show(
|
|
|
- context, '请输入验证码', 1500, 'info');
|
|
|
+ Toast.show(context, '请输入验证码', 1500, 'info');
|
|
|
} else {
|
|
|
print(_sessionID);
|
|
|
print(inputCode);
|
|
|
Toast.show(context, '加载中', -1, 'loading');
|
|
|
Toast.hide();
|
|
|
- final Result res = await HttpManager.post(
|
|
|
- 'auth/loginSms',
|
|
|
- data: {
|
|
|
- "phone": widget.phone,
|
|
|
- "code": inputCode,
|
|
|
- "sessionId": _sessionID,
|
|
|
- "requireToken": true
|
|
|
- });
|
|
|
+ final Result res = await HttpManager.post('auth/loginSms',
|
|
|
+ data: {"phone": widget.phone, "code": inputCode, "sessionId": _sessionID, "requireToken": true});
|
|
|
Toast.hide();
|
|
|
if (res.success) {
|
|
|
print(res);
|
|
|
@@ -155,23 +135,16 @@ class LoginSecondState extends State<LoginSecond> {
|
|
|
prefs.setString('token', res.token);
|
|
|
print(prefs.getString('token'));
|
|
|
HttpManager.token = res.token;
|
|
|
- StoreProvider.of<AppState>(context)
|
|
|
- .dispatch({
|
|
|
- "action": Actions.updateAll,
|
|
|
- "user": res.data
|
|
|
- });
|
|
|
- Toast.show(
|
|
|
- context, '登录成功', 1500, 'success');
|
|
|
+ StoreProvider.of<AppState>(context).dispatch({"action": Actions.updateAll, "user": res.data});
|
|
|
+ Toast.show(context, '登录成功', 1500, 'success');
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
context,
|
|
|
new CupertinoPageRoute(
|
|
|
- builder: (context) =>
|
|
|
- new HomePage(),
|
|
|
+ builder: (context) => new HomePage(),
|
|
|
),
|
|
|
ModalRoute.withName('/'));
|
|
|
} else {
|
|
|
- Toast.show(
|
|
|
- context, res.error, 1500, 'info');
|
|
|
+ Toast.show(context, res.error, 1500, 'info');
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -188,6 +161,7 @@ class LoginSecondState extends State<LoginSecond> {
|
|
|
Toast.hide();
|
|
|
print("返回键点击了");
|
|
|
Navigator.pop(context);
|
|
|
+ return Future.value(false);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -196,8 +170,7 @@ class LoginSecondState extends State<LoginSecond> {
|
|
|
|
|
|
Toast.show(context, '加载中', -1, 'loading');
|
|
|
|
|
|
- final Result res =
|
|
|
- await HttpManager.get('rong/sendCode', data: {"phone": widget.phone});
|
|
|
+ final Result res = await HttpManager.get('rong/sendCode', data: {"phone": widget.phone});
|
|
|
Toast.hide();
|
|
|
if (res.success) {
|
|
|
Toast.show(context, '发送成功', 1500, 'success');
|