@@ -16,6 +16,8 @@ import 'package:wechat_kit/wechat_kit.dart';
1616
1717import 'package:openiothub_common_pages/openiothub_common_pages.dart' ;
1818
19+ import '../utils/toast.dart' ;
20+
1921class LoginPage extends StatefulWidget {
2022 @override
2123 _State createState () => _State ();
@@ -43,7 +45,7 @@ class _State extends State<LoginPage> {
4345 await UserManager .LoginWithWechatCode (resp.code! );
4446 await _handleLoginResp (userLoginResponse);
4547 } else {
46- showToast ("$wechat_login_failed :${resp .errorMsg }" );
48+ show_failed ("$wechat_login_failed :${resp .errorMsg }" , context );
4749 }
4850 }
4951
@@ -117,12 +119,12 @@ class _State extends State<LoginPage> {
117119 onTap: () async {
118120 // 只有同意隐私政策才可以进行下一步
119121 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 );
121123 return ;
122124 }
123125 if (_usermobile.text.isEmpty ||
124126 _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 );
126128 return ;
127129 }
128130 LoginInfo loginInfo = LoginInfo ();
@@ -215,7 +217,7 @@ class _State extends State<LoginPage> {
215217 onPressed: () async {
216218 // 只有同意隐私政策才可以进行下一步
217219 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 );
219221 return ;
220222 }
221223 // 判断是否安装了微信,安装了微信则打开微信进行登录,否则显示二维码由手机扫描登录
@@ -237,7 +239,7 @@ class _State extends State<LoginPage> {
237239 loginFlag = generateRandomString (12 );
238240 String qrUrl = await getPicUrl (loginFlag! );
239241 if (qrUrl == "" ) {
240- showToast (OpenIoTHubCommonLocalizations .of (context).get_wechat_qr_code_failed);
242+ show_failed (OpenIoTHubCommonLocalizations .of (context).get_wechat_qr_code_failed, context );
241243 return ;
242244 }
243245 // 循环获取登录结果
@@ -283,8 +285,8 @@ class _State extends State<LoginPage> {
283285 });
284286 Navigator .of (context).pop ();
285287 } 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 );
288290 }
289291 }
290292
@@ -321,13 +323,13 @@ class _State extends State<LoginPage> {
321323 } else if ((response.data["data" ] as Map <String , dynamic >)
322324 .containsKey ("scan" ) &&
323325 (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 );
325327 } else if ((response.data["data" ] as Map <String , dynamic >)
326328 .containsKey ("scan" ) &&
327329 (response.data["data" ] as Map <String , dynamic >)["scan" ] == false ) {
328330 // showToast("请扫码!");
329331 } 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 );
331333 }
332334 }
333335 });
0 commit comments