ソースを参照

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

tags/0.0.9+5
23028876916@qq.com 3年前
コミット
2e5d8359d4
6個のファイルの変更112行の追加40行の削除
  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 ファイルの表示

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


+ 1
- 0
lib/models/user/user_info_model.dart ファイルの表示

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

// 获取模糊手机号码
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 ファイルの表示

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

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


+ 12
- 4
lib/pages/login_page/bind/login_bind_phone_page.dart ファイルの表示

@@ -33,7 +33,7 @@ class LoginBindPhonePage extends StatelessWidget {
backgroundColor: HexColor.fromHex('#FFFFFF'),
body: BlocProvider<LoginBindPhoneBloc>(
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 {
final Map<String, dynamic> model;

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

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

/// 跳转到邀请码页面
void _openInvitePage(String mobile) {
void _openInvitePage(String mobile,String captcha) {
print('跳转到邀请码页面');
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();
} else {
/// 打开邀请页面
_openInvitePage(current?.model?.mobile);
_openInvitePage(current?.model?.mobile,current?.model?.captcha);
}
return false;
}


+ 71
- 10
lib/pages/login_page/invite/bloc/login_invite_repository.dart ファイルの表示

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

LoginInviteRepository(this.data);

/// 获取数据,如果缓存有,则获取缓存的数据
Future<LoginStyleModel> fetchData() async {
@@ -24,9 +27,12 @@ class LoginInviteRepository {
/// 获取邀请人信息
Future<LoginInviteUser> fetchInviteUserInfo(LoginInviteQueryEvent event) async {
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;
return model;
}
@@ -38,14 +44,69 @@ class LoginInviteRepository {

/// 提交
Future<UserInfoModel> submitInvite(LoginInviteSubmitEvent event) async {
Logger.log("提交的数据");
Logger.log(data);
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) {
model.mobile = event.mobile;
return model;


+ 1
- 1
lib/pages/login_page/invite/login_invite_page.dart ファイルの表示

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


読み込み中…
キャンセル
保存