From 1ad4d86d0c63822f475cbe31df8468b57710acfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Mon, 8 Feb 2021 17:42:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=A4=9A=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 11 +- .../android/app/src/main/AndroidManifest.xml | 4 +- example/lib/main.dart | 2 + example/pubspec.yaml | 8 +- .../goods_share_image/goods_share_image.dart | 67 +++++------ .../goods_share_link/goods_share_link.dart | 2 +- .../image_download_util.dart | 12 +- .../model/goods_details_footer_model.dart | 108 +++++++----------- lib/widgets/share/share_alert.dart | 48 ++++---- lib/zhiying_base_widget.dart | 2 +- pubspec.yaml | 9 +- 11 files changed, 131 insertions(+), 142 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 67bbf41..0e7c865 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -53,7 +53,8 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { //选择要添加的对应cpu类型的.so库。 - abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' + abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a' + // abiFilters 'armeabi-v7a','x86_64' } } @@ -107,14 +108,14 @@ android { } - // 应用信息配置 +// // 应用信息配置 // productFlavors { // // 智夜生活 // zhiying { // applicationId "cn.zhios.zhiying" -// versionCode 39 +// versionCode 45 // dimension "app" -// versionName '1.2.39' +// versionName '1.3.3' // // 签名信息 // signingConfig signingConfigs.zhiying // } @@ -162,7 +163,7 @@ dependencies { androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' -//登陆 + //登陆 implementation 'com.ali.auth.sdk:alibabauth_core:2.0.0.11@aar' implementation 'com.ali.auth.sdk:alibabauth_ui:2.0.0.11@aar' implementation 'com.ali.auth.sdk:alibabauth_ext:2.0.0.11@aar' diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 4bf224b..fc4845f 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -26,8 +26,8 @@ - - + + { NewUserFreeRegister.init(); WeChatTeachRegister.init(); FriendCircleRegister.init(); + MemberUpgradeRegister.init(); print('初始化百川'); FlutterAlibc.initAlibc(version: "", appName: "").then((result) { print("白川" + '${result.errorCode} ${result.errorMessage}'); diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 74e6da9..50f362c 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -38,8 +38,14 @@ dev_dependencies: zhiying_moments: #path: ../zhiying_moments git: - ref: 0.1.1 + ref: 0.1.5 url: http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_moments.git + #会员升级 + zhiying_member_upgrade: + #path: ../Zhiying_Member_Upgrade + git: + ref: 0.0.1 + url: http://192.168.0.138:3000/FnuoOS_ZhiYing/Zhiying_Member_Upgrade.git # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart index accd50b..ffb644c 100644 --- a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart +++ b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart @@ -33,8 +33,7 @@ class GoodsShareImage extends StatefulWidget { final Map params; final String shareType; - const GoodsShareImage(this.model, this.params, this.shareType, {Key key}) - : super(key: key); + const GoodsShareImage(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareImageState createState() => _GoodsShareImageState(); @@ -45,8 +44,7 @@ class _GoodsShareImageState extends State { Widget build(BuildContext context) { return BlocProvider( bloc: GoodsShareContentBloc(), - child: _GoodsShareImageContent( - widget.model, widget.params, widget.shareType), + child: _GoodsShareImageContent(widget.model, widget.params, widget.shareType), ); } } @@ -56,16 +54,13 @@ class _GoodsShareImageContent extends StatefulWidget { final Map params; final String shareType; - const _GoodsShareImageContent(this.model, this.params, this.shareType, - {Key key}) - : super(key: key); + const _GoodsShareImageContent(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareImageContentState createState() => _GoodsShareImageContentState(); } -class _GoodsShareImageContentState extends State<_GoodsShareImageContent> - with AutomaticKeepAliveClientMixin { +class _GoodsShareImageContentState extends State<_GoodsShareImageContent> with AutomaticKeepAliveClientMixin { GlobalKey _globalKey = GlobalKey(); GoodsShareImageModel _style; Map _images = Map(); @@ -123,10 +118,7 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> onEditorClick: () { Fluttertoast.showToast(msg: '正在开发中'); return; - Navigator.push( - context, - CupertinoPageRoute( - builder: (context) => GoodsShareEditor(_style))); + Navigator.push(context, CupertinoPageRoute(builder: (context) => GoodsShareEditor(_style))); }, onTempChange: (temp) { setState(() { @@ -183,6 +175,17 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> }, ), ); + + List moreImageList = List(); + try{ + moreImageList = List.from(widget?.params['image_url_list']).map((e) => e.toString()).toList(); + }catch(e,s){ + print(e); + print(s); + } + + _style.customImage.addAll(moreImageList); + _style.customImage=_style.customImage.reversed.toList(); for (int index = 0; index < _style.customImage.length; index++) { String image = _style.customImage[index]; // 分享图片 @@ -211,16 +214,9 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> child: Container( margin: EdgeInsets.only(bottom: 4), padding: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(8), - bottomRight: Radius.circular(8))), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))), child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: widgets), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: widgets), ), ), ), @@ -235,12 +231,9 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> if (shareImages == null) { return Container(); } - CustomButtonModel btnCopy = CustomButtonModel.fromJson( - Map.from(shareImages['copy_btn'])); - CustomButtonModel btnSave = CustomButtonModel.fromJson( - Map.from(shareImages['save_btn'])); - CustomButtonModel btnShare = CustomButtonModel.fromJson( - Map.from(shareImages['share_btn'])); + CustomButtonModel btnCopy = CustomButtonModel.fromJson(Map.from(shareImages['copy_btn'])); + CustomButtonModel btnSave = CustomButtonModel.fromJson(Map.from(shareImages['save_btn'])); + CustomButtonModel btnShare = CustomButtonModel.fromJson(Map.from(shareImages['share_btn'])); return SafeArea( child: Container( margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), @@ -317,8 +310,7 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> _shareModel.image = null; } - if ((_shareModel.image == null || _shareModel.image.length == 0) && - _shareModel.poster == null) { + if ((_shareModel.image == null || _shareModel.image.length == 0) && _shareModel.poster == null) { Fluttertoast.showToast(msg: '请选择要保存的图片'); Loading.dismiss(); return; @@ -352,14 +344,16 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> } List paths = await ImageDownloadUtil.download(images); - paths.forEach((path) async { - Uint8List data = File(path).readAsBytesSync(); + for(var item in paths){ + Uint8List data = File(item).readAsBytesSync(); isSaveSuccess = await SaveImage.save(imageBytes: data); - }); - if (isSaveSuccess) + } + if (isSaveSuccess) { Fluttertoast.showToast(msg: '保存成功'); - else + } else{ Fluttertoast.showToast(msg: '保存失败'); + } + Loading.dismiss(); } @@ -371,8 +365,7 @@ class _GoodsShareImageContentState extends State<_GoodsShareImageContent> RenderRepaintBoundary boundary = buildContext.findRenderObject(); ui.Image image = await boundary.toImage(pixelRatio: 2.0); // 注意:png是压缩后格式,如果需要图片的原始像素数据,请使用rawRgba - ByteData byteData = - await image.toByteData(format: ui.ImageByteFormat.png); + ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png); Uint8List pngBytes = byteData.buffer.asUint8List(); _shareModel.poster = pngBytes; } diff --git a/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart b/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart index 7c2b36a..b40199e 100644 --- a/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart +++ b/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart @@ -180,7 +180,7 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> } Widget _createBottom() { - Map shareImages = _style?.cssList?.shareImage ?? {}; + Map shareImages = _style?.cssList?.shareImage; if (shareImages == null) { return Container(); } diff --git a/lib/utils/image_download_util/image_download_util.dart b/lib/utils/image_download_util/image_download_util.dart index 2ac1312..d665620 100644 --- a/lib/utils/image_download_util/image_download_util.dart +++ b/lib/utils/image_download_util/image_download_util.dart @@ -7,11 +7,17 @@ import 'package:zhiying_comm/zhiying_comm.dart'; class ImageDownloadUtil { static Future> download(List urls) async { try { - var dict = await getPhoneLocalPath(); - + // var dict = await getPhoneLocalPath(); + // var dict = await getTemporaryDirectory(); + Directory dict; + if (Platform.isAndroid) { + dict = await getTemporaryDirectory(); + } else { + dict = await getPhoneLocalPath(); + } Dio dio = Dio(); var paths = await Future.wait(urls.map((url) async { - String path = '${dict.path}/${EncodeUtil.generateMd5(url)}.jpg'; + String path = '${dict.path}/${EncodeUtil.generateMd5(url)}.png'; Logger.debug('图片下载地址 ${path.toString()}'); await dio.download(url, path); return path; diff --git a/lib/widgets/goods_details/footer/model/goods_details_footer_model.dart b/lib/widgets/goods_details/footer/model/goods_details_footer_model.dart index da89c3a..1e358b9 100644 --- a/lib/widgets/goods_details/footer/model/goods_details_footer_model.dart +++ b/lib/widgets/goods_details/footer/model/goods_details_footer_model.dart @@ -1,4 +1,3 @@ - import 'package:zhiying_comm/zhiying_comm.dart'; class GoodsDetailsFooterModel { @@ -56,9 +55,8 @@ class GoodsDetailsFooterModel { topRightRadius: json['top_right_radius'], bottomLeftRadius: json['bottom_left_radius'], bottomRightRadius: json['bottom_right_radius'], - bgColor : json['bg_color'], - listStyle : json['list_style'] != null? new ListStyle.fromJson(json['list_style']): null - ); + bgColor: json['bg_color'], + listStyle: json['list_style'] != null ? new ListStyle.fromJson(json['list_style']) : null); } GoodsDetailsFooterModel({ @@ -145,21 +143,22 @@ class FavArgs { String marketPrice; String currentPrice; String inorderCount; - Null detailData; - - FavArgs({this.provider, - this.providerName, - this.goodId, - this.goodImage, - this.goodTitle, - this.shopName, - this.coupon, - this.couponUrl, - this.commission, - this.marketPrice, - this.currentPrice, - this.inorderCount, - this.detailData}); + dynamic detailData; + + FavArgs( + {this.provider, + this.providerName, + this.goodId, + this.goodImage, + this.goodTitle, + this.shopName, + this.coupon, + this.couponUrl, + this.commission, + this.marketPrice, + this.currentPrice, + this.inorderCount, + this.detailData}); FavArgs.fromJson(Map json) { provider = json['provider']; @@ -205,10 +204,14 @@ class ShareUrlArgs { String selfbuyCommission; String title; String type; + List imageUrlList; - ShareUrlArgs({this.buyUrl, this.coupon, this.couponPrice, this.marketPrice, this.posterImage, this.selfbuyCommission, this.title, this.type}); + ShareUrlArgs({this.buyUrl, this.coupon, this.couponPrice, this.marketPrice, this.posterImage, this.selfbuyCommission, this.title, this.type,this.imageUrlList}); ShareUrlArgs.fromJson(Map json) { + if (json['image_url_list'] != null) { + imageUrlList = List.from(json['image_url_list']).map((e) => e.toString()).toList(); + } buyUrl = json['buy_url']; coupon = json['coupon']; couponPrice = json['coupon_price']; @@ -216,7 +219,9 @@ class ShareUrlArgs { posterImage = json['poster_image']; selfbuyCommission = json['selfbuy_commission']; title = json['title']; + type = json['type']; + } Map toJson() { @@ -229,6 +234,7 @@ class ShareUrlArgs { data['selfbuy_commission'] = this.selfbuyCommission; data['title'] = this.title; data['type'] = this.type; + data['image_url_list']=this.imageUrlList; return data; } } @@ -267,7 +273,6 @@ class ConvertArgs { } } - class ListStyle { LeftIcon1 leftIcon1; LeftIcon1 leftIcon2; @@ -276,32 +281,15 @@ class ListStyle { BuyBubbleTip buyBubbleTip; BuyBubbleTip buyShareTip; - ListStyle({this.leftIcon1, - this.leftIcon2, - this.rightIcon1, - this.rightIcon2, - this.buyBubbleTip, - this.buyShareTip}); + ListStyle({this.leftIcon1, this.leftIcon2, this.rightIcon1, this.rightIcon2, this.buyBubbleTip, this.buyShareTip}); ListStyle.fromJson(Map json) { - leftIcon1 = json['left_icon1'] != null - ? new LeftIcon1.fromJson(json['left_icon1']) - : null; - leftIcon2 = json['left_icon2'] != null - ? new LeftIcon1.fromJson(json['left_icon2']) - : null; - rightIcon1 = json['right_icon1'] != null - ? new RightIcon1.fromJson(json['right_icon1']) - : null; - rightIcon2 = json['right_icon2'] != null - ? new RightIcon1.fromJson(json['right_icon2']) - : null; - buyBubbleTip = json['buy_bubble_tip'] != null - ? new BuyBubbleTip.fromJson(json['buy_bubble_tip']) - : null; - buyShareTip = json['buy_share_tip'] != null - ? new BuyBubbleTip.fromJson(json['buy_share_tip']) - : null; + leftIcon1 = json['left_icon1'] != null ? new LeftIcon1.fromJson(json['left_icon1']) : null; + leftIcon2 = json['left_icon2'] != null ? new LeftIcon1.fromJson(json['left_icon2']) : null; + rightIcon1 = json['right_icon1'] != null ? new RightIcon1.fromJson(json['right_icon1']) : null; + rightIcon2 = json['right_icon2'] != null ? new RightIcon1.fromJson(json['right_icon2']) : null; + buyBubbleTip = json['buy_bubble_tip'] != null ? new BuyBubbleTip.fromJson(json['buy_bubble_tip']) : null; + buyShareTip = json['buy_share_tip'] != null ? new BuyBubbleTip.fromJson(json['buy_share_tip']) : null; } Map toJson() { @@ -328,7 +316,7 @@ class ListStyle { } } -class LeftIcon1 extends SkipModel{ +class LeftIcon1 extends SkipModel { String text; String color; String beforeIcon; @@ -339,14 +327,7 @@ class LeftIcon1 extends SkipModel{ String isJump; String isShow; - LeftIcon1({this.text, - this.color, - this.beforeIcon, - this.afterIcon, - this.skipIdentifier, - this.requiredLogin, - this.requiredTaobaoAuth, - this.isJump}); + LeftIcon1({this.text, this.color, this.beforeIcon, this.afterIcon, this.skipIdentifier, this.requiredLogin, this.requiredTaobaoAuth, this.isJump}); LeftIcon1.fromJson(Map json) { super.fromJson(json); @@ -358,7 +339,7 @@ class LeftIcon1 extends SkipModel{ requiredLogin = json['required_login']; requiredTaobaoAuth = json['required_taobao_auth']; isJump = json['is_jump']; - isShow=json['is_show']; + isShow = json['is_show']; } Map toJson() { @@ -384,12 +365,7 @@ class RightIcon1 { List sourceList; String isShow; - RightIcon1({this.text, - this.color, - this.btnStr, - this.bgImage, - this.functionType, - this.sourceList}); + RightIcon1({this.text, this.color, this.btnStr, this.bgImage, this.functionType, this.sourceList}); RightIcon1.fromJson(Map json) { text = json['text']; @@ -398,7 +374,7 @@ class RightIcon1 { bgImage = json['bg_image']; functionType = json['function_type']; sourceList = json['source_list'].cast(); - isShow=json['is_show']; + isShow = json['is_show']; } Map toJson() { @@ -422,13 +398,7 @@ class BuyBubbleTip { String isShow; List sourceList; - BuyBubbleTip({this.textStr, - this.textColor, - this.priceIcon, - this.bgImage, - this.closeIcon, - this.isShow, - this.sourceList}); + BuyBubbleTip({this.textStr, this.textColor, this.priceIcon, this.bgImage, this.closeIcon, this.isShow, this.sourceList}); BuyBubbleTip.fromJson(Map json) { textStr = json['text_str']; diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart index b7ab864..992bc51 100644 --- a/lib/widgets/share/share_alert.dart +++ b/lib/widgets/share/share_alert.dart @@ -42,7 +42,6 @@ class _ShareAlertState extends State { // }catch(e){ // print(e); // } - }, onSuccess: (data) { print(data); _parseData(data); @@ -107,6 +106,17 @@ class _ShareAlertContent extends StatefulWidget { } class _ShareAlertContentState extends State<_ShareAlertContent> { + @override + void initState() { + Future.delayed(Duration(milliseconds: 100), () async { + var status = await Permission.storage.status; + if (status != PermissionStatus.granted) { + status = await Permission.storage.request(); + } + }); + super.initState(); + } + @override Widget build(BuildContext context) { return GestureDetector( @@ -233,11 +243,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { // mob分享,只能单图分享,多图分享调用系统分享 void _shareByMob(ShareSDKPlatform plateform) async { - - - Loading.show(context); - Timer(Duration(milliseconds: 2000),(){ + Timer(Duration(milliseconds: 2000), () { Loading.dismiss(); }); @@ -261,25 +268,24 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { ); } } else { + var type = SSDKContentTypes.auto; - var type=SSDKContentTypes.auto; - - if(widget?.model?.image?.first!=null&&widget.model?.url!=null){ - type=SSDKContentTypes.webpage; - }else if(widget?.model?.image?.first!=null){ - type=SSDKContentTypes.image; - }else if(widget?.model?.title!=null||widget.model?.content!=null){ - type=SSDKContentTypes.text; + if (widget?.model?.image?.first != null && widget.model?.url != null) { + type = SSDKContentTypes.webpage; + } else if (widget?.model?.image?.first != null) { + type = SSDKContentTypes.image; + } else if (widget?.model?.title != null || widget.model?.content != null) { + type = SSDKContentTypes.text; } - if(plateform==ShareSDKPlatforms.qZone){ - widget?.model?.title=null; - type=SSDKContentTypes.message; + if (plateform == ShareSDKPlatforms.qZone && type == SSDKContentTypes.text) { + widget?.model?.title = null; + type = SSDKContentTypes.message; } params = SSDKMap() ..setGeneral( widget.model?.title ?? '', - widget?.model?.content??'', + widget?.model?.content ?? '', Platform.isIOS ? widget.model.image : null, Platform.isAndroid ? widget?.model?.image?.first : null, null, @@ -336,7 +342,7 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { if (status != PermissionStatus.granted) { status = await Permission.storage.request(); } - if (status == PermissionStatus.denied) { + if (status != PermissionStatus.granted) { Fluttertoast.showToast(msg: '暂无权限,分享失败'); return null; } @@ -368,9 +374,11 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { Loading.show(context); List downPaths = await ImageDownloadUtil.download(widget.model.image); paths.addAll(downPaths); - if(Platform.isAndroid&&type=='wx'){ + if (Platform.isAndroid && type == 'wx') { MorePictureShare.shareWeixinPics(paths); - }else{ + } else if (Platform.isAndroid && type == 'pyq') { + MorePictureShare.shareWeixinPicsCirlc(paths); + } else { ShareExtend.shareMultiple(paths, "image", subject: ""); } Loading.dismiss(); diff --git a/lib/zhiying_base_widget.dart b/lib/zhiying_base_widget.dart index c210465..c4849a4 100644 --- a/lib/zhiying_base_widget.dart +++ b/lib/zhiying_base_widget.dart @@ -3,4 +3,4 @@ library zhiying_base_widget; export 'dialog/loading/loading.dart'; export 'package:flutter_swiper/flutter_swiper.dart'; export 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; -export 'package:zhiying_base_widget/pages/custom_page/bloc/background_bloc.dart'; \ No newline at end of file +export 'package:zhiying_base_widget/pages/custom_page/bloc/background_bloc.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index a4b4163..7dbe21d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,13 +15,16 @@ dependencies: bloc: ^4.0.0 event_bus: ^1.1.1 pull_to_refresh: - path: ../../1.22.0_master/flutter_pulltorefresh + git: + url: 'http://192.168.0.138:3000/FnuoOS_ZhiYing/flutter_pulltorefresh.git' + ref: '0.0.1' flutter_cupertino_date_picker: - path: ../../1.22.0_master/flutter-cupertino-date-picker + git: + url: 'http://192.168.0.138:3000/FnuoOS_ZhiYing/flutter-cupertino-date-picker.git' + ref: '0.0.1' image_picker: ^0.6.7+3 tab_indicator_styler: 1.0.0 connectivity: ^0.4.9+3 - save_image: ^1.0.1 image_cropper: git: url: 'http://192.168.0.138:3000/FnuoOS_Flutter_Components/Image_Cropper.git'