From 7386a252e982d3c02989a5885af5db128e0888bb Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Tue, 24 Nov 2020 17:59:57 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81mob=20=E7=9F=AD=E4=BF=A1=E5=AE=8C?= =?UTF-8?q?=E6=88=90=202=E3=80=81mob=20=E7=A7=92=E9=AA=8C=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 24 ++++++++++ .../android/app/src/main/AndroidManifest.xml | 3 +- .../security_bind_alipay_bloc.dart | 4 +- .../security_bind_alipay_page.dart | 37 ++++++++++++---- .../security_mobile/security_mobile.dart | 44 +++++++++++++------ .../security_mobile_unbind.dart | 34 ++++++++++---- lib/pages/security_page/security_page.dart | 3 ++ .../security_password/security_password.dart | 30 +++++++++++-- .../security_unbin_alipay.dart | 33 +++++++++++--- lib/register.dart | 5 +-- 10 files changed, 172 insertions(+), 45 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 0e8bc6e..6f3b74b 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -57,12 +57,29 @@ android { } } + // 签名配置 + signingConfigs { + // 智夜生活 + zhiying { + storeFile file('zhiying.jks') + storePassword 'zhioscom' + keyAlias 'zysh' + keyPassword 'zhioscom' + v1SigningEnabled true + v2SigningEnabled true + } + + } + + flavorDimensions "app" + buildTypes { debug { buildConfigField "boolean", "LOG_DEBUG", "true" minifyEnabled false zipAlignEnabled true shrinkResources false + signingConfig signingConfigs.zhiying proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { @@ -70,6 +87,7 @@ android { minifyEnabled false shrinkResources false zipAlignEnabled true + signingConfig signingConfigs.zhiying proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } @@ -189,6 +207,12 @@ MobSDK { appKey "30dc33054b635" appSecret "396e98c293130c9976fb7428b6b434d6" + //手机验证登录 + SecVerify {} + + //短信 + SMSSDK {} + ShareSDK { // platform configuration information diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 6a0dba0..70a64fa 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -28,8 +28,9 @@ android:name="io.flutter.app.FlutterApplication" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:allowBackup="true" android:usesCleartextTraffic="true" - tools:replace="android:name"> + tools:replace="android:name, android:allowBackup"> bindAlipay(String name, String account, String code) { + Future bindAlipay(String name, String account, String code, String phone) { return NetUtil.post('/api/v1/settings/account/security/alipay', method: NetMethod.POST, params: Map.from({ 'alipay_real_name': name, 'alipay_account': account, 'valid_code': code, + 'phone': phone, + 'zone': '86' })).then((result) { if (result['code'] == 1) return true; return false; diff --git a/lib/pages/security_page/security_bind_alipay/security_bind_alipay_page.dart b/lib/pages/security_page/security_bind_alipay/security_bind_alipay_page.dart index 763bdeb..5e3df54 100644 --- a/lib/pages/security_page/security_bind_alipay/security_bind_alipay_page.dart +++ b/lib/pages/security_page/security_bind_alipay/security_bind_alipay_page.dart @@ -12,8 +12,11 @@ import 'package:zhiying_base_widget/pages/security_page/widgets/security_code_bu import 'package:zhiying_base_widget/pages/security_page/widgets/security_confirm_button.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/mob_util/mob_util.dart'; -// 绑定支付宝 +/// +/// 绑定支付宝 +/// class SecurityBindAlipayPage extends StatefulWidget { final Map model; @@ -34,7 +37,7 @@ class _SecurityBindAlipayPageState extends State { } else { return BlocProvider( bloc: SecurityBindAlipayBloc(), - child: _SecurityBindAlipayContainer(datas), + child: _SecurityBindAlipayContainer(datas, status['mobile_setting_text']), ); } } @@ -42,8 +45,9 @@ class _SecurityBindAlipayPageState extends State { class _SecurityBindAlipayContainer extends StatefulWidget { final Map model; + final String phone; - const _SecurityBindAlipayContainer(this.model, {Key key}) : super(key: key); + const _SecurityBindAlipayContainer(this.model, this.phone, {Key key}) : super(key: key); @override _SecurityBindAlipayContainerState createState() => @@ -140,7 +144,9 @@ class _SecurityBindAlipayContainerState if (await _bloc.bindAlipay( _nameController.text, _accountController.text, - _codeController.text)) { + _codeController.text, + widget.phone + )) { Fluttertoast.showToast(msg: '绑定成功'); Navigator.of(context).pop(true); } @@ -193,9 +199,22 @@ class _SecurityBindAlipayContainerState } void _sendCode() async { - NetUtil.request('/api/v1/settings/account/security/alipay/sms', - onSuccess: (result) { - Logger.debug(result); + // NetUtil.request('/api/v1/settings/account/security/alipay/sms', + // onSuccess: (result) { + // Logger.debug(result); + // Fluttertoast.showToast(msg: '发送成功'); + // _second = 60; + // Timer.periodic(Duration(seconds: 1), (timer) { + // _second--; + // if (_second <= 0) { + // timer.cancel(); + // } + // setState(() {}); + // }); + // }); + + bool result = await MobUtil.getTextCode(widget.phone, smsCodeType: SMSCodeType.BIND_ALIPAY); + if(result){ Fluttertoast.showToast(msg: '发送成功'); _second = 60; Timer.periodic(Duration(seconds: 1), (timer) { @@ -205,6 +224,8 @@ class _SecurityBindAlipayContainerState } setState(() {}); }); - }); + }else{ + Fluttertoast.showToast(msg: '获取验证码失败'); + } } } diff --git a/lib/pages/security_page/security_mobile/security_mobile.dart b/lib/pages/security_page/security_mobile/security_mobile.dart index 15d6eef..0661915 100644 --- a/lib/pages/security_page/security_mobile/security_mobile.dart +++ b/lib/pages/security_page/security_mobile/security_mobile.dart @@ -9,7 +9,11 @@ import 'package:zhiying_base_widget/pages/security_page/widgets/security_bind_in import 'package:zhiying_base_widget/pages/security_page/widgets/security_code_button.dart'; import 'package:zhiying_base_widget/pages/security_page/widgets/security_confirm_button.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/mob_util/mob_util.dart'; +/// +/// 绑定手机号 +/// class SecurityMobile extends StatefulWidget { final Map model; @@ -37,8 +41,7 @@ class _SecurityMobileContainer extends StatefulWidget { const _SecurityMobileContainer(this.model, {Key key}) : super(key: key); @override - _SecurityMobileContainerState createState() => - _SecurityMobileContainerState(); + _SecurityMobileContainerState createState() => _SecurityMobileContainerState(); } class _SecurityMobileContainerState extends State<_SecurityMobileContainer> { @@ -74,8 +77,7 @@ class _SecurityMobileContainerState extends State<_SecurityMobileContainer> { ? Container() : Container( width: double.infinity, - padding: EdgeInsets.only( - left: 12.5, right: 12.5, top: 10, bottom: 10), + padding: EdgeInsets.only(left: 12.5, right: 12.5, top: 10, bottom: 10), child: Text( '请绑定新的手机号码,如未完成绑定将继续使用原手机号码', style: TextStyle(fontSize: 12, color: Color(0xff999999)), @@ -157,8 +159,7 @@ class _SecurityMobileContainerState extends State<_SecurityMobileContainer> { } void _verifiy() { - bool canConfirm = - _phoneController.text.length > 0 && _codeController.text.length == 6; + bool canConfirm = _phoneController.text.length > 0 && _codeController.text.length == 6; if (canConfirm != _canConfirm) { setState(() { _canConfirm = canConfirm; @@ -167,12 +168,25 @@ class _SecurityMobileContainerState extends State<_SecurityMobileContainer> { } void _sendCode() async { - NetUtil.request('/api/v1/settings/account/security/mobile/sms', - params: Map.from({ - 'mobile': _phoneController.text, - }), - method: NetMethod.POST, onSuccess: (result) { - Logger.debug(result); + // NetUtil.request('/api/v1/settings/account/security/mobile/sms', + // params: Map.from({ + // 'mobile': _phoneController.text, + // }), + // method: NetMethod.POST, onSuccess: (result) { + // Logger.debug(result); + // Fluttertoast.showToast(msg: '发送成功'); + // _second = 60; + // Timer.periodic(Duration(seconds: 1), (timer) { + // _second--; + // if (_second <= 0) { + // timer.cancel(); + // } + // setState(() {}); + // }); + // }); + + bool result = await MobUtil.getTextCode(_phoneController.text, smsCodeType: SMSCodeType.BIND_PHONE); + if (result) { Fluttertoast.showToast(msg: '发送成功'); _second = 60; Timer.periodic(Duration(seconds: 1), (timer) { @@ -182,7 +196,9 @@ class _SecurityMobileContainerState extends State<_SecurityMobileContainer> { } setState(() {}); }); - }); + } else { + Fluttertoast.showToast(msg: '获取验证码失败'); + } } // 设置手机号,没有手机号的调这个😵 @@ -205,6 +221,8 @@ class _SecurityMobileContainerState extends State<_SecurityMobileContainer> { params: Map.from({ 'mobile': _phoneController.text, 'valid_code': _codeController.text, + 'phone': _phoneController.text, + 'zone': '86' }), method: NetMethod.POST, onSuccess: (result) { Logger.debug(result); diff --git a/lib/pages/security_page/security_mobile/security_mobile_unbind.dart b/lib/pages/security_page/security_mobile/security_mobile_unbind.dart index 30bc892..22269e0 100644 --- a/lib/pages/security_page/security_mobile/security_mobile_unbind.dart +++ b/lib/pages/security_page/security_mobile/security_mobile_unbind.dart @@ -9,7 +9,11 @@ import 'package:zhiying_base_widget/pages/security_page/widgets/security_bind_in import 'package:zhiying_base_widget/pages/security_page/widgets/security_code_button.dart'; import 'package:zhiying_base_widget/pages/security_page/widgets/security_confirm_button.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/mob_util/mob_util.dart'; +/// +/// 接绑手机号 +/// class SecurityMobileUnbind extends StatefulWidget { final Map model; @@ -45,8 +49,7 @@ class _SecurityMobileUnbindState extends State { children: [ Container( width: double.infinity, - padding: - EdgeInsets.only(left: 12.5, right: 12.5, top: 10, bottom: 10), + padding: EdgeInsets.only(left: 12.5, right: 12.5, top: 10, bottom: 10), child: Text( '为了您的账户安全,将对原有手机号进行验证', style: TextStyle(fontSize: 12, color: Color(0xff999999)), @@ -136,9 +139,21 @@ class _SecurityMobileUnbindState extends State { } void _sendCode() async { - NetUtil.request('/api/v1/settings/account/security/mobile/sms', - method: NetMethod.GET, onSuccess: (result) { - Logger.debug(result); + // NetUtil.request('/api/v1/settings/account/security/mobile/sms', + // method: NetMethod.GET, onSuccess: (result) { + // Logger.debug(result); + // Fluttertoast.showToast(msg: '发送成功'); + // _second = 60; + // Timer.periodic(Duration(seconds: 1), (timer) { + // _second--; + // if (_second <= 0) { + // timer.cancel(); + // } + // setState(() {}); + // }); + // }); + bool result = await MobUtil.getTextCode(_phone, smsCodeType: SMSCodeType.UNBIND_PHONE); + if (result) { Fluttertoast.showToast(msg: '发送成功'); _second = 60; Timer.periodic(Duration(seconds: 1), (timer) { @@ -148,7 +163,9 @@ class _SecurityMobileUnbindState extends State { } setState(() {}); }); - }); + } else { + Fluttertoast.showToast(msg: '获取验证码失败'); + } } // 解绑手机号 @@ -156,12 +173,13 @@ class _SecurityMobileUnbindState extends State { NetUtil.request('/api/v1/settings/account/security/mobile/unbind', params: Map.from({ 'valid_code': _codeController.text, + 'phone': _phone, + 'zone': '86' }), method: NetMethod.POST, onSuccess: (result) { _status['mobile_setting'] = '0'; _status['code'] = _codeController.text; - Navigator.of(context).pushReplacement(CupertinoPageRoute( - builder: (context) => SecurityMobile(widget.model))); + Navigator.of(context).pushReplacement(CupertinoPageRoute(builder: (context) => SecurityMobile(widget.model))); }); } } diff --git a/lib/pages/security_page/security_page.dart b/lib/pages/security_page/security_page.dart index 8b922fc..5bc14b3 100644 --- a/lib/pages/security_page/security_page.dart +++ b/lib/pages/security_page/security_page.dart @@ -5,6 +5,9 @@ import 'package:zhiying_base_widget/pages/security_page/security_page_bloc.dart' import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +/// +/// 账号安全 +/// class SecurityPage extends StatefulWidget { final Map data; diff --git a/lib/pages/security_page/security_password/security_password.dart b/lib/pages/security_page/security_password/security_password.dart index cbe4608..b781178 100644 --- a/lib/pages/security_page/security_password/security_password.dart +++ b/lib/pages/security_page/security_password/security_password.dart @@ -8,7 +8,11 @@ import 'package:zhiying_base_widget/pages/security_page/widgets/security_bind_in import 'package:zhiying_base_widget/pages/security_page/widgets/security_code_button.dart'; import 'package:zhiying_base_widget/pages/security_page/widgets/security_confirm_button.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/mob_util/mob_util.dart'; +/// +/// 修改密码页面 +/// class SecurityPassword extends StatefulWidget { final Map model; @@ -149,10 +153,10 @@ class _SecurityPasswordState extends State { } } + /// 获取验证码 void _sendCode() async { - NetUtil.request('/api/v1/settings/account/security/password/sms', - method: NetMethod.POST, onSuccess: (result) { - Logger.debug(result); + bool result = await MobUtil.getTextCode(_phone, smsCodeType: SMSCodeType.NORMAL); + if(result){ Fluttertoast.showToast(msg: '发送成功'); _second = 60; Timer.periodic(Duration(seconds: 1), (timer) { @@ -162,7 +166,23 @@ class _SecurityPasswordState extends State { } setState(() {}); }); - }); + }else{ + Fluttertoast.showToast(msg: '获取验证码失败'); + } + + // NetUtil.request('/api/v1/settings/account/security/password/sms', + // method: NetMethod.POST, onSuccess: (result) { + // Logger.debug(result); + // Fluttertoast.showToast(msg: '发送成功'); + // _second = 60; + // Timer.periodic(Duration(seconds: 1), (timer) { + // _second--; + // if (_second <= 0) { + // timer.cancel(); + // } + // setState(() {}); + // }); + // }); } void _confirm() async { @@ -171,6 +191,8 @@ class _SecurityPasswordState extends State { 'new_password': _passwordController.text, 'new_password_ack': _confirmController.text, 'valid_code': _codeController.text, + 'phone': _phone, + 'zone': '86' }), method: NetMethod.POST, onSuccess: (result) { Logger.debug(result); diff --git a/lib/pages/security_page/security_unbind_alipay/security_unbin_alipay.dart b/lib/pages/security_page/security_unbind_alipay/security_unbin_alipay.dart index 84f5dd7..cd73011 100644 --- a/lib/pages/security_page/security_unbind_alipay/security_unbin_alipay.dart +++ b/lib/pages/security_page/security_unbind_alipay/security_unbin_alipay.dart @@ -9,6 +9,7 @@ import 'package:zhiying_base_widget/pages/security_page/widgets/security_bind_in import 'package:zhiying_base_widget/pages/security_page/widgets/security_code_button.dart'; import 'package:zhiying_base_widget/pages/security_page/widgets/security_confirm_button.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/mob_util/mob_util.dart'; class SecurityUnbinAlipay extends StatefulWidget { final Map model; @@ -128,9 +129,22 @@ class _SecurityUnbinAlipayState extends State { } void _sendCode() async { - NetUtil.request('/api/v1/settings/account/security/alipay/sms', - method: NetMethod.GET, onSuccess: (result) { - Logger.debug(result); + // NetUtil.request('/api/v1/settings/account/security/alipay/sms', + // method: NetMethod.GET, onSuccess: (result) { + // Logger.debug(result); + // Fluttertoast.showToast(msg: '发送成功'); + // _second = 60; + // Timer.periodic(Duration(seconds: 1), (timer) { + // _second--; + // if (_second <= 0) { + // timer.cancel(); + // } + // setState(() {}); + // }); + // }); + + bool result = await MobUtil.getTextCode(_status['mobile_setting_text'], smsCodeType: SMSCodeType.BIND_ALIPAY); + if (result) { Fluttertoast.showToast(msg: '发送成功'); _second = 60; Timer.periodic(Duration(seconds: 1), (timer) { @@ -140,18 +154,23 @@ class _SecurityUnbinAlipayState extends State { } setState(() {}); }); - }); + } else { + Fluttertoast.showToast(msg: '获取验证码失败'); + } } void _unbind() async { NetUtil.request('/api/v1/settings/account/security/alipay/unbind', - params: Map.from({'valid_code': _codeController.text}), + params: Map.from({ + 'valid_code': _codeController.text, + 'phone': _status['mobile_setting_text'], + 'zone': '86', + }), method: NetMethod.POST, onSuccess: (result) { Logger.debug(result); Fluttertoast.showToast(msg: '解绑成功'); _status['alipay_setting'] = '0'; - Navigator.of(context).pushReplacement(CupertinoPageRoute( - builder: (context) => SecurityBindAlipayPage(widget.model))); + Navigator.of(context).pushReplacement(CupertinoPageRoute(builder: (context) => SecurityBindAlipayPage(widget.model))); }); } } diff --git a/lib/register.dart b/lib/register.dart index 566a54c..72b61cb 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -79,8 +79,7 @@ import 'widgets/search/input/search_input_widget.dart'; import 'widgets/search/tabbar/search_tab_creater.dart'; import 'widgets/search_result/goods_list/search_result_goods_list_creater.dart'; import 'widgets/search_result/search_input/search_result_input.dart'; -import 'package:secverify/secverify.dart'; -import 'package:zhiying_comm/util/second_test/second_test_util.dart'; +import 'package:zhiying_comm/util/mob_util/mob_util.dart'; class BaseWidgetRegister { /// 初始化方法 @@ -129,7 +128,7 @@ class BaseWidgetRegister { }); // MOB 秒验 - SecondTestUtil.getInstance().init(); + MobUtil.init(); Application.addMethod(() async { return Future.delayed(Duration(seconds: 1));