@@ -5,6 +5,7 @@ import 'package:flutter_alibc/flutter_alibc.dart'; | |||
import 'package:zhiying_comm/models/user/user_info_model.dart'; | |||
import 'package:zhiying_comm/util/global_config.dart'; | |||
import 'package:zhiying_comm/util/log/let_log.dart'; | |||
import 'package:zhiying_comm/util/mob_util/mob_util.dart'; | |||
import 'package:zhiying_comm/util/shared_prefe_util.dart'; | |||
/// | |||
@@ -74,6 +75,8 @@ class UserInfoNotifier with ChangeNotifier { | |||
GlobalConfig.SHARED_KEY_USER_INFO, ''); | |||
// 退出淘宝登录 | |||
FlutterAlibc.loginOut(); | |||
// 退出QQ登录 | |||
MobUtil.cancelQQAuth(); | |||
notifyListeners(); | |||
} | |||
@@ -60,7 +60,19 @@ class LoginBindPhoneRepository { | |||
if(GlobalConfig.LOGIN_THIRD_APPLE == third){ | |||
} | |||
/// 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/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]); | |||
@@ -76,7 +76,14 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | |||
Stream<LoginState> _mapLoginWeChatEventToState(LoginThirdWeChatEvent event) async* {} | |||
/// QQ 登录 | |||
Stream<LoginState> _mapLoginQQEventToState(LoginThirdQQEvent event) async* {} | |||
Stream<LoginState> _mapLoginQQEventToState(LoginThirdQQEvent event) async* { | |||
var result = await repository.qqLogin(event?.model); | |||
if(!EmptyUtil.isEmpty(result)){ | |||
yield LoginThirdLoginSuccessState(model: result, thirdType: GlobalConfig.LOGIN_THIRD_QQ); | |||
}else{ | |||
yield LoginThirdLoginErrorState(); | |||
} | |||
} | |||
/// 苹果登录 | |||
Stream<LoginState> _mapLoginAppleEventToState(LoginThirdAppleEvent event) async* {} | |||
@@ -1,4 +1,5 @@ | |||
import 'package:equatable/equatable.dart'; | |||
import 'package:flutter/cupertino.dart'; | |||
abstract class LoginEvent extends Equatable { | |||
const LoginEvent(); | |||
@@ -35,4 +36,11 @@ class LoginThirdAppleEvent extends LoginEvent {} | |||
class LoginThirdWeChatEvent extends LoginEvent {} | |||
/// 第三方登录:QQ登录 | |||
class LoginThirdQQEvent extends LoginEvent {} | |||
class LoginThirdQQEvent extends LoginEvent { | |||
final Map<dynamic, dynamic> model; | |||
LoginThirdQQEvent({@required this.model}); | |||
@override | |||
List<Object> get props => [this.model]; | |||
} |
@@ -53,7 +53,31 @@ class LoginRepository { | |||
} | |||
/// QQ 登录 | |||
Future<UserInfoModel> qqLogin() async { | |||
Future<UserInfoModel> qqLogin(final Map<dynamic, dynamic> data) async { | |||
try { | |||
var dbInfo = jsonDecode(data['dbInfo']); | |||
Map<String, String> params = {}; | |||
params['nickname'] = dbInfo['nickname']?.toString(); | |||
params['gender'] = dbInfo['gender']?.toString() == '0' ? '1' : '2'; | |||
params['avatar_url'] = dbInfo['icon']?.toString(); | |||
params['open_id'] = dbInfo['userID']?.toString(); | |||
params['unionid'] = dbInfo['unionid']?.toString(); | |||
params['token'] = dbInfo['token']?.toString(); | |||
var result = await NetUtil.post( | |||
'/api/v1/sign/fast/in', | |||
params: {'qq': params}, | |||
queryParameters: {'third_party_login': 'qq'}, | |||
method: NetMethod.POST, | |||
); | |||
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | |||
return UserInfoModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); | |||
} | |||
} catch (e, s) { | |||
Logger.error(e, s); | |||
} | |||
return null; | |||
} | |||
} |
@@ -1,3 +1,5 @@ | |||
import 'dart:convert'; | |||
import 'package:cached_network_image/cached_network_image.dart'; | |||
import 'package:flutter/cupertino.dart'; | |||
import 'package:flutter/gestures.dart'; | |||
@@ -6,6 +8,7 @@ import 'package:flutter_alibc/alibc_model.dart'; | |||
import 'package:flutter_alibc/flutter_alibc.dart'; | |||
import 'package:flutter_bloc/flutter_bloc.dart'; | |||
import 'package:fluttertoast/fluttertoast.dart'; | |||
import 'package:sharesdk_plugin/sharesdk_plugin.dart'; | |||
import 'package:zhiying_comm/pages/login_page/account/login_account_page.dart'; | |||
import 'package:zhiying_comm/pages/login_page/bind/login_bind_phone_page.dart'; | |||
import 'package:zhiying_comm/util/dialog/loading/loading.dart'; | |||
@@ -44,7 +47,7 @@ class LoginPageContainer extends StatefulWidget { | |||
class _LoginPageContainerState extends State<LoginPageContainer> { | |||
LoginModel _taoBao; | |||
var _qqUserData; | |||
/// 微信or手机登陆 | |||
void _loginClick(String type, LoginStyleModel model) { | |||
print('登陆$type'); | |||
@@ -58,9 +61,12 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||
} | |||
} else if ('wechat' == type) { | |||
/// 微信登录 | |||
// fluwx.sendWeChatAuth(scope: "snsapi_userinfo", state: "wechat_sdk_demo_test").then((data) { | |||
// Logger.debug('返回数据: ${data?.toString()}'); | |||
// }); | |||
Loading.show(context); | |||
SharesdkPlugin.getUserInfo(ShareSDKPlatforms.wechatSession, (SSDKResponseState state, Map user, SSDKError error) { | |||
if(state == SSDKResponseState.Success){ | |||
} | |||
}); | |||
Fluttertoast.showToast(msg: '暂不支持~'); | |||
} | |||
} | |||
@@ -72,10 +78,11 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||
Fluttertoast.showToast(msg: '暂不支持~'); | |||
return; | |||
} | |||
Loading.show(context); | |||
/// 淘宝登录 | |||
if ('taobao' == model.type) { | |||
Loading.show(context); | |||
_taoBao = await FlutterAlibc.loginTaoBao(); | |||
if (!EmptyUtil.isEmpty(_taoBao) && !EmptyUtil.isEmpty(_taoBao?.errorCode) && _taoBao.errorCode == '0') { | |||
BlocProvider.of<LoginBloc>(context).add(LoginThirdAliEvent( | |||
@@ -89,11 +96,25 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||
// 'avatar = ${_taoBao?.data?.avatarUrl}, openId = ${_taoBao?.data?.openId}, openSid = ${_taoBao?.data?.openSid}, ' | |||
// 'topAccessToken = ${_taoBao?.data?.topAccessToken}, topAuthCode = ${_taoBao?.data?.topAuthCode}'); | |||
} | |||
Loading.dismiss(); | |||
} | |||
/// QQ登录 | |||
if ('qq' == model.type) { | |||
Fluttertoast.showToast(msg: '暂不支持~'); | |||
Loading.show(context); | |||
SharesdkPlugin.getUserInfo(ShareSDKPlatforms.qq, (SSDKResponseState state, Map userdata, SSDKError error) { | |||
Logger.log('state = ${state?.toString()}\nuserData = ${userdata?.toString()}'); | |||
if (state == SSDKResponseState.Success && !EmptyUtil.isEmpty(userdata)) { | |||
try{ | |||
_qqUserData = jsonDecode(userdata['dbInfo']);; | |||
}catch(e){} | |||
BlocProvider.of<LoginBloc>(context).add(LoginThirdQQEvent(model: userdata)); | |||
Loading.dismiss(); | |||
} else { | |||
Loading.dismiss(); | |||
} | |||
}); | |||
// Fluttertoast.showToast(msg: '暂不支持~'); | |||
} | |||
/// 苹果登录 | |||
@@ -101,7 +122,7 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||
Fluttertoast.showToast(msg: '暂不支持~'); | |||
} | |||
Loading.dismiss(); | |||
} | |||
/// 跳到用户协议 | |||
@@ -129,6 +150,24 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||
'topAuthCode': _taoBao?.data?.topAuthCode, | |||
}))); | |||
} | |||
/// 如果是QQ登录 | |||
if(GlobalConfig.LOGIN_THIRD_QQ == thirdType) { | |||
if (!EmptyUtil.isEmpty(_qqUserData)) { | |||
Navigator.push( | |||
context, | |||
CupertinoPageRoute( | |||
builder: (_) => | |||
LoginBindPhonePage({ | |||
'thirdType': thirdType, | |||
'nickname': _qqUserData['nickname']?.toString(), | |||
'avatar_url': _qqUserData['icon']?.toString(), | |||
'open_id': _qqUserData['userID']?.toString(), | |||
'gender': _qqUserData['gender']?.toString() == '0' ? '1' : '2', | |||
'unionid': _qqUserData['unionid']?.toString(), | |||
'token': _qqUserData['token']?.toString(), | |||
}))); | |||
} | |||
} | |||
} | |||
/// 跳到首页 | |||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; | |||
import 'package:mobsms/mobsms.dart'; | |||
import 'package:sharesdk_plugin/sharesdk_plugin.dart'; | |||
import 'package:zhiying_comm/pages/login_page/model/login_style_model.dart'; | |||
import 'package:zhiying_comm/util/dialog/loading/loading.dart'; | |||
import 'package:zhiying_comm/util/empty_util.dart'; | |||
import 'package:zhiying_comm/util/enum_util.dart'; | |||
import 'package:zhiying_comm/util/global_config.dart'; | |||
@@ -23,6 +24,27 @@ class MobUtil { | |||
QuickLoginUtil.getInstance().init(); | |||
} | |||
/// | |||
/// 退出QQ登录 | |||
/// | |||
static void cancelQQAuth(){ | |||
SharesdkPlugin.cancelAuth(ShareSDKPlatforms.qq, (SSDKResponseState state, Map user, SSDKError error) { | |||
Logger.debug('state = ${state}\n rawData = ${error?.rawData?.toString()}'); | |||
}); | |||
} | |||
/// | |||
/// 取消授权 | |||
/// | |||
static void cancelAuth(ShareSDKPlatform platform) { | |||
SharesdkPlugin.cancelAuth(platform, (SSDKResponseState state, Map user, SSDKError error) { | |||
// showAlert(state, error.rawData, context); | |||
Logger.debug('state = ${state}\n rawData = ${error?.rawData?.toString()}'); | |||
}); | |||
} | |||
/// | |||
/// 打开秒验页面 | |||
/// | |||
@@ -64,9 +86,6 @@ class MobUtil { | |||
return Future.value(result); | |||
} | |||
/// 询问验证码是否可以下发 | |||
static Future<String> _getSMSStrategy(final String phone, {SMSCodeType type = SMSCodeType.NORMAL}) async { | |||
try { | |||
@@ -74,12 +93,9 @@ class MobUtil { | |||
if (EmptyUtil.isEmpty(vCodeType)) { | |||
vCodeType = enumToString(SMSCodeType.NORMAL).toLowerCase(); | |||
} | |||
String url = type == SMSCodeType.AUTO | |||
? '/api/v1/mob/sms/tmp/${vCodeType}?phone=${phone}' | |||
: '/api/v1/mob/sms/tmp/$vCodeType'; | |||
String url = type == SMSCodeType.AUTO ? '/api/v1/mob/sms/tmp/${vCodeType}?phone=${phone}' : '/api/v1/mob/sms/tmp/$vCodeType'; | |||
var result = await NetUtil.post(url, method: NetMethod.GET); | |||
if (NetUtil.isSuccess(result) && | |||
!EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | |||
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | |||
return result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]; | |||
} | |||
} catch (e, s) { | |||
@@ -100,7 +116,7 @@ class MobUtil { | |||
/// 隐私协议授权 | |||
static void submitPrivacyGrantResult(bool permission) { | |||
SharesdkPlugin.uploadPrivacyPermissionStatus(permission ? 1 : 0, (bool success) { | |||
if(success == true) { | |||
if (success == true) { | |||
Logger.log('隐私协议授权提交结果: 成功'); | |||
} else { | |||
Logger.log('隐私协议授权提交结果: 失败'); | |||
@@ -108,15 +124,14 @@ class MobUtil { | |||
}); | |||
} | |||
/// | |||
/// | |||
/// 提交验证码 | |||
/// | |||
/// phone: 手机号码 | |||
/// code: 验证码 | |||
/// zoneCode: 区号 | |||
/// | |||
// static Future<bool> commitCode(final String phone, String code, {String zoneCode = '86'}) async { | |||
// static Future<bool> commitCode(final String phone, String code, {String zoneCode = '86'}) async { | |||
// bool result = false; | |||
// await Smssdk.commitCode(phone, zoneCode, code, (ret, err) { | |||
// if (err != null) { | |||
@@ -132,14 +147,13 @@ class MobUtil { | |||
// } | |||
/// 统计MOB验证码提交 | |||
// static void _countMobSMS(final String phone, final String code, {String zoneCode = '86'}) async { | |||
// try { | |||
// NetUtil.post('/api/v1/funtions/mobsms', params: {'phone': phone, "code": code, 'zone': zoneCode}, showToast: false); | |||
// } catch (e, s) { | |||
// Logger.error(e, s); | |||
// } | |||
// } | |||
// static void _countMobSMS(final String phone, final String code, {String zoneCode = '86'}) async { | |||
// try { | |||
// NetUtil.post('/api/v1/funtions/mobsms', params: {'phone': phone, "code": code, 'zone': zoneCode}, showToast: false); | |||
// } catch (e, s) { | |||
// Logger.error(e, s); | |||
// } | |||
// } | |||
} | |||
@@ -8,6 +8,7 @@ import 'package:zhiying_comm/models/user/user_info_model_notifier.dart'; | |||
import 'package:zhiying_comm/pages/login_page/account/login_account_page.dart'; | |||
import 'package:zhiying_comm/pages/login_page/invite/login_invite_page.dart'; | |||
import 'package:zhiying_comm/pages/login_page/model/login_style_model.dart'; | |||
import 'package:zhiying_comm/util/dialog/loading/loading.dart'; | |||
import 'package:zhiying_comm/util/empty_util.dart'; | |||
import 'package:zhiying_comm/util/global_config.dart'; | |||
import 'package:zhiying_comm/util/log/let_log.dart'; | |||
@@ -56,6 +57,7 @@ class QuickLoginUtil { | |||
/// 打开秒验登录页面的方法 | |||
void openQuickLogin(BuildContext context, Quick model) { | |||
Loading.show(context); | |||
// 取号前设置 | |||
Secverify.autoFinishOauthPage(false); | |||
//设置UI属性 | |||
@@ -66,6 +68,7 @@ class QuickLoginUtil { | |||
} else { | |||
// showAlert("当前环境不支持", context); | |||
Logger.warn("当前环境不支持"); | |||
Loading.dismiss(); | |||
_openSMSLoginPage(context); | |||
} | |||
}); | |||
@@ -184,6 +187,7 @@ class QuickLoginUtil { | |||
// showAlert(err.toString(),context); | |||
Logger.log(err.toString()); | |||
_openSMSLoginPage(context); | |||
Loading.dismiss(); | |||
} else { | |||
Secverify.verify((Map ret, Map err) { | |||
if (err != null) { | |||
@@ -191,6 +195,7 @@ class QuickLoginUtil { | |||
// showAlert(err.toString(), context); | |||
Logger.log(err.toString()); | |||
_openSMSLoginPage(context); | |||
Loading.dismiss(); | |||
Secverify.finshOauthPage(); | |||
// Fluttertoast.showToast(msg: '未知错误 err = ${err?.toString()}'); | |||
} else { | |||
@@ -199,19 +204,23 @@ class QuickLoginUtil { | |||
rst = '登录失败'; | |||
// showAlert(rst, context); | |||
Logger.log(rst); | |||
Loading.dismiss(); | |||
Fluttertoast.showToast(msg: '登录失败'); | |||
} else if (ret.containsKey("otherLogin")) { | |||
///其他登录方式 | |||
_openSMSLoginPage(context); | |||
//调用此方法手动关闭授权页面 | |||
Loading.dismiss(); | |||
Secverify.finshOauthPage(); | |||
} else if (ret.containsKey("opToken")) { | |||
//如果登录成功,将返回的信息提交给自己的服务器 | |||
_doLogin(ret, context); | |||
//调用此方法手动关闭授权页面 | |||
Loading.dismiss(); | |||
Secverify.finshOauthPage(); | |||
} else { | |||
//调用此方法手动关闭授权页面 | |||
Loading.dismiss(); | |||
Secverify.finshOauthPage(); | |||
} | |||
} | |||
@@ -202,7 +202,7 @@ class TurnChainDialogWidget extends StatelessWidget { | |||
), | |||
TextSpan( | |||
text: number ?? '', | |||
style: TextStyle(color: HexColor.fromHex(numberColor), fontFamily: 'Din', package: 'zhiying_base_widget', fontSize: 13), | |||
style: TextStyle(color: HexColor.fromHex(numberColor), fontFamily: 'Din', package: 'zhiying_comm', fontSize: 13), | |||
), | |||
]), | |||
)); | |||
@@ -215,8 +215,8 @@ class TurnChainDialogWidget extends StatelessWidget { | |||
TextSpan(text: model?.style?.saveMomenyText ?? '共省 ¥', style: TextStyle(color: HexColor.fromHex(model?.style?.saveMomenyColor ?? '#FF2020'), fontSize: 13)), | |||
TextSpan( | |||
text: model?.totalSave ?? '0.00', | |||
style: TextStyle(color: HexColor.fromHex(model?.style?.saveMomenyColor ?? '#FF2020'), fontSize: 18, fontFamily: 'Din', package: 'zhiying_base_widget')), | |||
// TextSpan(text: '.99', style: TextStyle(color: HexColor.fromHex(model?.style?.saveMomenyColor ?? '#FF2020'), fontSize: 13, fontFamily: 'Din', package: 'zhiying_base_widget')), | |||
style: TextStyle(color: HexColor.fromHex(model?.style?.saveMomenyColor ?? '#FF2020'), fontSize: 18, fontFamily: 'Din', package: 'zhiying_comm')), | |||
// TextSpan(text: '.99', style: TextStyle(color: HexColor.fromHex(model?.style?.saveMomenyColor ?? '#FF2020'), fontSize: 13, fontFamily: 'Din', package: 'zhiying_comm')), | |||
]), | |||
); | |||
} | |||