|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.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:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../models/coupon_model.dart';
|
|
|
|
import '../../models/user.dart';
|
|
|
|
import '../../provider/base_info_provider.dart';
|
|
|
|
import '../../res/colors.dart';
|
|
|
|
import '../../utils/screen_util.dart';
|
|
|
|
import '../../widgets/h_empty_view.dart';
|
|
|
|
import '../../widgets/round_button.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 优惠券分享海报
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CouponPosterPage extends StatefulWidget {
|
|
|
|
final String id; //优惠券ID
|
|
|
|
|
|
|
|
final CouponUse use;
|
|
|
|
final CouponSunModel couponSunModel;
|
|
|
|
CouponPosterPage({Key key, this.id, this.use, this.couponSunModel})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_CouponPosterPageState createState() => _CouponPosterPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CouponPosterPageState extends State<CouponPosterPage> {
|
|
|
|
String managerName = '';
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// if (widget.idstr != null && widget.idstr != 'null') {
|
|
|
|
_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,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool success =
|
|
|
|
await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
|
|
|
|
if (success) {
|
|
|
|
managerName = _baseIndoProvider.baseInfoSunModel.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
User user = Provider.of<UserModel>(context, listen: false).user;
|
|
|
|
String times = '营业时间:';
|
|
|
|
if (user.morning != "") {
|
|
|
|
times += user.morning;
|
|
|
|
}
|
|
|
|
if (user.noon != "") {
|
|
|
|
times += ' ${user.noon}';
|
|
|
|
}
|
|
|
|
if (user.night != "") {
|
|
|
|
times += ' ${user.night}';
|
|
|
|
}
|
|
|
|
String phone = user.sellerphone.replaceAll(',', ' ');
|
|
|
|
String address = '地址:' + user.sellerAddr;
|
|
|
|
String title = "${user.sellername}向您推荐一张优惠券";
|
|
|
|
String name = '';
|
|
|
|
if (widget.couponSunModel.isType == '1') {
|
|
|
|
//店铺优惠券
|
|
|
|
String price = widget.couponSunModel.price;
|
|
|
|
|
|
|
|
if (widget.use != null) {
|
|
|
|
if (widget.use.isCash) {
|
|
|
|
if (price == '0') {
|
|
|
|
title = '免费获取';
|
|
|
|
} else {
|
|
|
|
title = '仅需${price}元,获取';
|
|
|
|
}
|
|
|
|
name = '${user.sellername}${widget.use.cash}元代金券';
|
|
|
|
} else if (widget.use.isDiscount) {
|
|
|
|
if (price == '0') {
|
|
|
|
title = '免费获取';
|
|
|
|
} else {
|
|
|
|
title = '仅需${price}元,获取';
|
|
|
|
}
|
|
|
|
name = '${user.sellername}${widget.use.discount}折折扣券';
|
|
|
|
} else if (widget.use.isDish) {
|
|
|
|
if (price == '0') {
|
|
|
|
title = '免费获取';
|
|
|
|
} else {
|
|
|
|
title = '仅需${price}元,获取';
|
|
|
|
}
|
|
|
|
name = '${user.sellername}${widget.couponSunModel.aname}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// title = "${managerName}给您赠送${widget.couponSunModel.aname}";
|
|
|
|
// title = "${widget.couponSunModel.aname}";
|
|
|
|
name = "${widget.couponSunModel.aname}";
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: SystemAppBar('优惠券详情'),
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
body: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
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),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
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_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(
|
|
|
|
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)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(91 * 2),
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: ScreenUtil().setWidth(16 * 2),
|
|
|
|
bottom: ScreenUtil().setWidth(35 * 2),
|
|
|
|
left: ScreenUtil().setWidth(23 * 2),
|
|
|
|
right: ScreenUtil().setWidth(23 * 2),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
spreadRadius: ScreenUtil().setWidth(2),
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.1),
|
|
|
|
offset: Offset(0, ScreenUtil().setWidth(-2)),
|
|
|
|
blurRadius: ScreenUtil().setWidth(8))
|
|
|
|
],
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(ScreenUtil().setWidth(16)),
|
|
|
|
topRight: Radius.circular(ScreenUtil().setWidth(16))),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
RoundButton(
|
|
|
|
text: '保存海报图片',
|
|
|
|
width: w(100),
|
|
|
|
gradientStart: MyColours.color_ffffff,
|
|
|
|
gradientEnd: MyColours.color_ffffff,
|
|
|
|
borderColor: MyColours.color_438E93,
|
|
|
|
textColor: MyColours.color_438E93,
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
radius: ScreenUtil().setWidth(14),
|
|
|
|
isBold: true,
|
|
|
|
fontSize: 28,
|
|
|
|
onPressed: () {},
|
|
|
|
),
|
|
|
|
HEmptyView(30),
|
|
|
|
Expanded(
|
|
|
|
child: RoundButton(
|
|
|
|
text: '分享给客户',
|
|
|
|
height: ScreenUtil().setWidth(80),
|
|
|
|
radius: ScreenUtil().setWidth(14),
|
|
|
|
isBold: false,
|
|
|
|
fontSize: 28,
|
|
|
|
onPressed: () {},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
))
|
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|