@@ -16,6 +16,8 @@ import 'package:wechat_kit/wechat_kit.dart';
16
16
17
17
import 'package:openiothub_common_pages/openiothub_common_pages.dart' ;
18
18
19
+ import '../utils/toast.dart' ;
20
+
19
21
class LoginPage extends StatefulWidget {
20
22
@override
21
23
_State createState () => _State ();
@@ -43,7 +45,7 @@ class _State extends State<LoginPage> {
43
45
await UserManager .LoginWithWechatCode (resp.code! );
44
46
await _handleLoginResp (userLoginResponse);
45
47
} else {
46
- showToast ("$wechat_login_failed :${resp .errorMsg }" );
48
+ show_failed ("$wechat_login_failed :${resp .errorMsg }" , context );
47
49
}
48
50
}
49
51
@@ -117,12 +119,12 @@ class _State extends State<LoginPage> {
117
119
onTap: () async {
118
120
// 只有同意隐私政策才可以进行下一步
119
121
if (! _isChecked) {
120
- showToast ("${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement1 }☑️${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement2 }" );
122
+ show_failed ("${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement1 }☑️${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement2 }" , context );
121
123
return ;
122
124
}
123
125
if (_usermobile.text.isEmpty ||
124
126
_userpassword.text.isEmpty) {
125
- showToast (OpenIoTHubCommonLocalizations .of (context).username_and_password_cant_be_empty);
127
+ show_failed (OpenIoTHubCommonLocalizations .of (context).username_and_password_cant_be_empty, context );
126
128
return ;
127
129
}
128
130
LoginInfo loginInfo = LoginInfo ();
@@ -215,7 +217,7 @@ class _State extends State<LoginPage> {
215
217
onPressed: () async {
216
218
// 只有同意隐私政策才可以进行下一步
217
219
if (! _isChecked) {
218
- showToast ("${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement1 }☑️${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement2 }" );
220
+ show_failed ("${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement1 }☑️${OpenIoTHubCommonLocalizations .of (context ).agree_to_the_user_agreement2 }" , context );
219
221
return ;
220
222
}
221
223
// 判断是否安装了微信,安装了微信则打开微信进行登录,否则显示二维码由手机扫描登录
@@ -237,7 +239,7 @@ class _State extends State<LoginPage> {
237
239
loginFlag = generateRandomString (12 );
238
240
String qrUrl = await getPicUrl (loginFlag! );
239
241
if (qrUrl == "" ) {
240
- showToast (OpenIoTHubCommonLocalizations .of (context).get_wechat_qr_code_failed);
242
+ show_failed (OpenIoTHubCommonLocalizations .of (context).get_wechat_qr_code_failed, context );
241
243
return ;
242
244
}
243
245
// 循环获取登录结果
@@ -283,8 +285,8 @@ class _State extends State<LoginPage> {
283
285
});
284
286
Navigator .of (context).pop ();
285
287
} else {
286
- showToast (
287
- "${OpenIoTHubCommonLocalizations .of (context ).login_failed }:code:${userLoginResponse .code },message:${userLoginResponse .msg }" );
288
+ show_failed (
289
+ "${OpenIoTHubCommonLocalizations .of (context ).login_failed }:code:${userLoginResponse .code },message:${userLoginResponse .msg }" , context );
288
290
}
289
291
}
290
292
@@ -321,13 +323,13 @@ class _State extends State<LoginPage> {
321
323
} else if ((response.data["data" ] as Map <String , dynamic >)
322
324
.containsKey ("scan" ) &&
323
325
(response.data["data" ] as Map <String , dynamic >)["scan" ] == true ) {
324
- showToast (OpenIoTHubCommonLocalizations .of (context).login_after_wechat_bind);
326
+ show_success (OpenIoTHubCommonLocalizations .of (context).login_after_wechat_bind, context );
325
327
} else if ((response.data["data" ] as Map <String , dynamic >)
326
328
.containsKey ("scan" ) &&
327
329
(response.data["data" ] as Map <String , dynamic >)["scan" ] == false ) {
328
330
// showToast("请扫码!");
329
331
} else {
330
- showToast ("${OpenIoTHubCommonLocalizations .of (context ).wechat_fast_login_failed }:${response .data ["msg" ]}" );
332
+ show_failed ("${OpenIoTHubCommonLocalizations .of (context ).wechat_fast_login_failed }:${response .data ["msg" ]}" , context );
331
333
}
332
334
}
333
335
});
0 commit comments