diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 0e9eb7e..045641f 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -301,6 +301,12 @@ "packageUri": "lib/", "languageVersion": "1.12" }, + { + "name": "moblink", + "rootUri": "file:///Users/fnuouser/.pub-cache/hosted/pub.flutter-io.cn/moblink-3.4.1", + "packageUri": "lib/", + "languageVersion": "2.1" + }, { "name": "mobsms", "rootUri": "file:///Users/fnuouser/.pub-cache/hosted/pub.flutter-io.cn/mobsms-1.1.0", @@ -662,7 +668,7 @@ "languageVersion": "2.8" } ], - "generated": "2020-11-25T02:26:02.961774Z", + "generated": "2020-11-25T07:42:55.235132Z", "generator": "pub", "generatorVersion": "2.8.2" } diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6f3b74b..da722a1 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -207,6 +207,11 @@ MobSDK { appKey "30dc33054b635" appSecret "396e98c293130c9976fb7428b6b434d6" + MobLink { + uriScheme "fnoos://cn.zhios.zhiying" + appLinkHost "bied.t4m.cn" + } + //手机验证登录 SecVerify {} diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ac0ebc1..f99ba19 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -44,6 +44,8 @@ PODS: - Flutter - jdsdk (0.0.1): - Flutter + - mob_linksdk_pro (3.3.7): + - MOBFoundation - mob_secverify (3.0.1): - MOBFoundation - mob_sharesdk (4.3.11): @@ -96,6 +98,9 @@ PODS: - mob_smssdk (3.2.10): - MOBFoundation - MOBFoundation (3.2.19) + - moblink (0.0.4): + - Flutter + - mob_linksdk_pro - mobsms (0.0.1): - Flutter - mob_smssdk @@ -198,6 +203,7 @@ DEPENDENCIES: - image_picker (from `.symlinks/plugins/image_picker/ios`) - imei_plugin (from `.symlinks/plugins/imei_plugin/ios`) - jdsdk (from `.symlinks/plugins/jdsdk/ios`) + - moblink (from `.symlinks/plugins/moblink/ios`) - mobsms (from `.symlinks/plugins/mobsms/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) - path_provider (from `.symlinks/plugins/path_provider/ios`) @@ -236,6 +242,7 @@ SPEC REPOS: - WindVane https://github.com/CocoaPods/Specs.git: - FMDB + - mob_linksdk_pro - mob_secverify - mob_sharesdk - mob_smssdk @@ -272,6 +279,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/imei_plugin/ios" jdsdk: :path: ".symlinks/plugins/jdsdk/ios" + moblink: + :path: ".symlinks/plugins/moblink/ios" mobsms: :path: ".symlinks/plugins/mobsms/ios" package_info: @@ -343,10 +352,12 @@ SPEC CHECKSUMS: image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 imei_plugin: cb1af7c223ac2d82dcd1457a7137d93d65d2a3cd jdsdk: 2ca38c7e3a2dfb0f3641425f8fd1e8d20357693f + mob_linksdk_pro: 9ad768d8da15c410d51056319f43a76c7cc01347 mob_secverify: 54c03b24122be033bb53adb84694fd8c19f6c2b6 mob_sharesdk: e0d8b5807e6063cac8f9d68ef059b1d3006c9088 mob_smssdk: bd7493aa6f21e12b8daed8935c32c69552907d14 MOBFoundation: 606bc4c10ff4c6ac573c09f5081a39c75316bc7b + moblink: 3480a191e86c33f4e84af0cb5d2cc5627e78bf65 mobsms: 141956ad151a39a69a47a2ddf2e186405346c4ef mtopSDK: d6fdf81730342a69be920b576541c7bb81a683d5 package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 diff --git a/example/ios/Runner/Runner.entitlements b/example/ios/Runner/Runner.entitlements index 903def2..ff13b9a 100644 --- a/example/ios/Runner/Runner.entitlements +++ b/example/ios/Runner/Runner.entitlements @@ -4,5 +4,13 @@ aps-environment development + com.apple.developer.applesignin + + Default + + com.apple.developer.associated-domains + + applinks:bied.t4m.cn + diff --git a/example/ios/Runner/项目资源/智莺生活/config/证书/cnzhioszhiying_dev-2.mobileprovision b/example/ios/Runner/项目资源/智莺生活/config/证书/cnzhioszhiying_dev-2.mobileprovision new file mode 100644 index 0000000..57552a6 Binary files /dev/null and b/example/ios/Runner/项目资源/智莺生活/config/证书/cnzhioszhiying_dev-2.mobileprovision differ diff --git a/example/ios/Runner/项目资源/智莺生活/config/证书/zhiying_appstore.mobileprovision b/example/ios/Runner/项目资源/智莺生活/config/证书/zhiying_appstore.mobileprovision new file mode 100644 index 0000000..d1c924e Binary files /dev/null and b/example/ios/Runner/项目资源/智莺生活/config/证书/zhiying_appstore.mobileprovision differ diff --git a/example/lib/main.dart b/example/lib/main.dart index 7fae307..a31fa4b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_alibc/flutter_alibc.dart'; @@ -34,11 +32,7 @@ class _MyAppState extends State { child: Text( "走神了~\n${error.exceptionAsString()}", style: - Theme - .of(context) - .textTheme - .title - .copyWith(color: Colors.redAccent), + Theme.of(context).textTheme.title.copyWith(color: Colors.redAccent), ), ); } diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart index b112dcc..4c73bfe 100644 --- a/lib/pages/home_page/home_page.dart +++ b/lib/pages/home_page/home_page.dart @@ -3,8 +3,10 @@ import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:permission_handler/permission_handler.dart'; +import 'package:flutter/services.dart'; +import 'package:moblink/moblink.dart'; import 'package:provider/provider.dart'; import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart'; import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart'; @@ -26,6 +28,8 @@ class HomePage extends StatefulWidget { class _HomePageState extends State with WidgetsBindingObserver { int _currentIndex = 0; List> _data = List(); + static const EventChannel _eventChannel = + const EventChannel('JAVA_TO_FLUTTER'); @override void initState() { @@ -45,9 +49,43 @@ class _HomePageState extends State with WidgetsBindingObserver { TaobaoAuth.initAuth(context); _showPolicy(); + + Moblink.uploadPrivacyPermissionStatus(1, (bool success) {}); + + // 是安卓系统,Android场景还原的实现 + /*if (defaultTargetPlatform == TargetPlatform.android) { + + }*/ + + //app后台杀死时候的还原 + Moblink.restoreScene(_restore); + // 监听开始(传递监听到原生端,用户监听场景还原的数据回传回来) + _eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); + super.initState(); } + // 场景还原,记录邀请码 + void _restore(MLSDKScene scene) { + const bool inProduction = const bool.fromEnvironment("dart.vm.product"); + if (!inProduction) { + // 非release环境,弹窗测试 + showAlert('要还原的路径为:' + scene.className + '\n' + scene.params.toString(), + context); + } + Logger.debug('要还原的路径为:' + scene.className); + try { + Map params = Map.from(scene.params); + if (params.containsKey('tgid')) { + String tgid = params['tgid'].toString(); + // 记录邀请码到本地 + SharedPreferencesUtil.setNetCacheResult(Constants.mobInvitedCode, tgid); + } + } catch (e) { + Logger.debug(e); + } + } + @override void dispose() { WidgetsBinding.instance.removeObserver(this); @@ -66,7 +104,7 @@ class _HomePageState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { ScreenUtil.init(context, width: 750, height: 1334); - print('home_page build'); + Logger.debug('home_page build'); List> tabs = _data; if (tabs == null || tabs.length == 0) { return Scaffold(); @@ -173,13 +211,42 @@ class _HomePageState extends State with WidgetsBindingObserver { } } - String isShowNotiPermission = - await SharedPreferencesUtil.getStringValue(Constants.isShowNotiPermission); + String isShowNotiPermission = await SharedPreferencesUtil.getStringValue( + Constants.isShowNotiPermission); if (isShowNotiPermission == null || isShowNotiPermission != '1') { await NotificationSettingDialog.show(context); - await SharedPreferencesUtil.setStringValue(Constants.isShowNotiPermission, "1"); + await SharedPreferencesUtil.setStringValue( + Constants.isShowNotiPermission, "1"); } IntellectCreate.checkAndCreateFirst(context); } + + //app存在后台时候的还原 + void _onEvent(Object event) { + Logger.debug('返回的内容: $event'); + if (null != event) { + showAlert('要还原的路径为[活着]:$event', context); + } + } + + void _onError(Object error) { + Logger.debug('返回的错误'); + } + + void showAlert(String text, BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) => CupertinoAlertDialog( + title: new Text("提示"), + content: new Text(text), + actions: [ + new FlatButton( + child: new Text("OK"), + onPressed: () { + Navigator.of(context).pop(); + }, + ) + ])); + } } diff --git a/lib/pages/wechat_teacher_page/wechat_teacher_page.dart b/lib/pages/wechat_teacher_page/wechat_teacher_page.dart index 155deaa..07823ee 100644 --- a/lib/pages/wechat_teacher_page/wechat_teacher_page.dart +++ b/lib/pages/wechat_teacher_page/wechat_teacher_page.dart @@ -1,17 +1,17 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:zhiying_base_widget/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart'; import 'package:zhiying_base_widget/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart'; import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart'; import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart'; import 'package:zhiying_base_widget/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart'; -import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'bloc/wechat_teacher_state.dart'; + import 'bloc/wechat_teacher_event.dart'; -import 'package:fluttertoast/fluttertoast.dart'; +import 'bloc/wechat_teacher_state.dart'; /// /// 微信导师 @@ -24,7 +24,8 @@ class WechatTeacherPage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (_) => WechatTeacherBloc(WechatTeacherRepository(data))..add(WechatTeacherInitEvent()), + create: (_) => WechatTeacherBloc(WechatTeacherRepository(data)) + ..add(WechatTeacherInitEvent()), child: _WechatTeacherPageContainer(), ); } @@ -32,10 +33,12 @@ class WechatTeacherPage extends StatelessWidget { class _WechatTeacherPageContainer extends StatefulWidget { @override - _WechatTeacherPageContainerState createState() => _WechatTeacherPageContainerState(); + _WechatTeacherPageContainerState createState() => + _WechatTeacherPageContainerState(); } -class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer> { +class _WechatTeacherPageContainerState + extends State<_WechatTeacherPageContainer> { TextEditingController _editingController; /// 是否绑定中 @@ -52,7 +55,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer setState(() { _isBinding = true; }); - BlocProvider.of(context).add(WechatTeacherBindEvent(teacherWxChat: wxAccount)); + BlocProvider.of(context) + .add(WechatTeacherBindEvent(teacherWxChat: wxAccount)); } } @@ -111,7 +115,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer ); } - Widget _createMainWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { + Widget _createMainWidget( + WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { return Scaffold( appBar: _createNav(styleModel), backgroundColor: HexColor.fromHex(styleModel?.bgColor ?? '#FFF5F5F5'), @@ -119,7 +124,7 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer child: SingleChildScrollView( child: Column( children: [ - _createHeader(styleModel,dataModel), + _createHeader(styleModel, dataModel), Padding( padding: const EdgeInsets.only(top: 15), child: CachedNetworkImage( @@ -179,7 +184,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer child: CupertinoTextField( onSubmitted: (val) => _bindTeacher(), controller: _editingController, - placeholder: styleModel?.nobindTeacherDialog?.inputHintText ?? '请填写邀请人邀请码/手机号码', + placeholder: styleModel?.nobindTeacherDialog?.inputHintText ?? + '请填写邀请人邀请码/手机号码', placeholderStyle: TextStyle(fontSize: 14), decoration: BoxDecoration(), ), @@ -196,13 +202,19 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer width: 130, height: 30, decoration: BoxDecoration( - color: HexColor.fromHex(styleModel?.commStyle?.btnBgColor ?? '#FF5A5A'), + color: HexColor.fromHex( + styleModel?.commStyle?.btnBgColor ?? '#FF5A5A'), borderRadius: BorderRadius.circular(15), ), child: Center( child: Text( - _isBinding ? '绑定中...' : styleModel?.nobindTeacherDialog?.btnText ?? '绑定邀请人', - style: TextStyle(color: HexColor.fromHex(styleModel?.commStyle?.btnTextColor ?? '#FFFFFFF'), fontSize: 14), + _isBinding + ? '绑定中...' + : styleModel?.nobindTeacherDialog?.btnText ?? '绑定邀请人', + style: TextStyle( + color: HexColor.fromHex( + styleModel?.commStyle?.btnTextColor ?? '#FFFFFFF'), + fontSize: 14), ), ), ), @@ -213,7 +225,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer } /// 绑定的UI - Widget _createBindWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { + Widget _createBindWidget( + WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { return Container( width: double.infinity, height: double.infinity, @@ -224,28 +237,47 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer width: 50, height: 50, // color: Colors.red, - child: CircleAvatar(child: CachedNetworkImage(imageUrl: dataModel?.teacherAvatar ??'',)), + child: CircleAvatar( + child: CachedNetworkImage( + imageUrl: dataModel?.teacherAvatar ?? '', + )), ), const SizedBox(width: 13), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Text(dataModel?.teacherUsername ??'', style: TextStyle(fontSize: 15, color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'))), - Text('微信号: ${dataModel?.teacherWechatAccount??''}', style: TextStyle(fontSize: 15, color: HexColor.fromHex(styleModel?.commStyle.wechatAccountColor ?? '#FF5050'))), + Text(dataModel?.teacherUsername ?? '', + style: TextStyle( + fontSize: 15, + color: HexColor.fromHex( + styleModel?.teacherDialogTitleColor ?? '#3C3C3C'))), + Text('微信号: ${dataModel?.teacherWechatAccount ?? ''}', + style: TextStyle( + fontSize: 15, + color: HexColor.fromHex( + styleModel?.commStyle?.wechatAccountColor ?? + '#FF5050'))), GestureDetector( onTap: () => _copyText(dataModel?.teacherWechatAccount), child: UnconstrainedBox( child: Container( decoration: BoxDecoration( // color: Color(0xffffdada), - color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnBgColor ?? '#FFDADA'), + color: HexColor.fromHex( + styleModel?.bindTeacherDialog?.btnBgColor ?? + '#FFDADA'), borderRadius: BorderRadius.circular(20), ), - padding: EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4), + padding: + EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4), child: Text( styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加', - style: TextStyle(fontSize: 13, color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')), + style: TextStyle( + fontSize: 13, + color: HexColor.fromHex( + styleModel?.bindTeacherDialog?.btnTextColor ?? + '#FF0000')), ), ), ), @@ -264,13 +296,19 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer height: 56, // color: Colors.red, child: CachedNetworkImage( - imageUrl: dataModel?.teacherWxQrCode ?? styleModel?.myTeacher?.defalutTeacher?.qrcode ?? '', + imageUrl: dataModel?.teacherWxQrCode ?? + styleModel?.myTeacher?.defalutTeacher?.qrcode ?? + '', ), ), const SizedBox(height: 9), Text( styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码', - style: TextStyle(fontSize: 13, color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')), + style: TextStyle( + fontSize: 13, + color: HexColor.fromHex( + styleModel?.officalWxchat?.qrcodeTextColor ?? + '#999999')), ), ], ), @@ -282,7 +320,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer ); } - Widget _createHeader(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { + Widget _createHeader( + WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { return Container( width: double.infinity, height: 283, @@ -308,7 +347,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer margin: EdgeInsets.only(left: 10, right: 10), padding: EdgeInsets.all(12), decoration: BoxDecoration( - color: HexColor.fromHex(styleModel?.teacherDialogBgColor ?? '#FFFFFF'), + color: HexColor.fromHex( + styleModel?.teacherDialogBgColor ?? '#FFFFFF'), borderRadius: BorderRadius.circular(10), ), child: Column( @@ -320,7 +360,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer style: TextStyle( fontWeight: FontWeight.bold, fontSize: 15, - color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'), + color: HexColor.fromHex( + styleModel?.teacherDialogTitleColor ?? '#3C3C3C'), ), ), Expanded( @@ -345,7 +386,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer margin: EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 22), padding: EdgeInsets.all(12), decoration: BoxDecoration( - color: HexColor.fromHex(styleModel?.officalWxchat?.bgColor ?? '#FFFFFF'), + color: + HexColor.fromHex(styleModel?.officalWxchat?.bgColor ?? '#FFFFFF'), borderRadius: BorderRadius.circular(10), ), child: Column( @@ -355,7 +397,8 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer Text( styleModel?.officalWxchat?.title ?? '官方微信', style: TextStyle( - color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#3C3C3C'), + color: HexColor.fromHex( + styleModel?.officalWxchat?.titleColor ?? '#3C3C3C'), fontSize: 15, fontWeight: FontWeight.bold, ), @@ -372,7 +415,11 @@ class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer if (length > 0) { styleModel.officalWxchat.list.forEach((element) { widgets.add(WechatTeachetItem(element, styleModel)); - widgets.add(Container(margin: EdgeInsets.only(top: 4, bottom: 4), width: double.infinity, height: 0.5, color: Color(0xffebebeb))); + widgets.add(Container( + margin: EdgeInsets.only(top: 4, bottom: 4), + width: double.infinity, + height: 0.5, + color: Color(0xffebebeb))); }); widgets.removeLast(); } else { diff --git a/lib/utils/contants.dart b/lib/utils/contants.dart index 77dee28..c189401 100644 --- a/lib/utils/contants.dart +++ b/lib/utils/contants.dart @@ -21,11 +21,15 @@ class Constants { //==============================弹窗===================================start ///用户协议显示 static String isShowPolicy = "is_show_policy"; + ///推送权限弹窗 static String isShowNotiPermission = "isShowNotiPermission"; + //==============================弹窗===================================end //==============================版本号,控制引导页显示=================================== static String versionNumber = "versionNumber"; + //==============================Mob场景还原邀请码=================================== + static String mobInvitedCode = "mobInvitedCode"; }