From cfc5f239ede33ed0779dadb52eed54ace641d374 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Wed, 2 Dec 2020 09:45:55 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=9A=84=E9=82=80=E8=AF=B7=E7=A0=81=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=B8=A6=E6=89=8B=E6=9C=BA=E5=8F=B7=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=202=E3=80=81=E6=B7=BB=E5=8A=A0mob=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=9A=90=E7=A7=81=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/login_account_page.dart | 11 ++-- .../bind/login_bind_phone_page.dart | 15 ++--- .../login_page/invite/login_invite_page.dart | 17 +++++- lib/pages/login_page/login_page.dart | 19 +++--- lib/util/mob_util/mob_util.dart | 58 ++++++++++++------- .../mob_util/secverify/quick_login_util.dart | 6 +- 6 files changed, 78 insertions(+), 48 deletions(-) diff --git a/lib/pages/login_page/account/login_account_page.dart b/lib/pages/login_page/account/login_account_page.dart index 585715b..96bff8a 100644 --- a/lib/pages/login_page/account/login_account_page.dart +++ b/lib/pages/login_page/account/login_account_page.dart @@ -57,14 +57,14 @@ class _LoginAccountPageContianerState extends State i bool _isLogging = false; /// 跳转到邀请码页面 - void _openInvitePage() { + void _openInvitePage(String mobile) { print('跳转到邀请码页面'); RouterUtil.hideKeyboard(context); Navigator.push( context, CupertinoPageRoute( // builder: (_) => PageFactory.create('login_invite', null) - builder: (_) => LoginInvitePage())); + builder: (_) => LoginInvitePage({'mobile': mobile}))); } /// 登陆成功页面 @@ -276,9 +276,10 @@ class _LoginAccountPageContianerState extends State i } // 登陆成功 if (current is LoginAccountLoginSuccessState) { - /// 缓存登陆数据 - Provider.of(context, listen: false)?.setUserInfo(current.model); + if (current?.model?.registerInviteCodeEnable != '1') { + /// 缓存登陆数据 + Provider.of(context, listen: false)?.setUserInfo(current.model); Fluttertoast.showToast(msg: '登录成功~'); _isLogging = true; @@ -286,7 +287,7 @@ class _LoginAccountPageContianerState extends State i _openLoginSuccessPage(); } else { /// 打开邀请页面 - _openInvitePage(); + _openInvitePage(current?.model?.mobile); } return false; } diff --git a/lib/pages/login_page/bind/login_bind_phone_page.dart b/lib/pages/login_page/bind/login_bind_phone_page.dart index 689cd20..7cd7b38 100644 --- a/lib/pages/login_page/bind/login_bind_phone_page.dart +++ b/lib/pages/login_page/bind/login_bind_phone_page.dart @@ -60,10 +60,10 @@ class _LoginBindPhonePageContainerState extends State<_LoginBindPhonePageContain bool _isLogging = false; /// 跳转到邀请码页面 - void _openInvitePage() { + void _openInvitePage(String mobile) { print('跳转到邀请码页面'); RouterUtil.hideKeyboard(context); - Navigator.push(context, CupertinoPageRoute(builder: (_) => LoginInvitePage())); + Navigator.push(context, CupertinoPageRoute(builder: (_) => LoginInvitePage({'mobile': mobile}))); } /// 登陆成功页面 @@ -225,17 +225,18 @@ class _LoginBindPhonePageContainerState extends State<_LoginBindPhonePageContain } // 登陆成功 if (current is LoginBindPhoneLoginSuccessState) { - /// 缓存登陆数据 - Provider.of(context, listen: false)?.setUserInfo(current.model); + if (current?.model?.registerInviteCodeEnable != '1') { + /// 缓存登陆数据 + Provider.of(context, listen: false)?.setUserInfo(current.model); Fluttertoast.showToast(msg: '登录成功~'); - _isLogging = true; - /// 打开也买 + _isLogging = true; + /// 打开首页 _openLoginSuccessPage(); } else { /// 打开邀请页面 - _openInvitePage(); + _openInvitePage(current?.model?.mobile); } return false; } diff --git a/lib/pages/login_page/invite/login_invite_page.dart b/lib/pages/login_page/invite/login_invite_page.dart index ce166cb..cf80357 100644 --- a/lib/pages/login_page/invite/login_invite_page.dart +++ b/lib/pages/login_page/invite/login_invite_page.dart @@ -1,6 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:provider/provider.dart'; import 'package:zhiying_comm/pages/login_page/model/login_style_model.dart'; import 'package:zhiying_comm/util/empty_util.dart'; @@ -15,6 +16,10 @@ import 'model/login_invite_user.dart'; /// 邀请页面 /// class LoginInvitePage extends StatelessWidget { + final Map data; + + LoginInvitePage(this.data); + @override Widget build(BuildContext context) { return Scaffold( @@ -22,7 +27,7 @@ class LoginInvitePage extends StatelessWidget { backgroundColor: HexColor.fromHex('#FFFFFF'), body: BlocProvider( create: (_) => LoginInviteBloc(repostitory: LoginInviteRepository())..add(LoginInviteInitEvent()), - child: LoginInvitePageContainer(), + child: LoginInvitePageContainer(this.data), ), ); } @@ -31,6 +36,10 @@ class LoginInvitePage extends StatelessWidget { /// /// 邀请 class LoginInvitePageContainer extends StatefulWidget { + final Map data; + + LoginInvitePageContainer(this.data); + @override _LoginInvitePageContainerState createState() => _LoginInvitePageContainerState(); } @@ -39,6 +48,7 @@ class _LoginInvitePageContainerState extends State { TextEditingController _editingController; FocusNode _focusNode; bool _showInviteInfo = false; + // 是否登录中 bool _isLogging = false; @@ -84,8 +94,9 @@ class _LoginInvitePageContainerState extends State { String inviteNum = inviteUser?.userId ?? ''; /// 手机号 - UserInfoModel model = await Provider.of(context, listen: false)?.getUserInfoModel(); - String mobile = model?.mobile ?? ''; + // UserInfoModel model = await Provider.of(context, listen: false)?.getUserInfoModel(); + + String mobile = widget?.data['mobile'] ;//model?.mobile ?? ''; if (!EmptyUtil.isEmpty(inviteNum) && !EmptyUtil.isEmpty(mobile)) { setState(() { _isLogging = true; diff --git a/lib/pages/login_page/login_page.dart b/lib/pages/login_page/login_page.dart index c3b2175..aa009c5 100644 --- a/lib/pages/login_page/login_page.dart +++ b/lib/pages/login_page/login_page.dart @@ -49,13 +49,19 @@ class _LoginPageContainerState extends State { void _loginClick(String type, LoginStyleModel model) { print('登陆$type'); RouterUtil.hideKeyboard(context); - if (type == 'mobile') { + if ('mobile' == type) { if (model?.flashLoginEnable == '1') { // mob 一键登录 MobUtil.openQuickLoginPage(context, model?.quick); } else { Navigator.push(context, CupertinoPageRoute(builder: (_) => LoginAccountPage(null))); } + } else if ('wechat' == type) { + /// 微信登录 + // fluwx.sendWeChatAuth(scope: "snsapi_userinfo", state: "wechat_sdk_demo_test").then((data) { + // Logger.debug('返回数据: ${data?.toString()}'); + // }); + Fluttertoast.showToast(msg: '暂不支持~'); } } @@ -79,9 +85,9 @@ class _LoginPageContainerState extends State { openSid: _taoBao?.data?.openSid, topAccessToken: _taoBao?.data?.topAccessToken, topAuthCode: _taoBao?.data?.topAuthCode)); - // Logger.warn(' tao login = ${taoBao?.errorCode} , msg = ${taoBao?.errorMessage}, nick = ${taoBao?.data?.nick}, ' - // 'avatar = ${taoBao?.data?.avatarUrl}, openId = ${taoBao?.data?.openId}, openSid = ${taoBao?.data?.openSid}, ' - // 'topAccessToken = ${taoBao?.data?.topAccessToken}, topAuthCode = ${taoBao?.data?.topAuthCode}'); + // Logger.warn(' tao login = ${_taoBao?.errorCode} , msg = ${_taoBao?.errorMessage}, nick = ${_taoBao?.data?.nick}, ' + // 'avatar = ${_taoBao?.data?.avatarUrl}, openId = ${_taoBao?.data?.openId}, openSid = ${_taoBao?.data?.openSid}, ' + // 'topAccessToken = ${_taoBao?.data?.topAccessToken}, topAuthCode = ${_taoBao?.data?.topAuthCode}'); } } @@ -90,11 +96,6 @@ class _LoginPageContainerState extends State { Fluttertoast.showToast(msg: '暂不支持~'); } - /// 微信登录 - if ('wechat' == model.type) { - Fluttertoast.showToast(msg: '暂不支持~'); - } - /// 苹果登录 if ('apple' == model.type) { Fluttertoast.showToast(msg: '暂不支持~'); diff --git a/lib/util/mob_util/mob_util.dart b/lib/util/mob_util/mob_util.dart index a8a2792..e1e48da 100644 --- a/lib/util/mob_util/mob_util.dart +++ b/lib/util/mob_util/mob_util.dart @@ -1,5 +1,6 @@ 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/empty_util.dart'; import 'package:zhiying_comm/util/enum_util.dart'; @@ -63,27 +64,7 @@ class MobUtil { return Future.value(result); } - /// - /// 提交验证码 - /// - /// phone: 手机号码 - /// code: 验证码 - /// zoneCode: 区号 - /// - // static Future commitCode(final String phone, String code, {String zoneCode = '86'}) async { - // bool result = false; - // await Smssdk.commitCode(phone, zoneCode, code, (ret, err) { - // if (err != null) { - // // showAlert(err.toString(),context); - // result = false; - // } else { - // // showAlert('提交验证码成功!',context); - // result = true; - // // _countMobSMS(phone, code, zoneCode: zoneCode); - // } - // }); - // return Future.value(result); - // } + /// 询问验证码是否可以下发 @@ -116,6 +97,40 @@ class MobUtil { return SharedPreferencesUtil.getStringValue('mobInvitedCode'); } + /// 隐私协议授权 + static void submitPrivacyGrantResult(bool permission) { + SharesdkPlugin.uploadPrivacyPermissionStatus(permission ? 1 : 0, (bool success) { + if(success == true) { + Logger.log('隐私协议授权提交结果: 成功'); + } else { + Logger.log('隐私协议授权提交结果: 失败'); + } + }); + } + + +/// + /// 提交验证码 + /// + /// phone: 手机号码 + /// code: 验证码 + /// zoneCode: 区号 + /// + // static Future commitCode(final String phone, String code, {String zoneCode = '86'}) async { +// bool result = false; +// await Smssdk.commitCode(phone, zoneCode, code, (ret, err) { +// if (err != null) { +// // showAlert(err.toString(),context); +// result = false; +// } else { +// // showAlert('提交验证码成功!',context); +// result = true; +// // _countMobSMS(phone, code, zoneCode: zoneCode); +// } +// }); +// return Future.value(result); +// } + /// 统计MOB验证码提交 // static void _countMobSMS(final String phone, final String code, {String zoneCode = '86'}) async { // try { @@ -125,6 +140,7 @@ class MobUtil { // } // } + } enum SMSCodeType { diff --git a/lib/util/mob_util/secverify/quick_login_util.dart b/lib/util/mob_util/secverify/quick_login_util.dart index 750bf12..7a3ea1a 100644 --- a/lib/util/mob_util/secverify/quick_login_util.dart +++ b/lib/util/mob_util/secverify/quick_login_util.dart @@ -78,9 +78,9 @@ class QuickLoginUtil { } /// 打开邀请码页面 - void _openInvitePage(BuildContext context) { + void _openInvitePage(BuildContext context, String mobile) { print('跳转到邀请码页面'); - Navigator.push(context, CupertinoPageRoute(builder: (_) => LoginInvitePage())); + Navigator.push(context, CupertinoPageRoute(builder: (_) => LoginInvitePage({'mobile': mobile}))); } /// 打开首页的方法 @@ -113,7 +113,7 @@ class QuickLoginUtil { if (!EmptyUtil.isEmpty(model)) { if (model.registerInviteCodeEnable == '1') { /// 需要填写注册码再跳首页 - _openInvitePage(context); + _openInvitePage(context, model?.username); return; } else {