From f79d6b228744ce6a35a16c79b3ff8579d0398da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Tue, 23 Mar 2021 19:23:07 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=88=86=E4=BA=AB=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E3=80=81=E6=8E=A5=E9=80=9A=E5=88=86=E4=BA=AB=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods_share_link/goods_share_link.dart | 71 +++++++++---------- .../goods_share_miniprogram.dart | 12 ++-- .../models/goods_share_temp_add_model.dart | 25 ++++--- lib/widgets/share/share_alert.dart | 4 +- 4 files changed, 60 insertions(+), 52 deletions(-) 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 1acc067..1ec6de5 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 @@ -24,8 +24,7 @@ class GoodsShareLink extends StatefulWidget { final String shareType; - const GoodsShareLink(this.model, this.params, this.shareType, {Key key}) - : super(key: key); + const GoodsShareLink(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareLinkState createState() => _GoodsShareLinkState(); @@ -36,8 +35,7 @@ class _GoodsShareLinkState extends State { Widget build(BuildContext context) { return BlocProvider( bloc: GoodsShareContentBloc(), - child: - _GoodsShareLinkContent(widget.model, widget.params, widget.shareType), + child: _GoodsShareLinkContent(widget.model, widget.params, widget.shareType), ); } } @@ -49,16 +47,13 @@ class _GoodsShareLinkContent extends StatefulWidget { // final GoodsShareTempDataModel datas; - const _GoodsShareLinkContent(this.model, this.params, this.shareType, - {Key key}) - : super(key: key); + const _GoodsShareLinkContent(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareLinkContentState createState() => _GoodsShareLinkContentState(); } -class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> - with AutomaticKeepAliveClientMixin { +class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> with AutomaticKeepAliveClientMixin { GoodsShareImageModel _style; Map _images = Map(); List widgets = List(); @@ -95,6 +90,13 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> if (_content == null || _content == '') { _content = data.shareContent; } + + _shareModel.image = List(); + + _shareModel.title = data?.appName ?? ""; + _shareModel.content=_content; + // _shareModel.image.add(data?.imgUrl ?? ""); + widgets.add(GoodsShareItem( imgHeader: _style?.cssList?.headerImage ?? '', imgCheck: _style?.cssList?.unChooseImage ?? '', @@ -125,10 +127,7 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> onEditorClick: () { Fluttertoast.showToast(msg: '正在开发中'); return; - Navigator.push( - context, - CupertinoPageRoute( - builder: (context) => GoodsShareEditor(_style))); + Navigator.push(context, CupertinoPageRoute(builder: (context) => GoodsShareEditor(_style))); }, onTempChange: (temp) { setState(() { @@ -160,34 +159,25 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> 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), ), ), ), - _createBottom(), + _createBottom(data), ], ); }); } - Widget _createBottom() { + Widget _createBottom(GoodsShareTempDataModel data) { Map shareImages = _style?.cssList?.shareLink; if (shareImages == null) { return Container(); } - CustomButtonModel btnCopy = CustomButtonModel.fromJson( - Map.from(shareImages['copy_btn'])); - CustomButtonModel btnShare = CustomButtonModel.fromJson( - Map.from(shareImages['share_btn'])); + CustomButtonModel btnCopy = CustomButtonModel.fromJson(Map.from(shareImages['copy_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), @@ -202,7 +192,11 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> decoration: BoxDecoration( borderRadius: BorderRadius.circular(18), ), - child: CustomButton(btnCopy)), + child: GestureDetector( + onTap: () { + Clipboard.setData(ClipboardData(text: _content)); + }, + child: CustomButton(btnCopy))), btnShare == null ? Container() : GestureDetector( @@ -225,15 +219,16 @@ class _GoodsShareLinkContentState extends State<_GoodsShareLinkContent> } void _showShare() async { - List images = List(); - for (int index = 0; index < _style.customImage.length; index++) { - if (_images.containsKey(index)) { - images.add(_images[index]); - } - } - if (images.length >= 0) { - _shareModel.image = images; - } + // List images = List(); + // for (int index = 0; index < _style.customImage.length; index++) { + // if (_images.containsKey(index)) { + // images.add(_images[index]); + // } + // } + // if (images.length >= 0) { + // _shareModel.image = images; + // } + showCupertinoModalPopup( context: context, builder: (context) => ShareAlert( diff --git a/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart b/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart index 2d8cbb3..33f1a64 100644 --- a/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart +++ b/lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart @@ -9,6 +9,7 @@ import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_m import 'package:zhiying_base_widget/widgets/public/custom_button/custom_bottom.dart'; import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; class GoodsShareMiniprogram extends StatefulWidget { final Map model; @@ -112,15 +113,15 @@ class _GoodsShareMiniprogramContentState ), ), ), - _createBottom(), + _createBottom(data), ], ); }); return Material(); } - Widget _createBottom() { - Map shareImages = _style.cssList.shareImage; + Widget _createBottom(GoodsShareTempDataModel data) { + Map shareImages = _style.cssList.shareMini; if (shareImages == null) { return Container(); } @@ -145,7 +146,10 @@ class _GoodsShareMiniprogramContentState borderRadius: BorderRadius.circular(18), ), child: CustomButton(btnShare)), - onTap: () {}, + onTap: () { + print(data); + LauncherWxMiniProgram.open(data.toJson()); + }, ), ], ), diff --git a/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart b/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart index 606cfd5..2f6bae7 100644 --- a/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart +++ b/lib/pages/goods_share_page/models/goods_share_temp_add_model.dart @@ -14,12 +14,13 @@ class GoodsShareTempDataModel { String miniAppCode; String miniAppDesc; - GoodsShareTempDataModel( - {this.shareContent, - this.shareTemplate, - this.shareTip, - this.appUrl, - this.miniAppUrl}); + String appId; + String userName; + String miniprogramType; + String page; + String imageUrl; + + GoodsShareTempDataModel({this.shareContent, this.shareTemplate, this.shareTip, this.appUrl, this.miniAppUrl}); GoodsShareTempDataModel.fromJson(Map json) { shareContent = json['template_content']; @@ -41,14 +42,18 @@ class GoodsShareTempDataModel { miniAppCode = json['mini_app_code']; miniAppDesc = json['mini_app_desc']; imgUrl = json['image_url']; + appId = json['app_id']; + userName = json['user_name']; + miniprogramType = json['miniprogram_type']; + page = json['page']; + imageUrl=json['image_url']; } Map toJson() { final Map data = new Map(); data['share_content'] = this.shareContent; if (this.shareTemplate != null) { - data['template_content'] = - this.shareTemplate.map((v) => v.toJson()).toList(); + data['template_content'] = this.shareTemplate.map((v) => v.toJson()).toList(); } data['share_tip'] = this.shareTip; data['app_url'] = this.appUrl; @@ -64,6 +69,10 @@ class GoodsShareTempDataModel { data['mini_app_url'] = this.miniAppUrl; data['mini_app_code'] = this.miniAppCode; data['mini_app_desc'] = this.miniAppDesc; + data['app_id'] = appId; + data['user_name'] = userName; + data['miniprogram_type'] = miniprogramType; + data['page'] = page; return data; } } diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart index 992bc51..2fafddb 100644 --- a/lib/widgets/share/share_alert.dart +++ b/lib/widgets/share/share_alert.dart @@ -270,9 +270,9 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { } else { var type = SSDKContentTypes.auto; - if (widget?.model?.image?.first != null && widget.model?.url != null) { + if (widget?.model?.image?.length!=0 && widget.model?.url != null) { type = SSDKContentTypes.webpage; - } else if (widget?.model?.image?.first != null) { + } else if (widget?.model?.image?.length!=0) { type = SSDKContentTypes.image; } else if (widget?.model?.title != null || widget.model?.content != null) { type = SSDKContentTypes.text;