Browse Source

0326 第三方登录绑定接口添加数据

tags/0.0.9+5
23028876916@qq.com 3 years ago
parent
commit
2e5d8359d4
6 changed files with 112 additions and 40 deletions
  1. +23
    -23
      example/pubspec.lock
  2. +1
    -0
      lib/models/user/user_info_model.dart
  3. +4
    -2
      lib/pages/login_page/bind/bloc/login_bind_phone_repository.dart
  4. +12
    -4
      lib/pages/login_page/bind/login_bind_phone_page.dart
  5. +71
    -10
      lib/pages/login_page/invite/bloc/login_invite_repository.dart
  6. +1
    -1
      lib/pages/login_page/invite/login_invite_page.dart

+ 23
- 23
example/pubspec.lock View File

@@ -100,7 +100,7 @@ packages:
name: device_info name: device_info
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.2+9"
version: "0.4.2+10"
device_info_platform_interface: device_info_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -191,7 +191,7 @@ packages:
name: flutter_native_image name: flutter_native_image
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.5+2"
version: "0.0.5+3"
flutter_screenutil: flutter_screenutil:
dependency: transitive dependency: transitive
description: description:
@@ -235,10 +235,10 @@ packages:
fluwx: fluwx:
dependency: transitive dependency: transitive
description: description:
path: "../../fluwx"
relative: true
source: path
version: "0.0.1"
name: fluwx
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.6.2"
http: http:
dependency: transitive dependency: transitive
description: description:
@@ -310,7 +310,7 @@ packages:
name: mobsms name: mobsms
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.2"
version: "1.1.3"
nested: nested:
dependency: transitive dependency: transitive
description: description:
@@ -324,7 +324,7 @@ packages:
name: package_info name: package_info
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.3"
version: "0.4.3+2"
path: path:
dependency: transitive dependency: transitive
description: description:
@@ -338,7 +338,7 @@ packages:
name: path_provider name: path_provider
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.6.21"
version: "1.6.27"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
@@ -352,21 +352,21 @@ packages:
name: path_provider_macos name: path_provider_macos
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.4+4"
version: "0.0.4+8"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: path_provider_platform_interface name: path_provider_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.3"
version: "1.0.4"
path_provider_windows: path_provider_windows:
dependency: transitive dependency: transitive
description: description:
name: path_provider_windows name: path_provider_windows
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.4+1"
version: "0.0.4+3"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@@ -456,21 +456,21 @@ packages:
name: shared_preferences name: shared_preferences
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.5.12+2"
version: "0.5.12+4"
shared_preferences_linux: shared_preferences_linux:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_linux name: shared_preferences_linux
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.2+2"
version: "0.0.2+4"
shared_preferences_macos: shared_preferences_macos:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_macos name: shared_preferences_macos
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+10"
version: "0.0.1+11"
shared_preferences_platform_interface: shared_preferences_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -491,7 +491,7 @@ packages:
name: shared_preferences_windows name: shared_preferences_windows
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+1"
version: "0.0.1+3"
sharesdk_plugin: sharesdk_plugin:
dependency: transitive dependency: transitive
description: description:
@@ -526,14 +526,14 @@ packages:
name: sqflite name: sqflite
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.1+1"
version: "1.3.1+2"
sqflite_common: sqflite_common:
dependency: transitive dependency: transitive
description: description:
name: sqflite_common name: sqflite_common
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.2+1"
version: "1.0.3"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@@ -598,21 +598,21 @@ packages:
name: url_launcher name: url_launcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "5.7.5"
version: "5.7.6"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_linux name: url_launcher_linux
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+1"
version: "0.0.1+4"
url_launcher_macos: url_launcher_macos:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_macos name: url_launcher_macos
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+8"
version: "0.0.1+9"
url_launcher_platform_interface: url_launcher_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -633,7 +633,7 @@ packages:
name: url_launcher_windows name: url_launcher_windows
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.0.1+1"
version: "0.0.1+3"
uuid: uuid:
dependency: transitive dependency: transitive
description: description:
@@ -661,7 +661,7 @@ packages:
name: win32 name: win32
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.7.3"
version: "1.7.4"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:


+ 1
- 0
lib/models/user/user_info_model.dart View File

@@ -12,6 +12,7 @@ class UserInfoModel {
String registerInviteCodeEnable; String registerInviteCodeEnable;
String bindPhoneEnable; String bindPhoneEnable;
bool isTBAuth; // 是否淘宝授权 bool isTBAuth; // 是否淘宝授权
String captcha;


// 获取模糊手机号码 // 获取模糊手机号码
get blurMobile => !EmptyUtil.isEmpty(mobile) ? mobile.length == 11 ? '${mobile.substring(0, 3)}****${mobile.substring(7, mobile.length)}' : mobile : mobile; get blurMobile => !EmptyUtil.isEmpty(mobile) ? mobile.length == 11 ? '${mobile.substring(0, 3)}****${mobile.substring(7, mobile.length)}' : mobile : mobile;


+ 4
- 2
lib/pages/login_page/bind/bloc/login_bind_phone_repository.dart View File

@@ -43,6 +43,7 @@ class LoginBindPhoneRepository {
params['mobile'] = event.mobile; params['mobile'] = event.mobile;
params['zone'] = '86'; params['zone'] = '86';
params['captcha'] = event.captcha; params['captcha'] = event.captcha;
params['version'] = "2";


/// 淘宝登录 /// 淘宝登录
if (GlobalConfig.LOGIN_THIRD_ALI == third) { if (GlobalConfig.LOGIN_THIRD_ALI == third) {
@@ -75,7 +76,7 @@ class LoginBindPhoneRepository {
qqParam['unionid'] = data['unionid']?.toString(); qqParam['unionid'] = data['unionid']?.toString();
params['wechat'] = qqParam; params['wechat'] = qqParam;
} }
/// QQ登录 /// QQ登录
if(GlobalConfig.LOGIN_THIRD_QQ == third){ if(GlobalConfig.LOGIN_THIRD_QQ == third){
Map<String, String> qqParam = {}; Map<String, String> qqParam = {};
@@ -87,12 +88,13 @@ class LoginBindPhoneRepository {
qqParam['unionid'] = data['unionid']?.toString(); qqParam['unionid'] = data['unionid']?.toString();
params['qq'] = qqParam; params['qq'] = qqParam;
} }
var result = await NetUtil.post('/api/v1/sign/fast/in', params: params); var result = await NetUtil.post('/api/v1/sign/fast/in', params: params);
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
UserInfoModel loginUser = UserInfoModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); UserInfoModel loginUser = UserInfoModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
if (null != loginUser) { if (null != loginUser) {
loginUser.mobile = event.mobile; loginUser.mobile = event.mobile;
loginUser.captcha = event.captcha;
return loginUser; return loginUser;
} }
} }


+ 12
- 4
lib/pages/login_page/bind/login_bind_phone_page.dart View File

@@ -33,7 +33,7 @@ class LoginBindPhonePage extends StatelessWidget {
backgroundColor: HexColor.fromHex('#FFFFFF'), backgroundColor: HexColor.fromHex('#FFFFFF'),
body: BlocProvider<LoginBindPhoneBloc>( body: BlocProvider<LoginBindPhoneBloc>(
create: (_) => LoginBindPhoneBloc(repository: LoginBindPhoneRepository(model))..add(LoginBindPhoneInitEvent()), create: (_) => LoginBindPhoneBloc(repository: LoginBindPhoneRepository(model))..add(LoginBindPhoneInitEvent()),
child: _LoginBindPhonePageContainer(),
child: _LoginBindPhonePageContainer(model: model,),
), ),
); );
} }
@@ -41,6 +41,10 @@ class LoginBindPhonePage extends StatelessWidget {


/// 啦啦啦 /// 啦啦啦
class _LoginBindPhonePageContainer extends StatefulWidget { class _LoginBindPhonePageContainer extends StatefulWidget {
final Map<String, dynamic> model;

const _LoginBindPhonePageContainer({Key key, this.model}) : super(key: key);

@override @override
_LoginBindPhonePageContainerState createState() => _LoginBindPhonePageContainerState(); _LoginBindPhonePageContainerState createState() => _LoginBindPhonePageContainerState();
} }
@@ -60,10 +64,14 @@ class _LoginBindPhonePageContainerState extends State<_LoginBindPhonePageContain
bool _isLogging = false; bool _isLogging = false;


/// 跳转到邀请码页面 /// 跳转到邀请码页面
void _openInvitePage(String mobile) {
void _openInvitePage(String mobile,String captcha) {
print('跳转到邀请码页面'); print('跳转到邀请码页面');
RouterUtil.hideKeyboard(context); RouterUtil.hideKeyboard(context);
Navigator.push(context, CupertinoPageRoute(builder: (_) => LoginInvitePage({'mobile': mobile})));
Map<String, dynamic> data=widget.model;
data['mobile']=mobile;
data['captcha']=captcha;

Navigator.push(context, CupertinoPageRoute(builder: (_) => LoginInvitePage(data)));
} }


/// 登陆成功页面 /// 登陆成功页面
@@ -236,7 +244,7 @@ class _LoginBindPhonePageContainerState extends State<_LoginBindPhonePageContain
_openLoginSuccessPage(); _openLoginSuccessPage();
} else { } else {
/// 打开邀请页面 /// 打开邀请页面
_openInvitePage(current?.model?.mobile);
_openInvitePage(current?.model?.mobile,current?.model?.captcha);
} }
return false; return false;
} }


+ 71
- 10
lib/pages/login_page/invite/bloc/login_invite_repository.dart View File

@@ -11,6 +11,9 @@ import 'bloc.dart';
class LoginInviteRepository { class LoginInviteRepository {
LoginStyleModel pageModel; LoginStyleModel pageModel;
LoginInviteUser lastInviteUser; LoginInviteUser lastInviteUser;
final Map<String, dynamic> data;

LoginInviteRepository(this.data);


/// 获取数据,如果缓存有,则获取缓存的数据 /// 获取数据,如果缓存有,则获取缓存的数据
Future<LoginStyleModel> fetchData() async { Future<LoginStyleModel> fetchData() async {
@@ -24,9 +27,12 @@ class LoginInviteRepository {
/// 获取邀请人信息 /// 获取邀请人信息
Future<LoginInviteUser> fetchInviteUserInfo(LoginInviteQueryEvent event) async { Future<LoginInviteUser> fetchInviteUserInfo(LoginInviteQueryEvent event) async {
try { try {
var result = await NetUtil.post('/api/v1/user/invite/${event.num}', method: NetMethod.GET, showToast: false);
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
LoginInviteUser model = LoginInviteUser.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
var result = await NetUtil.post('/api/v1/user/invite/${event.num}',
method: NetMethod.GET, showToast: false);
if (NetUtil.isSuccess(result) &&
!EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
LoginInviteUser model =
LoginInviteUser.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
lastInviteUser = model; lastInviteUser = model;
return model; return model;
} }
@@ -38,14 +44,69 @@ class LoginInviteRepository {


/// 提交 /// 提交
Future<UserInfoModel> submitInvite(LoginInviteSubmitEvent event) async { Future<UserInfoModel> submitInvite(LoginInviteSubmitEvent event) async {
Logger.log("提交的数据");
Logger.log(data);
try { try {
var result = await NetUtil.post('/api/v1/user/invite/ack', params: {
'mobile': event.mobile,
'zone': '86',
'parent_uid': event.num,
});
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
UserInfoModel model = UserInfoModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
Map<String, dynamic> params = {};
params['mobile'] = event.mobile;
params['zone'] = '86';
params['parent_uid'] = event.num;

if(!EmptyUtil.isEmpty(data['captcha'])){
params['captcha'] = data['captcha'];
}
if (!EmptyUtil.isEmpty(data)) {
String third = data['thirdType'];

/// 淘宝登录
if (GlobalConfig.LOGIN_THIRD_ALI == third) {
Map<String, String> taobaoParam = {};
taobaoParam['nick_name'] = data['nick'];
taobaoParam['avatar_url'] = data['avatarUrl'];
taobaoParam['open_id'] = data['openId'];
taobaoParam['sid'] = data['openSid'];
taobaoParam['access_token'] = data['topAccessToken'];
taobaoParam['auth_code'] = data['topAuthCode'];
params['taobao'] = taobaoParam;
}

/// 苹果登录
if (GlobalConfig.LOGIN_THIRD_APPLE == third) {
// identityTokenStr
Map<String, String> appleParam = {};
appleParam['token'] = data['identityTokenStr'];
params['apple'] = appleParam;
}

/// 微信登录
if (GlobalConfig.LOGIN_THIRD_WECHAT == third) {
Map<String, String> qqParam = {};
qqParam['nickname'] = data['nickname']?.toString();
qqParam['gender'] = data['gender']?.toString();
qqParam['avatar_url'] = data['avatar_url']?.toString();
qqParam['open_id'] = data['open_id']?.toString();
qqParam['token'] = data['token']?.toString();
qqParam['unionid'] = data['unionid']?.toString();
params['wechat'] = qqParam;
}

/// QQ登录
if (GlobalConfig.LOGIN_THIRD_QQ == third) {
Map<String, String> qqParam = {};
qqParam['nickname'] = data['nickname']?.toString();
qqParam['gender'] = data['gender']?.toString();
qqParam['avatar_url'] = data['avatar_url']?.toString();
qqParam['open_id'] = data['open_id']?.toString();
qqParam['token'] = data['token']?.toString();
qqParam['unionid'] = data['unionid']?.toString();
params['qq'] = qqParam;
}
}
var result = await NetUtil.post('/api/v1/user/invite/ack', params: params);
if (NetUtil.isSuccess(result) &&
!EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
UserInfoModel model =
UserInfoModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
if (null != model) { if (null != model) {
model.mobile = event.mobile; model.mobile = event.mobile;
return model; return model;


+ 1
- 1
lib/pages/login_page/invite/login_invite_page.dart View File

@@ -26,7 +26,7 @@ class LoginInvitePage extends StatelessWidget {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: HexColor.fromHex('#FFFFFF'), backgroundColor: HexColor.fromHex('#FFFFFF'),
body: BlocProvider( body: BlocProvider(
create: (_) => LoginInviteBloc(repostitory: LoginInviteRepository())..add(LoginInviteInitEvent()),
create: (_) => LoginInviteBloc(repostitory: LoginInviteRepository(data))..add(LoginInviteInitEvent()),
child: LoginInvitePageContainer(this.data), child: LoginInvitePageContainer(this.data),
), ),
); );


Loading…
Cancel
Save