Commit d30312d44d73911b5cab0b6da49b3d98e00529b1

Authored by wdn127929
1 parent 8274bc18

预订安排自定义图文 删除图片 OK

@@ -68,6 +68,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -68,6 +68,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
68 68
69 MarketingCenterProvider marketingCenterProvider; 69 MarketingCenterProvider marketingCenterProvider;
70 70
  71 + List<String> imgAll = [];
  72 +
71 @override 73 @override
72 void initState() { 74 void initState() {
73 super.initState(); 75 super.initState();
@@ -121,6 +123,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -121,6 +123,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
121 additionModel.image.process = 1; 123 additionModel.image.process = 1;
122 additionModel.image.qiniuUrl = contentModel.content; 124 additionModel.image.qiniuUrl = contentModel.content;
123 data.add(additionModel); 125 data.add(additionModel);
  126 +
  127 + imgAll.add(contentModel.content);
124 } else { 128 } else {
125 AdditionModel additionModel = AdditionModel(); 129 AdditionModel additionModel = AdditionModel();
126 additionModel.content = contentModel.content; 130 additionModel.content = contentModel.content;
@@ -215,6 +219,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -215,6 +219,8 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
215 // 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641'; 219 // 'https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641';
216 220
217 data[index] = additionModel; 221 data[index] = additionModel;
  222 +
  223 + imgAll.add(imgModel.qiniuUrl);
218 setState(() {}); 224 setState(() {});
219 }); 225 });
220 } 226 }
@@ -738,6 +744,7 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -738,6 +744,7 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
738 element.infoC.text == null)); 744 element.infoC.text == null));
739 if (can) { 745 if (can) {
740 List temp = []; 746 List temp = [];
  747 + List<String> delImgs = [];
741 for (int i = 0; i < data.length; i++) { 748 for (int i = 0; i < data.length; i++) {
742 AdditionModel element = data[i]; 749 AdditionModel element = data[i];
743 temp.add({ 750 temp.add({
@@ -746,6 +753,9 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -746,6 +753,9 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
746 ? element.infoC.text 753 ? element.infoC.text
747 : element.image.qiniuUrl, 754 : element.image.qiniuUrl,
748 }); 755 });
  756 + if (element.type != '2') {
  757 + delImgs.add(element.image.qiniuUrl);
  758 + }
749 } 759 }
750 760
751 Map<String, String> params = { 761 Map<String, String> params = {
@@ -764,6 +774,18 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> { @@ -764,6 +774,18 @@ class _InvicationAdditionPageState extends State<InvicationAdditionPage> {
764 bool success = await marketingCenterProvider 774 bool success = await marketingCenterProvider
765 .setReserveImgText(context, params); 775 .setReserveImgText(context, params);
766 if (success) { 776 if (success) {
  777 + // imgAll和images 比较,挑出不一样的,删除七牛云
  778 + Set<String> difference = Set.from(imgAll)
  779 + ..removeAll(delImgs);
  780 + List<String> differenceList =
  781 + difference.toList(); //需要删除的图片
  782 + if (differenceList.length > 0) {
  783 + String delImgs =
  784 + Utils.listToStringEnglish(differenceList);
  785 +
  786 + _uploadImageProvider.deleteImg(context, delImgs,
  787 + needToast: false);
  788 + }
767 bus.emit('getReserveImgText'); 789 bus.emit('getReserveImgText');
768 Navigator.pop(context); 790 Navigator.pop(context);
769 } 791 }