Commit ea2c8205a2744ab6c563b2421cbe60268ecaf14e
1 parent
23384a42
feat:更新代码
Showing
7 changed files
with
9 additions
and
7 deletions
lib/login/loginpage/bloc/login_bloc.dart
@@ -42,19 +42,19 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | @@ -42,19 +42,19 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | ||
42 | 42 | ||
43 | ///请求登陆 | 43 | ///请求登陆 |
44 | void _requestLoginApi(RequestLoginEvent event, Emitter<LoginState> emitter) async { | 44 | void _requestLoginApi(RequestLoginEvent event, Emitter<LoginState> emitter) async { |
45 | - DioUtil().requestData( | 45 | + await DioUtil().requestData( |
46 | Api.login, | 46 | Api.login, |
47 | + method: HttpMethod.post, | ||
47 | data: { | 48 | data: { |
48 | 'phoneNum':'17730280759', | 49 | 'phoneNum':'17730280759', |
49 | 'type':_loginType.toString(), | 50 | 'type':_loginType.toString(), |
50 | 'password':'asd123456'}, | 51 | 'password':'asd123456'}, |
51 | successCallBack: (data){ | 52 | successCallBack: (data){ |
52 | - | 53 | + emitter(LoginResultChangeState(true)); |
53 | }, | 54 | }, |
54 | errorCallBack: (error){ | 55 | errorCallBack: (error){ |
55 | - | 56 | + emitter(LoginResultChangeState(false)); |
56 | }); | 57 | }); |
57 | - // emitter(LoginResultChangeState()); | ||
58 | } | 58 | } |
59 | 59 | ||
60 | ///切换登陆方式 | 60 | ///切换登陆方式 |
lib/login/loginpage/bloc/login_state.dart
@@ -14,5 +14,6 @@ class SmsSendTypeChangeState extends LoginState {} | @@ -14,5 +14,6 @@ class SmsSendTypeChangeState extends LoginState {} | ||
14 | class AgreementTypeChangeState extends LoginState {} | 14 | class AgreementTypeChangeState extends LoginState {} |
15 | ///登陆请求结果 | 15 | ///登陆请求结果 |
16 | class LoginResultChangeState extends LoginState { | 16 | class LoginResultChangeState extends LoginState { |
17 | - | 17 | + bool result = false; |
18 | + LoginResultChangeState(this.result); | ||
18 | } | 19 | } |
lib/modes/response_model.dart renamed to lib/models/response_model.dart
lib/modes/response_model.g.dart renamed to lib/models/response_model.g.dart
lib/modes/test_model.dart renamed to lib/models/test_model.dart
lib/modes/test_model.g.dart renamed to lib/models/test_model.g.dart
lib/network/network_manager.dart
@@ -3,9 +3,9 @@ import 'dart:io'; | @@ -3,9 +3,9 @@ import 'dart:io'; | ||
3 | import 'package:dio/dio.dart'; | 3 | import 'package:dio/dio.dart'; |
4 | import 'package:flutter/foundation.dart'; | 4 | import 'package:flutter/foundation.dart'; |
5 | import 'package:flutter_easyloading/flutter_easyloading.dart'; | 5 | import 'package:flutter_easyloading/flutter_easyloading.dart'; |
6 | +import 'package:wow_english/models/response_model.dart'; | ||
6 | import 'package:wow_english/network/basic_configuration.dart'; | 7 | import 'package:wow_english/network/basic_configuration.dart'; |
7 | 8 | ||
8 | -import '../modes/response_model.dart'; | ||
9 | 9 | ||
10 | enum HttpMethod { | 10 | enum HttpMethod { |
11 | get, | 11 | get, |
@@ -37,12 +37,13 @@ class DioUtil { | @@ -37,12 +37,13 @@ class DioUtil { | ||
37 | Future<void> requestData<T>( | 37 | Future<void> requestData<T>( |
38 | String path, { | 38 | String path, { |
39 | data, | 39 | data, |
40 | - HttpMethod method = HttpMethod.post, | 40 | + // HttpMethod method = HttpMethod.post, |
41 | Map<String, dynamic>? queryParameters, | 41 | Map<String, dynamic>? queryParameters, |
42 | ProgressCallback? onSendProgress, | 42 | ProgressCallback? onSendProgress, |
43 | ProgressCallback? onReceiveProgress, | 43 | ProgressCallback? onReceiveProgress, |
44 | required Function successCallBack, | 44 | required Function successCallBack, |
45 | required Function errorCallBack, | 45 | required Function errorCallBack, |
46 | + required HttpMethod method, | ||
46 | }) async{ | 47 | }) async{ |
47 | try { | 48 | try { |
48 | Map<String, dynamic> headers = <String, dynamic>{}; | 49 | Map<String, dynamic> headers = <String, dynamic>{}; |