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 33f1a64..9459fba 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 @@ -10,6 +10,8 @@ import 'package:zhiying_base_widget/widgets/public/custom_button/custom_bottom.d 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'; +import 'package:sharesdk_plugin/sharesdk_plugin.dart'; +import 'package:fluwx/fluwx.dart'; class GoodsShareMiniprogram extends StatefulWidget { final Map model; @@ -17,9 +19,7 @@ class GoodsShareMiniprogram extends StatefulWidget { final String shareType; - const GoodsShareMiniprogram(this.model, this.params, this.shareType, - {Key key}) - : super(key: key); + const GoodsShareMiniprogram(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override _GoodsShareMiniprogramState createState() => _GoodsShareMiniprogramState(); @@ -30,8 +30,7 @@ class _GoodsShareMiniprogramState extends State { Widget build(BuildContext context) { return BlocProvider( bloc: GoodsShareContentBloc(), - child: _GoodsShareMiniprogramContent( - widget.model, widget.params, widget.shareType), + child: _GoodsShareMiniprogramContent(widget.model, widget.params, widget.shareType), ); } } @@ -41,18 +40,13 @@ class _GoodsShareMiniprogramContent extends StatefulWidget { final Map params; final String shareType; - const _GoodsShareMiniprogramContent(this.model, this.params, this.shareType, - {Key key}) - : super(key: key); + const _GoodsShareMiniprogramContent(this.model, this.params, this.shareType, {Key key}) : super(key: key); @override - _GoodsShareMiniprogramContentState createState() => - _GoodsShareMiniprogramContentState(); + _GoodsShareMiniprogramContentState createState() => _GoodsShareMiniprogramContentState(); } -class _GoodsShareMiniprogramContentState - extends State<_GoodsShareMiniprogramContent> - with AutomaticKeepAliveClientMixin { +class _GoodsShareMiniprogramContentState extends State<_GoodsShareMiniprogramContent> with AutomaticKeepAliveClientMixin { GoodsShareImageModel _style; Map _images = Map(); List widgets = List(); @@ -86,11 +80,7 @@ class _GoodsShareMiniprogramContentState 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, @@ -127,8 +117,7 @@ class _GoodsShareMiniprogramContentState } // CustomButtonModel btnCopy = CustomButtonModel.fromJson( // Map.from(shareImages['copy_btn'])); - CustomButtonModel btnShare = CustomButtonModel.fromJson( - Map.from(shareImages['share_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), @@ -147,8 +136,8 @@ class _GoodsShareMiniprogramContentState ), child: CustomButton(btnShare)), onTap: () { - print(data); - LauncherWxMiniProgram.open(data.toJson()); + print(data.toJson()); + _shareMini(data); }, ), ], @@ -156,4 +145,17 @@ class _GoodsShareMiniprogramContentState ), ); } + + void _shareMini(GoodsShareTempDataModel data) { + WeChatShareMiniProgramModel shareMiniProgramModel = WeChatShareMiniProgramModel( + miniProgramType: WXMiniProgramType.RELEASE, + userName: data?.userName, + webPageUrl: data?.page, + path: data?.page, + title: data?.miniAppTitle, + thumbnail: WeChatImage.network(data?.imageUrl)); + + shareToWeChat(shareMiniProgramModel); + + } } diff --git a/lib/pages/goods_share_page/goods_share_page.dart b/lib/pages/goods_share_page/goods_share_page.dart index 04be686..a79b750 100644 --- a/lib/pages/goods_share_page/goods_share_page.dart +++ b/lib/pages/goods_share_page/goods_share_page.dart @@ -49,9 +49,10 @@ class _GoodsShareContainerState extends State<_GoodsShareContainer> // Map data = // Map.from(convert.jsonDecode(d)); Map data = widget.model; - Logger.debug(data['share_url_args'].toString()); + Logger.debug(data.toString()); _bloc = BlocProvider.of(context); _params = data['share_url_args']; + _params['good_id']=data['good_id']; _bloc.loadData('taobao', _params); super.initState(); } diff --git a/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart b/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart index 01dc17c..f8b9ec3 100644 --- a/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart +++ b/lib/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart @@ -56,12 +56,12 @@ class GoodsShareMiniprogramWidget extends StatelessWidget { ), Row( children: [ - Container( - margin: EdgeInsets.only(right: 6), - width: 15, - height: 15, - // color: Colors.redAccent, - ), + // Container( + // margin: EdgeInsets.only(right: 6), + // width: 15, + // height: 15, + // // color: Colors.redAccent, + // ), Text( '小程序', style: TextStyle(fontSize: 11, color: Color(0xff333333)), diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart index 2fafddb..18402f7 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?.length!=0 && widget.model?.url != null) { + if (widget?.model?.image?.length != 0 && widget.model?.url != null) { type = SSDKContentTypes.webpage; - } else if (widget?.model?.image?.length!=0) { + } else if (widget?.model?.image?.length != 0) { type = SSDKContentTypes.image; } else if (widget?.model?.title != null || widget.model?.content != null) { type = SSDKContentTypes.text; @@ -282,12 +282,18 @@ class _ShareAlertContentState extends State<_ShareAlertContent> { type = SSDKContentTypes.message; } + var isExistImage = false; + + if (widget?.model?.image != null && widget?.model?.image?.length > 0) { + isExistImage = true; + } + params = SSDKMap() ..setGeneral( widget.model?.title ?? '', widget?.model?.content ?? '', Platform.isIOS ? widget.model.image : null, - Platform.isAndroid ? widget?.model?.image?.first : null, + Platform.isAndroid ? (isExistImage ? widget?.model?.image?.first : null) : null, null, widget.model.url, null,