Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 5dadc46a
authored
2025-11-24 18:37:23 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
微信登录时,增加loading
1 parent
c500d097
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
62 deletions
lib/bloc/login_main_cubit.dart
lib/ui/pages/login_main_page.dart
lib/bloc/login_main_cubit.dart
View file @
5dadc46
...
@@ -8,23 +8,33 @@ import 'package:flutter_bloc/flutter_bloc.dart';
...
@@ -8,23 +8,33 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import
'package:fluwx/fluwx.dart'
;
import
'package:fluwx/fluwx.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
class
LoginMainState
extends
Equatable
{
class
LoginMainState
extends
Equatable
{
final
bool
agreed
;
final
bool
agreed
;
final
bool
showAgreed
;
final
bool
showAgreed
;
final
bool
loading
;
const
LoginMainState
({
this
.
agreed
=
false
,
this
.
showAgreed
=
false
});
const
LoginMainState
({
this
.
agreed
=
false
,
this
.
showAgreed
=
false
,
this
.
loading
=
false
,
});
@override
@override
List
<
Object
?>
get
props
=>
[
agreed
,
showAgreed
];
List
<
Object
?>
get
props
=>
[
agreed
,
showAgreed
,
loading
,
];
LoginMainState
copyWith
({
LoginMainState
copyWith
({
bool
?
agreed
,
bool
?
agreed
,
bool
?
showAgreed
,
bool
?
showAgreed
,
bool
?
loading
,
})
{
})
{
return
LoginMainState
(
return
LoginMainState
(
agreed:
agreed
??
this
.
agreed
,
agreed:
agreed
??
this
.
agreed
,
showAgreed:
showAgreed
??
this
.
showAgreed
,
showAgreed:
showAgreed
??
this
.
showAgreed
,
loading:
loading
??
this
.
loading
,
);
);
}
}
}
}
...
@@ -67,6 +77,9 @@ class LoginMainCubit extends Cubit<LoginMainState> {
...
@@ -67,6 +77,9 @@ class LoginMainCubit extends Cubit<LoginMainState> {
if
(!
result
)
{
if
(!
result
)
{
throw
Exception
(
'微信授权处理失败'
);
throw
Exception
(
'微信授权处理失败'
);
}
}
// 控制显示加载框
emit
(
state
.
copyWith
(
loading:
true
));
}
}
void
goLoginPhone
()
{
void
goLoginPhone
()
{
...
@@ -98,7 +111,7 @@ class LoginMainCubit extends Cubit<LoginMainState> {
...
@@ -98,7 +111,7 @@ class LoginMainCubit extends Cubit<LoginMainState> {
sharedPreferences
.
setString
(
'auth_stuId'
,
stuId
??
''
);
sharedPreferences
.
setString
(
'auth_stuId'
,
stuId
??
''
);
sharedPreferences
.
setString
(
'auth_ip'
,
Constant
.
h5Server
);
sharedPreferences
.
setString
(
'auth_ip'
,
Constant
.
h5Server
);
if
(
Constant
.
needIM
)
{
if
(
Constant
.
needIM
)
{
// IM登录, 正式使用时,需要从服务端获取用户签名
// IM登录, 正式使用时,需要从服务端获取用户签名
var
loginResult
=
await
_imService
.
login
(
userCode
);
var
loginResult
=
await
_imService
.
login
(
userCode
);
if
(
loginResult
)
{
if
(
loginResult
)
{
...
...
lib/ui/pages/login_main_page.dart
View file @
5dadc46
...
@@ -14,41 +14,61 @@ class LoginMainPage extends StatelessWidget {
...
@@ -14,41 +14,61 @@ class LoginMainPage extends StatelessWidget {
create:
(
context
)
=>
LoginMainCubit
(
LoginMainState
()),
create:
(
context
)
=>
LoginMainCubit
(
LoginMainState
()),
child:
BlocConsumer
<
LoginMainCubit
,
LoginMainState
>(
builder:
(
context
,
state
)
{
child:
BlocConsumer
<
LoginMainCubit
,
LoginMainState
>(
builder:
(
context
,
state
)
{
var
loginMainCubit
=
context
.
read
<
LoginMainCubit
>();
var
loginMainCubit
=
context
.
read
<
LoginMainCubit
>();
return
Scaffold
(
return
Stack
(
resizeToAvoidBottomInset:
true
,
children:
[
backgroundColor:
Colors
.
white
,
Scaffold
(
body:
SafeArea
(
resizeToAvoidBottomInset:
true
,
top:
false
,
backgroundColor:
Colors
.
white
,
child:
SingleChildScrollView
(
body:
SafeArea
(
child:
Column
(
top:
false
,
children:
[
child:
SingleChildScrollView
(
LoginPageImageWidget
(),
Transform
.
translate
(
offset:
Offset
(
0
,
-
40
),
// 向上移动40像素
child:
Container
(
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
vertical
(
top:
Radius
.
circular
(
20
)),
color:
Colors
.
white
,
// 设置背景色
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
24.0
),
child:
Column
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
crossAxisAlignment:
CrossAxisAlignment
.
start
,
LoginPageImageWidget
(),
children:
[
Transform
.
translate
(
SizedBox
(
height:
30
),
offset:
Offset
(
0
,
-
40
),
// 向上移动40像素
// _buildHeader(),
child:
Container
(
LoginPageHeaderWidget
(),
decoration:
BoxDecoration
(
SizedBox
(
height:
25
),
borderRadius:
BorderRadius
.
vertical
(
top:
Radius
.
circular
(
20
)),
_buildLoginButtons
(
context
,
loginMainCubit
,
state
.
agreed
),
color:
Colors
.
white
,
// 设置背景色
SizedBox
(
height:
20
),
),
_buildAgreement
(
context
,
loginMainCubit
,
state
.
agreed
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
24.0
),
],
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
SizedBox
(
height:
30
),
LoginPageHeaderWidget
(),
SizedBox
(
height:
25
),
_buildLoginButtons
(
context
,
loginMainCubit
,
state
.
agreed
),
SizedBox
(
height:
20
),
_buildAgreement
(
context
,
loginMainCubit
,
state
.
agreed
),
],
),
),
),
),
),
],
),
)),
],
),
)),
),
),
state
.
loading
?
Container
(
color:
Colors
.
black54
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
child:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
CircularProgressIndicator
(
color:
Color
(
0xFF7691FA
),
),
],
),
),
)
:
SizedBox
(),
],
);
);
},
listener:
(
context
,
state
)
{
},
listener:
(
context
,
state
)
{
if
(
state
.
showAgreed
)
{
if
(
state
.
showAgreed
)
{
...
@@ -58,31 +78,6 @@ class LoginMainPage extends StatelessWidget {
...
@@ -58,31 +78,6 @@ class LoginMainPage extends StatelessWidget {
);
);
}
}
Widget
_buildHeader
()
{
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'欢迎登录'
,
style:
TextStyle
(
fontSize:
25
,
fontWeight:
FontWeight
.
bold
,
color:
Colors
.
black87
,
),
),
SizedBox
(
height:
6
),
Text
(
'班小二,班级群必备效率工具'
,
style:
TextStyle
(
fontSize:
14
,
color:
Colors
.
black87
,
),
),
],
);
}
Widget
_buildLoginButtons
(
BuildContext
context
,
LoginMainCubit
loginMainCubit
,
bool
agreed
)
{
Widget
_buildLoginButtons
(
BuildContext
context
,
LoginMainCubit
loginMainCubit
,
bool
agreed
)
{
return
Column
(
return
Column
(
children:
[
children:
[
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment