diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 46b14a5..ebfda1c 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -596,7 +596,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-29T06:14:15.252464Z", + "generated": "2020-09-29T07:01:40.444026Z", "generator": "pub", "generatorVersion": "2.7.2" } diff --git a/lib/pages/goods_share_page/goods_share_page.dart b/lib/pages/goods_share_page/goods_share_page.dart index c8b74f7..dffc0e2 100644 --- a/lib/pages/goods_share_page/goods_share_page.dart +++ b/lib/pages/goods_share_page/goods_share_page.dart @@ -74,6 +74,8 @@ class _GoodsShareContainerState extends State<_GoodsShareContainer> _contents.add(GoodsShareLink(item)); } else if (mod_name == 'share_goods_mini.taobao') { _contents.add(GoodsShareMiniprogram(item)); + } else { + _contents.add(Container()); } }); diff --git a/lib/utils/image_download_util/image_download_util.dart b/lib/utils/image_download_util/image_download_util.dart new file mode 100644 index 0000000..2ac1312 --- /dev/null +++ b/lib/utils/image_download_util/image_download_util.dart @@ -0,0 +1,38 @@ +import 'dart:io'; + +import 'package:dio/dio.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class ImageDownloadUtil { + static Future> download(List urls) async { + try { + var dict = await getPhoneLocalPath(); + + Dio dio = Dio(); + var paths = await Future.wait(urls.map((url) async { + String path = '${dict.path}/${EncodeUtil.generateMd5(url)}.jpg'; + Logger.debug('图片下载地址 ${path.toString()}'); + await dio.download(url, path); + return path; + }).toList()); + + return paths; + // return paths.map((path) { + // return File(path); + // }).toList(); + } catch (err) { + Logger.error(err); + } + return []; + } + + ///获取手机的存储目录路径 + static Future getPhoneLocalPath() async { + if (Platform.isIOS) { + return getTemporaryDirectory(); + } else if (Platform.isAndroid) { + return getExternalStorageDirectory(); + } + } +} diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart index eef717d..3f6a756 100644 --- a/lib/widgets/share/share_alert.dart +++ b/lib/widgets/share/share_alert.dart @@ -1,7 +1,9 @@ +import 'dart:io'; import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:sharesdk_plugin/sharesdk_plugin.dart'; +import 'package:zhiying_base_widget/utils/image_download_util/image_download_util.dart'; import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; import 'package:zhiying_base_widget/widgets/share/models/share_plateform.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -151,7 +153,7 @@ class _ShareAlertContent extends StatelessWidget { ); } - void _shareByMob(SharePlateform plateform) { + void _shareByMob(SharePlateform plateform) async { //单独公共分享 SSDKMap params = SSDKMap() ..setGeneral( @@ -186,10 +188,9 @@ class _ShareAlertContent extends StatelessWidget { break; } if (model.image is List && (model.image as List).length > 1) { - // p = ShareSDKPlatforms.sina; - // Share.shareFiles(model.image); - ShareExtend.share( - "share text", "text"); + List paths = await ImageDownloadUtil.download(model.image); + ShareExtend.shareMultiple( + paths, "image", subject: ""); return; }