@@ -52,10 +52,19 @@ MobSDK { | |||||
bypassApproval false | bypassApproval false | ||||
enable true | enable true | ||||
} | } | ||||
Wechat { | |||||
appId "wx598aaef252cd78e4" | |||||
appSecret "d2fc2edf9ece746765b3bfc0bf1b230e" | |||||
withShareTicket true | |||||
bypassApproval false | |||||
enable true | |||||
} | |||||
WechatMoments { | WechatMoments { | ||||
bypassApproval false | |||||
enable true | enable true | ||||
} | } | ||||
WechatFavorite { | WechatFavorite { | ||||
bypassApproval false | |||||
enable true | enable true | ||||
} | } | ||||
QZone { | QZone { | ||||
@@ -78,6 +87,7 @@ android { | |||||
defaultConfig { | defaultConfig { | ||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||||
applicationId "cn.zhios.zhiying" | applicationId "cn.zhios.zhiying" | ||||
// applicationId "cn.sharesdk.demo" | |||||
minSdkVersion 19 | minSdkVersion 19 | ||||
targetSdkVersion 28 | targetSdkVersion 28 | ||||
aaptOptions.cruncherEnabled = false | aaptOptions.cruncherEnabled = false | ||||
@@ -89,6 +99,12 @@ android { | |||||
} | } | ||||
signingConfigs{ | signingConfigs{ | ||||
config { | |||||
keyAlias 'demokey.keystore' | |||||
keyPassword '123456' | |||||
storeFile file('demokey.keystore') | |||||
storePassword '123456' | |||||
} | |||||
release { | release { | ||||
storeFile file("zhiying.jks") | storeFile file("zhiying.jks") | ||||
storePassword "zhioscom" | storePassword "zhioscom" | ||||
@@ -0,0 +1,10 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |||||
<plist version="1.0"> | |||||
<dict> | |||||
<key>com.apple.developer.applesignin</key> | |||||
<array> | |||||
<string>Default</string> | |||||
</array> | |||||
</dict> | |||||
</plist> |
@@ -29,7 +29,7 @@ class BaseTabModel extends SkipModel { | |||||
chooseIcon = json['choose_icon']; | chooseIcon = json['choose_icon']; | ||||
cateTag = json['cate_tag']; | cateTag = json['cate_tag']; | ||||
skipIdentifier = json['skip_identifier']; | skipIdentifier = json['skip_identifier']; | ||||
requiredLogin = json['required_login']; | |||||
requiredLogin = json['required_login']?.toString(); | |||||
requiredTaobaoAuth = json['required_taobao_auth']; | requiredTaobaoAuth = json['required_taobao_auth']; | ||||
bgColor = json['bg_color']; | bgColor = json['bg_color']; | ||||
fontColor = json['font_color']; | fontColor = json['font_color']; | ||||
@@ -16,8 +16,8 @@ class SkipModel { | |||||
void fromJson(Map<String, dynamic> json) { | void fromJson(Map<String, dynamic> json) { | ||||
url = json['url']; | url = json['url']; | ||||
requiredLogin = json['required_login']; | |||||
requiredTaobaoAuth = json['required_taobao_auth']; | |||||
requiredLogin = json['required_login']?.toString(); | |||||
requiredTaobaoAuth = json['required_taobao_auth']?.toString(); | |||||
skipIdentifier = json['skip_identifier']; | skipIdentifier = json['skip_identifier']; | ||||
} | } | ||||
@@ -77,6 +77,8 @@ class UserInfoNotifier with ChangeNotifier { | |||||
FlutterAlibc.loginOut(); | FlutterAlibc.loginOut(); | ||||
// 退出QQ登录 | // 退出QQ登录 | ||||
MobUtil.cancelQQAuth(); | MobUtil.cancelQQAuth(); | ||||
// 退出微信登录 | |||||
MobUtil.cancelWeChatAuth(); | |||||
notifyListeners(); | notifyListeners(); | ||||
} | } | ||||
@@ -58,7 +58,22 @@ class LoginBindPhoneRepository { | |||||
/// 苹果登录 | /// 苹果登录 | ||||
if(GlobalConfig.LOGIN_THIRD_APPLE == third){ | 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登录 | /// QQ登录 | ||||
@@ -73,7 +73,14 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | |||||
} | } | ||||
/// 微信登录 | /// 微信登录 | ||||
Stream<LoginState> _mapLoginWeChatEventToState(LoginThirdWeChatEvent event) async* {} | |||||
Stream<LoginState> _mapLoginWeChatEventToState(LoginThirdWeChatEvent event) async* { | |||||
var result = await repository.weChatLogin(event?.model); | |||||
if(!EmptyUtil.isEmpty(result)){ | |||||
yield LoginThirdLoginSuccessState(model: result, thirdType: GlobalConfig.LOGIN_THIRD_WECHAT); | |||||
}else{ | |||||
yield LoginThirdLoginErrorState(); | |||||
} | |||||
} | |||||
/// QQ 登录 | /// QQ 登录 | ||||
Stream<LoginState> _mapLoginQQEventToState(LoginThirdQQEvent event) async* { | Stream<LoginState> _mapLoginQQEventToState(LoginThirdQQEvent event) async* { | ||||
@@ -86,5 +93,12 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | |||||
} | } | ||||
/// 苹果登录 | /// 苹果登录 | ||||
Stream<LoginState> _mapLoginAppleEventToState(LoginThirdAppleEvent event) async* {} | |||||
Stream<LoginState> _mapLoginAppleEventToState(LoginThirdAppleEvent event) async* { | |||||
var result = await repository.appleLogin(identityToken: event.identityToken); | |||||
if(!EmptyUtil.isEmpty(result)){ | |||||
yield LoginThirdLoginSuccessState(model: result, thirdType: GlobalConfig.LOGIN_THIRD_APPLE); | |||||
}else{ | |||||
yield LoginThirdLoginErrorState(); | |||||
} | |||||
} | |||||
} | } |
@@ -30,10 +30,20 @@ class LoginThirdAliEvent extends LoginEvent { | |||||
} | } | ||||
/// 第三方登录:苹果登录 | /// 第三方登录:苹果登录 | ||||
class LoginThirdAppleEvent extends LoginEvent {} | |||||
class LoginThirdAppleEvent extends LoginEvent { | |||||
final String identityToken; | |||||
LoginThirdAppleEvent({@required this.identityToken}); | |||||
@override | |||||
List<Object> get props => [this.identityToken]; | |||||
} | |||||
/// 第三方登录:微信登录 | /// 第三方登录:微信登录 | ||||
class LoginThirdWeChatEvent extends LoginEvent {} | |||||
class LoginThirdWeChatEvent extends LoginEvent { | |||||
final Map<dynamic, dynamic> model; | |||||
LoginThirdWeChatEvent({@required this.model}); | |||||
@override | |||||
List<Object> get props => [this.model]; | |||||
} | |||||
/// 第三方登录:QQ登录 | /// 第三方登录:QQ登录 | ||||
class LoginThirdQQEvent extends LoginEvent { | class LoginThirdQQEvent extends LoginEvent { | ||||
@@ -16,6 +16,27 @@ class LoginRepository { | |||||
return await LoginStyleUtil.fetchCachePageData(); | return await LoginStyleUtil.fetchCachePageData(); | ||||
} | } | ||||
/// apple 登录 | |||||
Future<UserInfoModel> appleLogin({@required final String identityToken}) async { | |||||
try{ | |||||
Map<String, String> params = {}; | |||||
params['token'] = identityToken; | |||||
var result = await NetUtil.post('/api/v1/sign/fast/in', | |||||
queryParameters: {'third_party_login': 'apple'}, | |||||
params: {'apple' : params}, | |||||
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; | |||||
} | |||||
/// 淘宝登录 | /// 淘宝登录 | ||||
Future<UserInfoModel> aliLogin( | Future<UserInfoModel> aliLogin( | ||||
{@required final String nick, @required final String avatarUrl, @required final String openId, final String openSid, final String topAccessToken, final String topAuthCode}) async { | {@required final String nick, @required final String avatarUrl, @required final String openId, final String openSid, final String topAccessToken, final String topAuthCode}) async { | ||||
@@ -42,13 +63,32 @@ class LoginRepository { | |||||
return null; | return null; | ||||
} | } | ||||
/// 微信登录 | /// 微信登录 | ||||
Future<UserInfoModel> weChatLogin() async { | |||||
return null; | |||||
} | |||||
Future<UserInfoModel> weChatLogin(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(); | |||||
/// apple 登录 | |||||
Future<UserInfoModel> appleLogin() async { | |||||
var result = await NetUtil.post( | |||||
'/api/v1/sign/fast/in', | |||||
params: {'wechat' :params}, | |||||
queryParameters: {'third_party_login': 'wechat'}, | |||||
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; | return null; | ||||
} | } | ||||
@@ -1,4 +1,5 @@ | |||||
import 'dart:convert'; | import 'dart:convert'; | ||||
import 'dart:io'; | |||||
import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
@@ -16,6 +17,7 @@ import 'package:zhiying_comm/util/empty_util.dart'; | |||||
import 'package:zhiying_comm/util/mob_util/mob_util.dart'; | import 'package:zhiying_comm/util/mob_util/mob_util.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:ali_auth_wbq/ali_auth_wbq.dart'; | |||||
import 'bloc/bloc.dart'; | import 'bloc/bloc.dart'; | ||||
import 'bloc/login_repository.dart'; | import 'bloc/login_repository.dart'; | ||||
@@ -48,6 +50,42 @@ class LoginPageContainer extends StatefulWidget { | |||||
class _LoginPageContainerState extends State<LoginPageContainer> { | class _LoginPageContainerState extends State<LoginPageContainer> { | ||||
LoginModel _taoBao; | LoginModel _taoBao; | ||||
var _qqUserData; | var _qqUserData; | ||||
var _wxUserData; | |||||
String _appleData; | |||||
@override | |||||
void initState() { | |||||
// 登录监听 | |||||
AliAuthPlugin.loginListen(type: false, onEvent: _onAppleLoginEvent); | |||||
super.initState(); | |||||
} | |||||
// 返回授权信息 | |||||
// returnCode: 200成功 500失败 | |||||
// returnMsg | |||||
// user | |||||
// familyName //可能为 @"" | |||||
// givenName //可能为 @"" | |||||
// email //可能为 @"" | |||||
// identityTokenStr //需要使用的参数 | |||||
// authorizationCodeStr | |||||
void _onAppleLoginEvent(event) { | |||||
var stateCode = event['returnCode']; | |||||
String stateMsg = event['returnMsg']; | |||||
// _appleData = event['identityTokenStr']; | |||||
_appleData = event['user']; | |||||
Logger.debug('event == ' + event?.toString()); | |||||
if (stateCode == 200 && !EmptyUtil.isEmpty(_appleData)) { | |||||
Loading.dismiss(); | |||||
print("成功------$event"); | |||||
BlocProvider.of<LoginBloc>(context).add(LoginThirdAppleEvent(identityToken: _appleData)); | |||||
} else { | |||||
Loading.dismiss(); | |||||
print("失败------$stateMsg"); | |||||
} | |||||
} | |||||
/// 微信or手机登陆 | /// 微信or手机登陆 | ||||
void _loginClick(String type, LoginStyleModel model) { | void _loginClick(String type, LoginStyleModel model) { | ||||
print('登陆$type'); | print('登陆$type'); | ||||
@@ -62,12 +100,21 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||||
} else if ('wechat' == type) { | } else if ('wechat' == type) { | ||||
/// 微信登录 | /// 微信登录 | ||||
Loading.show(context); | Loading.show(context); | ||||
SharesdkPlugin.getUserInfo(ShareSDKPlatforms.wechatSession, (SSDKResponseState state, Map user, SSDKError error) { | |||||
if(state == SSDKResponseState.Success){ | |||||
} | |||||
}); | |||||
Fluttertoast.showToast(msg: '暂不支持~'); | |||||
SharesdkPlugin.getUserInfo(ShareSDKPlatforms.wechatSession, (SSDKResponseState state, Map userdata, SSDKError error) { | |||||
Logger.log('state = ${state?.toString()}, userInfo = ${userdata?.toString()}'); | |||||
if (state == SSDKResponseState.Success) { | |||||
try { | |||||
_wxUserData = jsonDecode(userdata['dbInfo']); | |||||
BlocProvider.of<LoginBloc>(context).add(LoginThirdWeChatEvent(model: userdata)); | |||||
Loading.dismiss(); | |||||
} catch (e) { | |||||
Fluttertoast.showToast(msg: '登录失败'); | |||||
Loading.dismiss(); | |||||
} | |||||
} else { | |||||
Loading.dismiss(); | |||||
} | |||||
}); | |||||
} | } | ||||
} | } | ||||
@@ -78,7 +125,6 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||||
Fluttertoast.showToast(msg: '暂不支持~'); | Fluttertoast.showToast(msg: '暂不支持~'); | ||||
return; | return; | ||||
} | } | ||||
/// 淘宝登录 | /// 淘宝登录 | ||||
if ('taobao' == model.type) { | if ('taobao' == model.type) { | ||||
@@ -105,11 +151,14 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||||
SharesdkPlugin.getUserInfo(ShareSDKPlatforms.qq, (SSDKResponseState state, Map userdata, SSDKError error) { | SharesdkPlugin.getUserInfo(ShareSDKPlatforms.qq, (SSDKResponseState state, Map userdata, SSDKError error) { | ||||
Logger.log('state = ${state?.toString()}\nuserData = ${userdata?.toString()}'); | Logger.log('state = ${state?.toString()}\nuserData = ${userdata?.toString()}'); | ||||
if (state == SSDKResponseState.Success && !EmptyUtil.isEmpty(userdata)) { | if (state == SSDKResponseState.Success && !EmptyUtil.isEmpty(userdata)) { | ||||
try{ | |||||
_qqUserData = jsonDecode(userdata['dbInfo']);; | |||||
}catch(e){} | |||||
BlocProvider.of<LoginBloc>(context).add(LoginThirdQQEvent(model: userdata)); | |||||
Loading.dismiss(); | |||||
try { | |||||
_qqUserData = jsonDecode(userdata['dbInfo']); | |||||
BlocProvider.of<LoginBloc>(context).add(LoginThirdQQEvent(model: userdata)); | |||||
Loading.dismiss(); | |||||
} catch (e) { | |||||
Fluttertoast.showToast(msg: '登录失败'); | |||||
Loading.dismiss(); | |||||
} | |||||
} else { | } else { | ||||
Loading.dismiss(); | Loading.dismiss(); | ||||
} | } | ||||
@@ -119,10 +168,14 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||||
/// 苹果登录 | /// 苹果登录 | ||||
if ('apple' == model.type) { | if ('apple' == model.type) { | ||||
Fluttertoast.showToast(msg: '暂不支持~'); | |||||
if (Platform.isIOS) { | |||||
Loading.show(context); | |||||
await AliAuthPlugin.appleLogin; | |||||
// final appleLogin = await AliAuthPlugin.appleLogin; | |||||
} else { | |||||
Fluttertoast.showToast(msg: '暂不支持~'); | |||||
} | |||||
} | } | ||||
} | } | ||||
/// 跳到用户协议 | /// 跳到用户协议 | ||||
@@ -135,6 +188,17 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||||
/// 跳到绑定手机号 | /// 跳到绑定手机号 | ||||
void _jumpBindPhonePage(String thirdType) { | void _jumpBindPhonePage(String thirdType) { | ||||
/// 如果是苹果登录 | |||||
if (GlobalConfig.LOGIN_THIRD_APPLE == thirdType) { | |||||
Navigator.push( | |||||
context, | |||||
CupertinoPageRoute( | |||||
builder: (_) => LoginBindPhonePage({ | |||||
'thirdType': thirdType, | |||||
'identityTokenStr': _appleData, | |||||
}))); | |||||
} | |||||
/// 如果是淘宝登录 | /// 如果是淘宝登录 | ||||
if (GlobalConfig.LOGIN_THIRD_ALI == thirdType) { | if (GlobalConfig.LOGIN_THIRD_ALI == thirdType) { | ||||
Navigator.push( | Navigator.push( | ||||
@@ -150,14 +214,14 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||||
'topAuthCode': _taoBao?.data?.topAuthCode, | 'topAuthCode': _taoBao?.data?.topAuthCode, | ||||
}))); | }))); | ||||
} | } | ||||
/// 如果是QQ登录 | /// 如果是QQ登录 | ||||
if(GlobalConfig.LOGIN_THIRD_QQ == thirdType) { | |||||
if (GlobalConfig.LOGIN_THIRD_QQ == thirdType) { | |||||
if (!EmptyUtil.isEmpty(_qqUserData)) { | if (!EmptyUtil.isEmpty(_qqUserData)) { | ||||
Navigator.push( | Navigator.push( | ||||
context, | context, | ||||
CupertinoPageRoute( | CupertinoPageRoute( | ||||
builder: (_) => | |||||
LoginBindPhonePage({ | |||||
builder: (_) => LoginBindPhonePage({ | |||||
'thirdType': thirdType, | 'thirdType': thirdType, | ||||
'nickname': _qqUserData['nickname']?.toString(), | 'nickname': _qqUserData['nickname']?.toString(), | ||||
'avatar_url': _qqUserData['icon']?.toString(), | 'avatar_url': _qqUserData['icon']?.toString(), | ||||
@@ -168,6 +232,24 @@ class _LoginPageContainerState extends State<LoginPageContainer> { | |||||
}))); | }))); | ||||
} | } | ||||
} | } | ||||
/// 微信登录 | |||||
if (GlobalConfig.LOGIN_THIRD_WECHAT == thirdType) { | |||||
if (!EmptyUtil.isEmpty(_wxUserData)) { | |||||
Navigator.push( | |||||
context, | |||||
CupertinoPageRoute( | |||||
builder: (_) => LoginBindPhonePage({ | |||||
'thirdType': thirdType, | |||||
'nickname': _wxUserData['nickname']?.toString(), | |||||
'avatar_url': _wxUserData['icon']?.toString(), | |||||
'open_id': _wxUserData['userID']?.toString(), | |||||
'gender': _wxUserData['gender']?.toString() == '0' ? '1' : '2', | |||||
'unionid': _wxUserData['unionid']?.toString(), | |||||
'token': _wxUserData['token']?.toString(), | |||||
}))); | |||||
} | |||||
} | |||||
} | } | ||||
/// 跳到首页 | /// 跳到首页 | ||||
@@ -33,6 +33,15 @@ class MobUtil { | |||||
}); | }); | ||||
} | } | ||||
/// | |||||
/// 退出微信登录 | |||||
/// | |||||
static void cancelWeChatAuth(){ | |||||
SharesdkPlugin.cancelAuth(ShareSDKPlatforms.wechatSession, (SSDKResponseState state, Map user, SSDKError error) { | |||||
Logger.debug('state = ${state}\n rawData = ${error?.rawData?.toString()}'); | |||||
}); | |||||
} | |||||
/// | /// | ||||
/// 取消授权 | /// 取消授权 | ||||
/// | /// | ||||
@@ -56,9 +56,11 @@ dependencies: | |||||
# 锁粉 | # 锁粉 | ||||
moblink: ^3.4.1 | moblink: ^3.4.1 | ||||
# 苹果登录 | # 苹果登录 | ||||
# sign_in_with_apple: ^2.5.4 | |||||
# 微信登录 | |||||
# fluwx_no_pay: 2.3.1 | |||||
ali_auth_wbq: | |||||
# path: ../zhiying_ali_auth_wbq | |||||
git: | |||||
url: 'http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_ali_auth_wbq.git' | |||||
ref: '0.0.5' | |||||
# loading 动画 | # loading 动画 | ||||
loading_indicator: ^1.2.0 | loading_indicator: ^1.2.0 | ||||
#权限授权 | #权限授权 | ||||