@@ -58,18 +58,18 @@ class LoginAccountBloc extends Bloc<LoginAccountEvent, LoginAccountState> { | |||||
Stream<LoginAccountState> _mapLoginTypeVcodeEventToState(LoginAccountTypeVcodeEvent event) async* { | Stream<LoginAccountState> _mapLoginTypeVcodeEventToState(LoginAccountTypeVcodeEvent event) async* { | ||||
var result = await repository.loginTypeVcode(event); | var result = await repository.loginTypeVcode(event); | ||||
if (!EmptyUtil.isEmpty(result)) | if (!EmptyUtil.isEmpty(result)) | ||||
yield LoginAccountTypeVcodeLoginSuccessState(model: result); | |||||
yield LoginAccountLoginSuccessState(model: result); | |||||
else | else | ||||
yield LoginAccountTypeVcodeLoginErrorState(); | |||||
yield LoginAccountLoginErrorState(); | |||||
} | } | ||||
/// 密码登陆 | /// 密码登陆 | ||||
Stream<LoginAccountState> _mapLoginTypePassEventToState(LoginAccountTypePasswordEvent event) async* { | Stream<LoginAccountState> _mapLoginTypePassEventToState(LoginAccountTypePasswordEvent event) async* { | ||||
var result = await repository.loginTypePass(event); | var result = await repository.loginTypePass(event); | ||||
if(!EmptyUtil.isEmpty(result)) | if(!EmptyUtil.isEmpty(result)) | ||||
yield LoginAccountTypeVcodeLoginSuccessState(model: result); | |||||
yield LoginAccountLoginSuccessState(model: result); | |||||
else | else | ||||
yield LoginAccountTypeVcodeLoginErrorState(); | |||||
yield LoginAccountLoginErrorState(); | |||||
} | } | ||||
} | } |
@@ -43,19 +43,19 @@ class LoginAccountGetVcodeErrorState extends LoginAccountState { | |||||
const LoginAccountGetVcodeErrorState({this.msg}); | const LoginAccountGetVcodeErrorState({this.msg}); | ||||
} | } | ||||
/// 验证码登陆成功 | |||||
class LoginAccountTypeVcodeLoginSuccessState extends LoginAccountState { | |||||
/// 登陆成功 | |||||
class LoginAccountLoginSuccessState extends LoginAccountState { | |||||
final UserInfoModel model; | final UserInfoModel model; | ||||
const LoginAccountTypeVcodeLoginSuccessState({@required this.model}); | |||||
const LoginAccountLoginSuccessState({@required this.model}); | |||||
@override | @override | ||||
List<Object> get props => [this.model]; | List<Object> get props => [this.model]; | ||||
} | } | ||||
/// 验证码登陆失败 | |||||
class LoginAccountTypeVcodeLoginErrorState extends LoginAccountState { | |||||
/// 登陆失败 | |||||
class LoginAccountLoginErrorState extends LoginAccountState { | |||||
final String msg; | final String msg; | ||||
const LoginAccountTypeVcodeLoginErrorState({this.msg}); | |||||
} | |||||
const LoginAccountLoginErrorState({this.msg}); | |||||
} |
@@ -52,6 +52,8 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i | |||||
FocusNode _phoneFN; | FocusNode _phoneFN; | ||||
FocusNode _passFN; | FocusNode _passFN; | ||||
FocusNode _vcodeFN; | FocusNode _vcodeFN; | ||||
// 是否登录中 | |||||
bool _isLogging = false; | |||||
/// 跳转到邀请码页面 | /// 跳转到邀请码页面 | ||||
void _openInvitePage() { | void _openInvitePage() { | ||||
@@ -67,11 +69,7 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i | |||||
/// 登陆成功页面 | /// 登陆成功页面 | ||||
void _openLoginSuccessPage() { | void _openLoginSuccessPage() { | ||||
RouterUtil.hideKeyboard(context); | 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() { | void _submitOnClick() { | ||||
print('登陆'); | print('登陆'); | ||||
if (_checkParam(true)) { | |||||
if (_checkParam(true) && !_isLogging) { | |||||
setState(() { | |||||
_isLogging = true; | |||||
}); | |||||
if (_useVcode) { | 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 { | } 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) { | Widget build(BuildContext context) { | ||||
return BlocConsumer<LoginAccountBloc, LoginAccountState>( | return BlocConsumer<LoginAccountBloc, LoginAccountState>( | ||||
listener: (context, state) { | listener: (context, state) { | ||||
if (state is LoginAccountTypeVcodeLoginSuccessState) {} | |||||
if (state is LoginAccountLoginSuccessState) {} | |||||
}, | }, | ||||
buildWhen: (prev, current) { | buildWhen: (prev, current) { | ||||
// 验证码登陆失败 | |||||
if (current is LoginAccountTypeVcodeLoginErrorState) { | |||||
// 登陆失败 | |||||
if (current is LoginAccountLoginErrorState) { | |||||
// Fluttertoast.showToast(msg: '登陆失败'); | // Fluttertoast.showToast(msg: '登陆失败'); | ||||
setState(() { | |||||
_isLogging = false; | |||||
}); | |||||
return false; | return false; | ||||
} | } | ||||
// 验证码登陆成功 | |||||
if (current is LoginAccountTypeVcodeLoginSuccessState) { | |||||
// 登陆成功 | |||||
if (current is LoginAccountLoginSuccessState) { | |||||
/// 缓存登陆数据 | /// 缓存登陆数据 | ||||
Provider.of<UserInfoNotifier>(context, listen: false)?.setUserInfo(current.model); | Provider.of<UserInfoNotifier>(context, listen: false)?.setUserInfo(current.model); | ||||
if (current?.model?.registerInviteCodeEnable != '1') { | if (current?.model?.registerInviteCodeEnable != '1') { | ||||
@@ -327,7 +332,7 @@ class _LoginAccountPageContianerState extends State<LoginAccountPageContianer> i | |||||
/// 切换登陆方式tip | /// 切换登陆方式tip | ||||
Padding(padding: const EdgeInsets.only(top: 15), child: _getChangeTipWidget(model)), | 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)), | 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, | color: Colors.white, | ||||
child: RaisedButton( | child: RaisedButton( | ||||
child: Text( | child: Text( | ||||
model?.mobile?.btnLoginText ?? '立即登录', | |||||
_isLogging ? '登录中...' : model?.mobile?.btnLoginText ?? '立即登录', | |||||
style: TextStyle(fontSize: 15), | style: TextStyle(fontSize: 15), | ||||
), | ), | ||||
textColor: HexColor.fromHex(model?.mobile?.btnLoginTextColor ?? '#FFFFFF'), | textColor: HexColor.fromHex(model?.mobile?.btnLoginTextColor ?? '#FFFFFF'), | ||||
@@ -39,6 +39,9 @@ class _LoginInvitePageContainerState extends State<LoginInvitePageContainer> { | |||||
FocusNode _focusNode; | FocusNode _focusNode; | ||||
bool _showInviteInfo = false; | bool _showInviteInfo = false; | ||||
// 是否登录中 | |||||
bool _isLogging = false; | |||||
/// 返回上一页 | /// 返回上一页 | ||||
void _openPop() { | void _openPop() { | ||||
if (Navigator.canPop(context)) { | if (Navigator.canPop(context)) { | ||||
@@ -93,7 +93,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) { | if (params == null) { | ||||
params = {}; | params = {}; | ||||
} | } | ||||
@@ -112,6 +112,7 @@ class NetUtil { | |||||
path, | path, | ||||
data: !EmptyUtil.isEmpty(bodyParams) ? bodyParams : null, | data: !EmptyUtil.isEmpty(bodyParams) ? bodyParams : null, | ||||
options: Options(method: enumToString(method), headers: headParam), | options: Options(method: enumToString(method), headers: headParam), | ||||
queryParameters: !EmptyUtil.isEmpty(queryParameters) ? queryParameters : null, | |||||
); | ); | ||||
} on DioError catch (e) { | } on DioError catch (e) { | ||||
_formatError(e); | _formatError(e); | ||||
@@ -138,15 +139,14 @@ class NetUtil { | |||||
} | } | ||||
// 退出登陆 | // 退出登陆 | ||||
if(result[GlobalConfig.HTTP_RESPONSE_KEY_CODE]?.toString() == '401003'){ | |||||
if (result[GlobalConfig.HTTP_RESPONSE_KEY_CODE]?.toString() == '401003') { | |||||
try { | try { | ||||
Future.delayed(Duration(seconds: 0)).then((onValue) { | Future.delayed(Duration(seconds: 0)).then((onValue) { | ||||
BuildContext context = navigatorKey.currentState.overlay.context; | BuildContext context = navigatorKey.currentState.overlay.context; | ||||
Provider.of<UserInfoNotifier>(context, listen: false).unLogin(); | Provider.of<UserInfoNotifier>(context, listen: false).unLogin(); | ||||
}); | }); | ||||
}catch(e,s ){ | |||||
Logger.error(e,s ); | |||||
} catch (e, s) { | |||||
Logger.error(e, s); | |||||
} | } | ||||
} | } | ||||
@@ -158,7 +158,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) { | if (params == null) { | ||||
params = {}; | params = {}; | ||||
} | } | ||||
@@ -171,7 +171,7 @@ class NetUtil { | |||||
} | } | ||||
try { | try { | ||||
Map result = await NetUtil.post(path, method: method, params: params); | |||||
Map result = await NetUtil.post(path, method: method, params: params, queryParameters: queryParameters); | |||||
// TODO 解密? | // TODO 解密? | ||||
if (isSuccess(result)) { | if (isSuccess(result)) { | ||||
if (onSuccess != null) { | if (onSuccess != null) { | ||||
@@ -291,7 +291,6 @@ class NetUtil { | |||||
// idfa | // idfa | ||||
params['idfa'] = iosInfo?.identifierForVendor?.toString(); | params['idfa'] = iosInfo?.identifierForVendor?.toString(); | ||||
} else if (Platform.isAndroid) { | } else if (Platform.isAndroid) { | ||||
AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo; | AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo; | ||||
// 设备 | // 设备 | ||||
@@ -349,10 +348,10 @@ class NetUtil { | |||||
} | } | ||||
/// 获取Android imei | /// 获取Android imei | ||||
static Future<String> _getImei() async{ | |||||
try{ | |||||
static Future<String> _getImei() async { | |||||
try { | |||||
return await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: true); | return await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: true); | ||||
}catch(e, s){ | |||||
} catch (e, s) { | |||||
Logger.error(e, s); | Logger.error(e, s); | ||||
} | } | ||||
return null; | return null; | ||||
@@ -86,6 +86,7 @@ class TurnChainUtil { | |||||
} else if (!EmptyUtil.isEmpty(webUrl)) { | } else if (!EmptyUtil.isEmpty(webUrl)) { | ||||
RouterUtil.openWebview(webUrl, context); | RouterUtil.openWebview(webUrl, context); | ||||
} else { | } else { | ||||
Fluttertoast.cancel(); | |||||
Fluttertoast.showToast(msg: '购买链接不存在'); | Fluttertoast.showToast(msg: '购买链接不存在'); | ||||
} | } | ||||
@@ -98,6 +99,7 @@ class TurnChainUtil { | |||||
} else if (!EmptyUtil.isEmpty(webUrl)) { | } else if (!EmptyUtil.isEmpty(webUrl)) { | ||||
RouterUtil.openWebview(webUrl, context); | RouterUtil.openWebview(webUrl, context); | ||||
} else { | } else { | ||||
Fluttertoast.cancel(); | |||||
Fluttertoast.showToast(msg: '购买链接不存在'); | Fluttertoast.showToast(msg: '购买链接不存在'); | ||||
} | } | ||||
break; | break; | ||||
@@ -117,11 +119,13 @@ class TurnChainUtil { | |||||
Logger.log('打开${provider} webUrl, url = ${webUrl}'); | Logger.log('打开${provider} webUrl, url = ${webUrl}'); | ||||
RouterUtil.openWebview(webUrl, context); | RouterUtil.openWebview(webUrl, context); | ||||
} else { | } else { | ||||
Fluttertoast.cancel(); | |||||
Fluttertoast.showToast(msg: '购买链接不存在'); | Fluttertoast.showToast(msg: '购买链接不存在'); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} else { | } else { | ||||
Fluttertoast.cancel(); | |||||
Fluttertoast.showToast(msg: '购买链接不存在'); | Fluttertoast.showToast(msg: '购买链接不存在'); | ||||
} | } | ||||
} | } | ||||
@@ -154,6 +158,7 @@ class TurnChainUtil { | |||||
if (!EmptyUtil.isEmpty(result) && !EmptyUtil.isEmpty(result['open_app_url'])) { | if (!EmptyUtil.isEmpty(result) && !EmptyUtil.isEmpty(result['open_app_url'])) { | ||||
return result; | return result; | ||||
} | } | ||||
Fluttertoast.cancel(); | |||||
Fluttertoast.showToast(msg: '购买链接不存在'); | Fluttertoast.showToast(msg: '购买链接不存在'); | ||||
return null; | return null; | ||||
} | } | ||||