Sfoglia il codice sorgente

1.优化分享链接、接通分享小程序

tags/0.0.9+1
“yanghuaxuan” 3 anni fa
parent
commit
f79d6b2287
4 ha cambiato i file con 60 aggiunte e 52 eliminazioni
  1. +33
    -38
      lib/pages/goods_share_page/goods_share_link/goods_share_link.dart
  2. +8
    -4
      lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart
  3. +17
    -8
      lib/pages/goods_share_page/models/goods_share_temp_add_model.dart
  4. +2
    -2
      lib/widgets/share/share_alert.dart

+ 33
- 38
lib/pages/goods_share_page/goods_share_link/goods_share_link.dart Vedi File

@@ -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<GoodsShareLink> {
Widget build(BuildContext context) {
return BlocProvider<GoodsShareContentBloc>(
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<int, String> _images = Map();
List<Widget> 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<String, dynamic> shareImages = _style?.cssList?.shareLink;
if (shareImages == null) {
return Container();
}
CustomButtonModel btnCopy = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['copy_btn']));
CustomButtonModel btnShare = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['share_btn']));
CustomButtonModel btnCopy = CustomButtonModel.fromJson(Map<String, dynamic>.from(shareImages['copy_btn']));
CustomButtonModel btnShare = CustomButtonModel.fromJson(Map<String, dynamic>.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<String> 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<String> 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(


+ 8
- 4
lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart Vedi File

@@ -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<String, dynamic> model;
@@ -112,15 +113,15 @@ class _GoodsShareMiniprogramContentState
),
),
),
_createBottom(),
_createBottom(data),
],
);
});
return Material();
}

Widget _createBottom() {
Map<String, dynamic> shareImages = _style.cssList.shareImage;
Widget _createBottom(GoodsShareTempDataModel data) {
Map<String, dynamic> 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());
},
),
],
),


+ 17
- 8
lib/pages/goods_share_page/models/goods_share_temp_add_model.dart Vedi File

@@ -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<String, dynamic> 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<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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;
}
}


+ 2
- 2
lib/widgets/share/share_alert.dart Vedi File

@@ -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;


Caricamento…
Annulla
Salva