Przeglądaj źródła

添加系统多图分享

tags/0.0.1
Weller 4 lat temu
rodzic
commit
16848e28bc
4 zmienionych plików z 47 dodań i 6 usunięć
  1. +1
    -1
      .dart_tool/package_config.json
  2. +2
    -0
      lib/pages/goods_share_page/goods_share_page.dart
  3. +38
    -0
      lib/utils/image_download_util/image_download_util.dart
  4. +6
    -5
      lib/widgets/share/share_alert.dart

+ 1
- 1
.dart_tool/package_config.json Wyświetl plik

@@ -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"
}

+ 2
- 0
lib/pages/goods_share_page/goods_share_page.dart Wyświetl plik

@@ -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());
}
});



+ 38
- 0
lib/utils/image_download_util/image_download_util.dart Wyświetl plik

@@ -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<List<String>> download(List<String> 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<Directory> getPhoneLocalPath() async {
if (Platform.isIOS) {
return getTemporaryDirectory();
} else if (Platform.isAndroid) {
return getExternalStorageDirectory();
}
}
}

+ 6
- 5
lib/widgets/share/share_alert.dart Wyświetl plik

@@ -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<String> paths = await ImageDownloadUtil.download(model.image);
ShareExtend.shareMultiple(
paths, "image", subject: "");
return;
}



Ładowanie…
Anuluj
Zapisz