From a05d9cd9d3b579c6f209dbd32ca50a6f96725c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Fri, 14 May 2021 10:07:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=88=86=E4=BA=AB=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B0=E6=B5=AA=E5=BE=AE=E5=8D=9A=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=88=86=E4=BA=AB=E5=9B=BE=E7=89=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/widgets/share/share_alert.dart | 42 ++++++++++++++++++++--- lib/widgets/share/share_alert_select.dart | 32 +++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart index 7f900e7..9d8de49 100644 --- a/lib/widgets/share/share_alert.dart +++ b/lib/widgets/share/share_alert.dart @@ -278,8 +278,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { if (path != null && path != '') { params = SSDKMap() ..setGeneral( - widget.model?.title ?? '', - widget.model?.content ?? '', + widget.model?.title ?? '图片分享', + widget.model?.content ?? '更多好事物', Platform.isIOS ? path : null, null, Platform.isAndroid ? path : null, @@ -300,6 +300,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { type = SSDKContentTypes.image; } else if (widget?.model?.title != null || widget.model?.content != null) { type = SSDKContentTypes.text; + } else if (widget?.model?.poster != null) { + type = SSDKContentTypes.image; } if (plateform == ShareSDKPlatforms.qZone && widget?.model?.content != null) { widget?.model?.title = null; @@ -340,8 +342,8 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { params = SSDKMap() ..setGeneral( - widget.model?.title ?? '', - widget?.model?.content ?? '', + widget.model?.title ?? '~', + widget?.model?.content ?? '~', Platform.isIOS ? widget.model.image : null, Platform.isAndroid ? (isExistImage ? widget?.model?.image?.first : null) : null, null, @@ -353,6 +355,38 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { type, ); } + + var isExistImage = false; + + if (widget?.model?.image != null && widget?.model?.image?.length > 0) { + isExistImage = true; + } + + ///新浪分享图片 + if (plateform == ShareSDKPlatforms.sina && + (isExistImage || widget?.model?.poster != null) && + EmptyUtil.isEmpty(widget?.model?.content) && + EmptyUtil.isEmpty(widget?.model?.url)) { + SSDKMap params2 = SSDKMap() + ..setSina( + "图片分享", + null, + null, + null, + null, + null, + null, + null, + false, + (isExistImage ? widget?.model?.image.first : null), + params.map["imagePath_android"], + SSDKContentTypes.image, + ); + print(params2); + SharesdkPlugin.share(ShareSDKPlatforms.sina, params2, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) {}); + return; + } + SharesdkPlugin.share(plateform, params, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) { print(error); if (state == SSDKResponseState.Fail) { diff --git a/lib/widgets/share/share_alert_select.dart b/lib/widgets/share/share_alert_select.dart index 3ad0da9..3e220d3 100644 --- a/lib/widgets/share/share_alert_select.dart +++ b/lib/widgets/share/share_alert_select.dart @@ -493,6 +493,38 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { type, ); } + + var isExistImage = false; + + if (widget?.model?.image != null && widget?.model?.image?.length > 0) { + isExistImage = true; + } + + ///新浪分享图片 + if (plateform == ShareSDKPlatforms.sina && + (isExistImage || widget?.model?.poster != null) && + EmptyUtil.isEmpty(widget?.model?.content) && + EmptyUtil.isEmpty(widget?.model?.url)) { + SSDKMap params2 = SSDKMap() + ..setSina( + "图片分享", + null, + null, + null, + null, + null, + null, + null, + false, + (isExistImage ? widget?.model?.image.first : null), + params.map["imagePath_android"], + SSDKContentTypes.image, + ); + print(params2); + SharesdkPlugin.share(ShareSDKPlatforms.sina, params2, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) {}); + return; + } + SharesdkPlugin.share(plateform, params, (SSDKResponseState state, Map userdata, Map contentEntity, SSDKError error) { print(error); if (state == SSDKResponseState.Fail) {