|
|
|
import 'dart:io';
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../models/coupon_model.dart';
|
|
...
|
...
|
@@ -12,7 +20,9 @@ import '../../models/user.dart'; |
|
|
|
import '../../provider/base_info_provider.dart';
|
|
|
|
import '../../res/colors.dart';
|
|
|
|
import '../../utils/screen_util.dart';
|
|
|
|
import '../../utils/share_helper.dart';
|
|
|
|
import '../../widgets/h_empty_view.dart';
|
|
|
|
import '../../widgets/loading.dart';
|
|
|
|
import '../../widgets/round_button.dart';
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -33,6 +43,8 @@ class CouponPosterPage extends StatefulWidget { |
|
|
|
|
|
|
|
class _CouponPosterPageState extends State<CouponPosterPage> {
|
|
|
|
String managerName = '';
|
|
|
|
// 全局key
|
|
|
|
final GlobalKey _rootWidgetKey = GlobalKey();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
...
|
...
|
@@ -40,23 +52,41 @@ class _CouponPosterPageState extends State<CouponPosterPage> { |
|
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// if (widget.idstr != null && widget.idstr != 'null') {
|
|
|
|
_getCustomerActivityBaseinfo();
|
|
|
|
// _getCustomerActivityBaseinfo();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_getCustomerActivityBaseinfo() async {
|
|
|
|
BaseIndoProvider _baseIndoProvider =
|
|
|
|
Provider.of<BaseIndoProvider>(context, listen: false);
|
|
|
|
Map<String, String> params = {
|
|
|
|
'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
|
|
|
|
};
|
|
|
|
// _getCustomerActivityBaseinfo() async {
|
|
|
|
// BaseIndoProvider _baseIndoProvider =
|
|
|
|
// Provider.of<BaseIndoProvider>(context, listen: false);
|
|
|
|
// Map<String, String> params = {
|
|
|
|
// 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
// "uid": Provider.of<UserModel>(context, listen: false).user.openid,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// bool success =
|
|
|
|
// await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
|
|
|
|
// if (success) {
|
|
|
|
// managerName = _baseIndoProvider.baseInfoSunModel.name;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
bool success =
|
|
|
|
await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
|
|
|
|
if (success) {
|
|
|
|
managerName = _baseIndoProvider.baseInfoSunModel.name;
|
|
|
|
/// 截图
|
|
|
|
Future<Uint8List> _capturePng(
|
|
|
|
GlobalKey globalKey, {
|
|
|
|
double pixelRatio = 6.0, //截屏的图片与原图的比例
|
|
|
|
}) async {
|
|
|
|
try {
|
|
|
|
RenderRepaintBoundary boundary =
|
|
|
|
globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary;
|
|
|
|
var image = await boundary.toImage(pixelRatio: pixelRatio);
|
|
|
|
ByteData byteData = await image.toByteData(format: ImageByteFormat.png);
|
|
|
|
Uint8List pngBytes = byteData?.buffer.asUint8List();
|
|
|
|
return pngBytes;
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
...
|
...
|
@@ -87,21 +117,22 @@ class _CouponPosterPageState extends State<CouponPosterPage> { |
|
|
|
} else {
|
|
|
|
title = '仅需${price}元,获取';
|
|
|
|
}
|
|
|
|
name = '${user.sellername}${widget.use.cash}元代金券';
|
|
|
|
// name = '${user.sellername}${widget.use.cash}元代金券';
|
|
|
|
name = '${widget.use.cash}元代金券';
|
|
|
|
} else if (widget.use.isDiscount) {
|
|
|
|
if (price == '0') {
|
|
|
|
title = '免费获取';
|
|
|
|
} else {
|
|
|
|
title = '仅需${price}元,获取';
|
|
|
|
}
|
|
|
|
name = '${user.sellername}${widget.use.discount}折折扣券';
|
|
|
|
name = '${widget.use.discount}折折扣券';
|
|
|
|
} else if (widget.use.isDish) {
|
|
|
|
if (price == '0') {
|
|
|
|
title = '免费获取';
|
|
|
|
} else {
|
|
|
|
title = '仅需${price}元,获取';
|
|
|
|
}
|
|
|
|
name = '${user.sellername}${widget.couponSunModel.aname}';
|
|
|
|
name = '${widget.couponSunModel.aname}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
...
|
...
|
@@ -118,129 +149,185 @@ class _CouponPosterPageState extends State<CouponPosterPage> { |
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Stack(
|
|
|
|
clipBehavior: Clip.none,
|
|
|
|
children: [
|
|
|
|
CachedNetworkImage(
|
|
|
|
imageUrl: user.sellerimage,
|
|
|
|
width: double.infinity,
|
|
|
|
height: w(280),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: -w(64),
|
|
|
|
child: Container(
|
|
|
|
// width: double.infinity,
|
|
|
|
// height: w(128),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(10), vertical: w(18)),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: w(20)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.circular(r(8))),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
user.sellername,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_E4461D,
|
|
|
|
fontSize: font(16),
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
Text(
|
|
|
|
times,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(14),
|
|
|
|
child: RepaintBoundary(
|
|
|
|
key: _rootWidgetKey,
|
|
|
|
child: Container(
|
|
|
|
color: Colors.white,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Stack(
|
|
|
|
clipBehavior: Clip.none,
|
|
|
|
children: [
|
|
|
|
CachedNetworkImage(
|
|
|
|
imageUrl: user.sellerimage,
|
|
|
|
width: double.infinity,
|
|
|
|
height: w(280),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: '电话:',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours.color_515151)),
|
|
|
|
TextSpan(
|
|
|
|
text: phone,
|
|
|
|
style: TextStyle(
|
|
|
|
Positioned(
|
|
|
|
bottom: -w(64),
|
|
|
|
child: Container(
|
|
|
|
// width: double.infinity,
|
|
|
|
// height: w(128),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(10), vertical: w(18)),
|
|
|
|
margin: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(20)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: MyColours.color_E4461D,
|
|
|
|
width: w(1)),
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(r(8))),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
user.sellername,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours.color_E4461D)),
|
|
|
|
])),
|
|
|
|
VEmptyView(10),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
address,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('location_orange'),
|
|
|
|
width: w(25),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(170),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(32), color: MyColours.color_000000),
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(20)),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('coupon_l'),
|
|
|
|
height: w(100),
|
|
|
|
),
|
|
|
|
HEmptyView(1),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
constraints: BoxConstraints(minHeight: w(120)),
|
|
|
|
decoration: BoxDecoration(color: Colors.red),
|
|
|
|
child: Text(name,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_E4461D,
|
|
|
|
fontSize: font(16),
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
Text(
|
|
|
|
times,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(28),
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: '电话:',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours
|
|
|
|
.color_515151)),
|
|
|
|
TextSpan(
|
|
|
|
text: phone,
|
|
|
|
style: TextStyle(
|
|
|
|
overflow: TextOverflow
|
|
|
|
.ellipsis,
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours
|
|
|
|
.color_E4461D)),
|
|
|
|
])),
|
|
|
|
VEmptyView(10),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
address,
|
|
|
|
overflow:
|
|
|
|
TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color:
|
|
|
|
MyColours.color_515151,
|
|
|
|
fontSize: font(14),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
'location_orange'),
|
|
|
|
width: w(25),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
VEmptyView(170),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(32),
|
|
|
|
color: MyColours.color_ffffff)),
|
|
|
|
)),
|
|
|
|
HEmptyView(1),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('coupon_r'),
|
|
|
|
// width: w(20),
|
|
|
|
height: w(100),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
VEmptyView(30),
|
|
|
|
// CachedNetworkImage(imageUrl: imageUrl)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
color: MyColours.color_000000),
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: w(20)),
|
|
|
|
child: Stack(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('coupon_bg')),
|
|
|
|
Positioned(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(20)),
|
|
|
|
child: Text(name,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow:
|
|
|
|
TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(32),
|
|
|
|
color: MyColours
|
|
|
|
.color_ffffff))))
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
// Padding(
|
|
|
|
// padding: EdgeInsets.symmetric(horizontal: w(20)),
|
|
|
|
// child: Row(
|
|
|
|
// children: [
|
|
|
|
// Image.asset(
|
|
|
|
// Utils.getImgPath('coupon_l'),
|
|
|
|
// height: w(100),
|
|
|
|
// ),
|
|
|
|
// HEmptyView(1),
|
|
|
|
// Expanded(
|
|
|
|
// child: Container(
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
// constraints: BoxConstraints(minHeight: w(120)),
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// color: Color.fromRGBO(252, 0, 0, 1)),
|
|
|
|
// child: Text(name,
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: font(32),
|
|
|
|
// color: MyColours.color_ffffff)),
|
|
|
|
// )),
|
|
|
|
// HEmptyView(1),
|
|
|
|
// Image.asset(
|
|
|
|
// Utils.getImgPath('coupon_r'),
|
|
|
|
// // width: w(20),
|
|
|
|
// height: w(100),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// )),
|
|
|
|
VEmptyView(30),
|
|
|
|
if (widget.couponSunModel.liteQrcode != null)
|
|
|
|
CachedNetworkImage(
|
|
|
|
imageUrl: widget.couponSunModel.liteQrcode,
|
|
|
|
height: w(200),
|
|
|
|
),
|
|
|
|
|
|
|
|
if (widget.couponSunModel.liteQrcode != null)
|
|
|
|
VEmptyView(20),
|
|
|
|
if (widget.couponSunModel.liteQrcode != null)
|
|
|
|
Text('长按二维码识别领取',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(16),
|
|
|
|
color: MyColours.color_000000)),
|
|
|
|
VEmptyView(60),
|
|
|
|
],
|
|
|
|
)))),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(91 * 2),
|
|
...
|
...
|
@@ -277,7 +364,35 @@ class _CouponPosterPageState extends State<CouponPosterPage> { |
|
|
|
radius: ScreenUtil().setWidth(14),
|
|
|
|
isBold: true,
|
|
|
|
fontSize: 28,
|
|
|
|
onPressed: () {},
|
|
|
|
onPressed: () {
|
|
|
|
Utils.getPickPermission(context, () {
|
|
|
|
//获取截屏图像
|
|
|
|
//添加到图片数组中
|
|
|
|
Loading.showLoading(
|
|
|
|
context,
|
|
|
|
);
|
|
|
|
_capturePng(_rootWidgetKey).then((value) async {
|
|
|
|
if (value != null) {
|
|
|
|
print(value);
|
|
|
|
final result = await ImageGallerySaver.saveImage(
|
|
|
|
value,
|
|
|
|
quality: 100);
|
|
|
|
if (result != null) {
|
|
|
|
Utils.showToast("保存成功");
|
|
|
|
} else {
|
|
|
|
print('error');
|
|
|
|
Utils.showToast("保存失败");
|
|
|
|
// toast("");
|
|
|
|
}
|
|
|
|
Loading.hideLoading(context);
|
|
|
|
// setState(() {});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
Platform.isIOS
|
|
|
|
? Permission.photos
|
|
|
|
: Permission.storage);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
HEmptyView(30),
|
|
|
|
Expanded(
|
|
...
|
...
|
@@ -287,7 +402,12 @@ class _CouponPosterPageState extends State<CouponPosterPage> { |
|
|
|
radius: ScreenUtil().setWidth(14),
|
|
|
|
isBold: false,
|
|
|
|
fontSize: 28,
|
|
|
|
onPressed: () {},
|
|
|
|
onPressed: () {
|
|
|
|
ShareHelper.onShareWx(
|
|
|
|
context,
|
|
|
|
boundaryKey: _rootWidgetKey,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
...
|
...
|
|