Weller 4 年之前
父節點
當前提交
38cc0f1870
共有 6 個文件被更改,包括 51 次插入38 次删除
  1. +4
    -4
      lib/pages/login_page/account/bloc/login_account_bloc.dart
  2. +7
    -7
      lib/pages/login_page/account/bloc/login_account_state.dart
  3. +22
    -17
      lib/pages/login_page/account/login_account_page.dart
  4. +3
    -0
      lib/pages/login_page/invite/login_invite_page.dart
  5. +10
    -10
      lib/util/net_util.dart
  6. +5
    -0
      lib/util/turn_chain/turn_chain_util.dart

+ 4
- 4
lib/pages/login_page/account/bloc/login_account_bloc.dart 查看文件

@@ -58,18 +58,18 @@ class LoginAccountBloc extends Bloc<LoginAccountEvent, LoginAccountState> {
Stream<LoginAccountState> _mapLoginTypeVcodeEventToState(LoginAccountTypeVcodeEvent event) async* {
var result = await repository.loginTypeVcode(event);
if (!EmptyUtil.isEmpty(result))
yield LoginAccountTypeVcodeLoginSuccessState(model: result);
yield LoginAccountLoginSuccessState(model: result);
else
yield LoginAccountTypeVcodeLoginErrorState();
yield LoginAccountLoginErrorState();
}

/// 密码登陆
Stream<LoginAccountState> _mapLoginTypePassEventToState(LoginAccountTypePasswordEvent event) async* {
var result = await repository.loginTypePass(event);
if(!EmptyUtil.isEmpty(result))
yield LoginAccountTypeVcodeLoginSuccessState(model: result);
yield LoginAccountLoginSuccessState(model: result);
else
yield LoginAccountTypeVcodeLoginErrorState();
yield LoginAccountLoginErrorState();

}
}

+ 7
- 7
lib/pages/login_page/account/bloc/login_account_state.dart 查看文件

@@ -43,19 +43,19 @@ class LoginAccountGetVcodeErrorState extends LoginAccountState {
const LoginAccountGetVcodeErrorState({this.msg});
}

/// 验证码登陆成功
class LoginAccountTypeVcodeLoginSuccessState extends LoginAccountState {
/// 登陆成功
class LoginAccountLoginSuccessState extends LoginAccountState {
final UserInfoModel model;

const LoginAccountTypeVcodeLoginSuccessState({@required this.model});
const LoginAccountLoginSuccessState({@required this.model});

@override
List<Object> get props => [this.model];
}

/// 验证码登陆失败
class LoginAccountTypeVcodeLoginErrorState extends LoginAccountState {
/// 登陆失败
class LoginAccountLoginErrorState extends LoginAccountState {
final String msg;

const LoginAccountTypeVcodeLoginErrorState({this.msg});
}
const LoginAccountLoginErrorState({this.msg});
}

+ 22
- 17
lib/pages/login_page/account/login_account_page.dart 查看文件

@@ -52,6 +52,8 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i
FocusNode _phoneFN;
FocusNode _passFN;
FocusNode _vcodeFN;
// 是否登录中
bool _isLogging = false;

/// 跳转到邀请码页面
void _openInvitePage() {
@@ -67,11 +69,7 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i
/// 登陆成功页面
void _openLoginSuccessPage() {
RouterUtil.hideKeyboard(context);
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)),
(Route<dynamic> route) => false,
);
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), (Route<dynamic> route) => false,);
}

/// 返回上一页
@@ -84,14 +82,17 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i
/// 登陆
void _submitOnClick() {
print('登陆');
if (_checkParam(true)) {
if (_checkParam(true) && !_isLogging) {
setState(() {
_isLogging = true;
});
if (_useVcode) {
BlocProvider.of<LoginAccountBloc>(context)
.add(LoginAccountTypeVcodeEvent(mobile: _phoneEdController?.text?.toString()?.trim() ?? '', captcha: _vcodeEdController?.text?.toString()?.trim() ?? ''));
BlocProvider.of<LoginAccountBloc>(context).add(LoginAccountTypeVcodeEvent(mobile: _phoneEdController?.text?.toString()?.trim() ?? '', captcha: _vcodeEdController?.text?.toString()?.trim() ?? ''));
} else {
BlocProvider.of<LoginAccountBloc>(context)
.add(LoginAccountTypePasswordEvent(username: _phoneEdController?.text?.toString()?.trim() ?? '', password: _passEdController?.text?.toString()?.trim() ?? ''));
BlocProvider.of<LoginAccountBloc>(context).add(LoginAccountTypePasswordEvent(username: _phoneEdController?.text?.toString()?.trim() ?? '', password: _passEdController?.text?.toString()?.trim() ?? ''));
}
}else{
Logger.log('参数有误 或者 正在登录中。。。');
}
}

@@ -255,16 +256,20 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i
Widget build(BuildContext context) {
return BlocConsumer<LoginAccountBloc, LoginAccountState>(
listener: (context, state) {
if (state is LoginAccountTypeVcodeLoginSuccessState) {}
if (state is LoginAccountLoginSuccessState) {}
},
buildWhen: (prev, current) {
// 验证码登陆失败
if (current is LoginAccountTypeVcodeLoginErrorState) {
// 登陆失败
if (current is LoginAccountLoginErrorState) {
// Fluttertoast.showToast(msg: '登陆失败');
setState(() {
_isLogging = false;
});

return false;
}
// 验证码登陆成功
if (current is LoginAccountTypeVcodeLoginSuccessState) {
// 登陆成功
if (current is LoginAccountLoginSuccessState) {
/// 缓存登陆数据
Provider.of<UserInfoNotifier>(context, listen: false)?.setUserInfo(current.model);
if (current?.model?.registerInviteCodeEnable != '1') {
@@ -327,7 +332,7 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i
/// 切换登陆方式tip
Padding(padding: const EdgeInsets.only(top: 15), child: _getChangeTipWidget(model)),

/// 按钮
/// 登录按钮
Padding(padding: const EdgeInsets.only(left: 27.5, right: 27.5, top: 30), child: _getSubmiBtnWidget(model)),

/// 协议
@@ -488,7 +493,7 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i
color: Colors.white,
child: RaisedButton(
child: Text(
model?.mobile?.btnLoginText ?? '立即登录',
_isLogging ? '登录中...' : model?.mobile?.btnLoginText ?? '立即登录',
style: TextStyle(fontSize: 15),
),
textColor: HexColor.fromHex(model?.mobile?.btnLoginTextColor ?? '#FFFFFF'),


+ 3
- 0
lib/pages/login_page/invite/login_invite_page.dart 查看文件

@@ -39,6 +39,9 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> {
FocusNode _focusNode;
bool _showInviteInfo = false;

// 是否登录中
bool _isLogging = false;

/// 返回上一页
void _openPop() {
if (Navigator.canPop(context)) {


+ 10
- 10
lib/util/net_util.dart 查看文件

@@ -94,7 +94,7 @@ class NetUtil {
}

/// 同步请求
static Future<dynamic> post(String path, {Map<String, dynamic> params, NetMethod method = NetMethod.POST, bool cache = false}) async {
static Future<dynamic> post(String path, {Map<String, dynamic> params, Map<String, dynamic> queryParameters, NetMethod method = NetMethod.POST, bool cache = false}) async {
if (params == null) {
params = {};
}
@@ -113,6 +113,7 @@ class NetUtil {
path,
data: !EmptyUtil.isEmpty(bodyParams) ? bodyParams : null,
options: Options(method: enumToString(method), headers: headParam),
queryParameters: !EmptyUtil.isEmpty(queryParameters) ? queryParameters : null,
);
} on DioError catch (e) {
_formatError(e);
@@ -139,15 +140,14 @@ class NetUtil {
}

// 退出登陆
if(result[GlobalConfig.HTTP_RESPONSE_KEY_CODE]?.toString() == '401003'){
if (result[GlobalConfig.HTTP_RESPONSE_KEY_CODE]?.toString() == '401003') {
try {
Future.delayed(Duration(seconds: 0)).then((onValue) {
BuildContext context = navigatorKey.currentState.overlay.context;
Provider.of<UserInfoNotifier>(context, listen: false).unLogin();
});

}catch(e,s ){
Logger.error(e,s );
} catch (e, s) {
Logger.error(e, s);
}
}

@@ -159,7 +159,7 @@ class NetUtil {
}

/// 异步请求
static void request(String path, {NetMethod method = NetMethod.GET, Map<String, dynamic> params, OnSuccess onSuccess, OnError onError, OnCache onCache}) async {
static void request(String path, {NetMethod method = NetMethod.GET, Map<String, dynamic> params,Map<String, dynamic> queryParameters, OnSuccess onSuccess, OnError onError, OnCache onCache}) async {
if (params == null) {
params = {};
}
@@ -172,7 +172,7 @@ class NetUtil {
}

try {
Map result = await NetUtil.post(path, method: method, params: params);
Map result = await NetUtil.post(path, method: method, params: params, queryParameters: queryParameters);
// TODO 解密?
if (isSuccess(result)) {
if (onSuccess != null) {
@@ -351,10 +351,10 @@ class NetUtil {
}

/// 获取Android imei
static Future<String> _getImei() async{
try{
static Future<String> _getImei() async {
try {
return await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: true);
}catch(e, s){
} catch (e, s) {
Logger.error(e, s);
}
return null;


+ 5
- 0
lib/util/turn_chain/turn_chain_util.dart 查看文件

@@ -86,6 +86,7 @@ class TurnChainUtil {
} else if (!EmptyUtil.isEmpty(webUrl)) {
RouterUtil.openWebview(webUrl, context);
} else {
Fluttertoast.cancel();
Fluttertoast.showToast(msg: '购买链接不存在');
}

@@ -98,6 +99,7 @@ class TurnChainUtil {
} else if (!EmptyUtil.isEmpty(webUrl)) {
RouterUtil.openWebview(webUrl, context);
} else {
Fluttertoast.cancel();
Fluttertoast.showToast(msg: '购买链接不存在');
}
break;
@@ -117,11 +119,13 @@ class TurnChainUtil {
Logger.log('打开${provider} webUrl, url = ${webUrl}');
RouterUtil.openWebview(webUrl, context);
} else {
Fluttertoast.cancel();
Fluttertoast.showToast(msg: '购买链接不存在');
}
break;
}
} else {
Fluttertoast.cancel();
Fluttertoast.showToast(msg: '购买链接不存在');
}
}
@@ -154,6 +158,7 @@ class TurnChainUtil {
if (!EmptyUtil.isEmpty(result) && !EmptyUtil.isEmpty(result['open_app_url'])) {
return result;
}
Fluttertoast.cancel();
Fluttertoast.showToast(msg: '购买链接不存在');
return null;
}


Loading…
取消
儲存