Commit b459dd18f86dfa831a4caca27d02efee27098998

Authored by wdn127929
1 parent 2f3cb0a4

优惠券生成海报部分UI

@@ -330,32 +330,32 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -330,32 +330,32 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
330 onTap: () { 330 onTap: () {
331 Navigator.pop(context); 331 Navigator.pop(context);
332 }, 332 },
333 - rightImgName: couponProvider != null &&  
334 - couponProvider.couponSunModel != null &&  
335 - // couponProvider.couponSunModel.isType == '1' &&  
336 - // couponProvider.couponSunModel.isExamine == '1' &&  
337 - couponProvider.couponSunModel.status == '1'  
338 - ? 'share.png'  
339 - : null,  
340 - onTapRight: () {  
341 - // if (couponProvider.couponSunModel.isType == '1' &&  
342 - // couponProvider.couponSunModel.isExamine == '1' &&  
343 - // couponProvider.couponSunModel.status == '1') {  
344 - if (couponProvider.couponSunModel.isType == '1' &&  
345 - couponProvider.couponSunModel.status == '1') {  
346 - //店铺券  
347 - Utils.goShareBuyCouponToWeChat(  
348 - context,  
349 - widget.idstr,  
350 - couponProvider.couponSunModel.use,  
351 - couponProvider.couponSunModel);  
352 - } else if (couponProvider.couponSunModel.isType == '2' &&  
353 - couponProvider.couponSunModel.status == '1') {  
354 - // 我的优惠券  
355 - Utils.goShareBuyCouponToWeChatMy(context, widget.idstr,  
356 - managerName, couponProvider.couponSunModel);  
357 - }  
358 - }, 333 + // rightImgName: couponProvider != null &&
  334 + // couponProvider.couponSunModel != null &&
  335 + // // couponProvider.couponSunModel.isType == '1' &&
  336 + // // couponProvider.couponSunModel.isExamine == '1' &&
  337 + // couponProvider.couponSunModel.status == '1'
  338 + // ? 'share.png'
  339 + // : null,
  340 + // onTapRight: () {
  341 + // // if (couponProvider.couponSunModel.isType == '1' &&
  342 + // // couponProvider.couponSunModel.isExamine == '1' &&
  343 + // // couponProvider.couponSunModel.status == '1') {
  344 + // if (couponProvider.couponSunModel.isType == '1' &&
  345 + // couponProvider.couponSunModel.status == '1') {
  346 + // //店铺券
  347 + // Utils.goShareBuyCouponToWeChat(
  348 + // context,
  349 + // widget.idstr,
  350 + // couponProvider.couponSunModel.use,
  351 + // couponProvider.couponSunModel);
  352 + // } else if (couponProvider.couponSunModel.isType == '2' &&
  353 + // couponProvider.couponSunModel.status == '1') {
  354 + // // 我的优惠券
  355 + // Utils.goShareBuyCouponToWeChatMy(context, widget.idstr,
  356 + // managerName, couponProvider.couponSunModel);
  357 + // }
  358 + // },
359 ), 359 ),
360 body: Consumer<CouponProvider>(builder: (context, model, _) { 360 body: Consumer<CouponProvider>(builder: (context, model, _) {
361 if (pageState != PageState.Success) { 361 if (pageState != PageState.Success) {
@@ -640,7 +640,86 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -640,7 +640,86 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
640 : false) 640 : false)
641 ], 641 ],
642 ))), 642 ))),
643 - ) 643 + ),
  644 + Container(
  645 + height: ScreenUtil().setWidth(91 * 2),
  646 + padding: EdgeInsets.only(
  647 + top: ScreenUtil().setWidth(16 * 2),
  648 + bottom: ScreenUtil().setWidth(35 * 2),
  649 + left: ScreenUtil().setWidth(23 * 2),
  650 + right: ScreenUtil().setWidth(23 * 2),
  651 + ),
  652 + decoration: BoxDecoration(
  653 + color: MyColours.color_ffffff,
  654 + boxShadow: [
  655 + BoxShadow(
  656 + spreadRadius: ScreenUtil().setWidth(2),
  657 + color: Color.fromRGBO(0, 0, 0, 0.1),
  658 + offset: Offset(0, ScreenUtil().setWidth(-2)),
  659 + blurRadius: ScreenUtil().setWidth(8))
  660 + ],
  661 + borderRadius: BorderRadius.only(
  662 + topLeft: Radius.circular(ScreenUtil().setWidth(16)),
  663 + topRight: Radius.circular(ScreenUtil().setWidth(16))),
  664 + ),
  665 + child: Row(
  666 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  667 + children: [
  668 + RoundButton(
  669 + text: '生成海报',
  670 + width: w(100),
  671 + gradientStart: MyColours.color_ffffff,
  672 + gradientEnd: MyColours.color_ffffff,
  673 + borderColor: MyColours.color_438E93,
  674 + textColor: MyColours.color_438E93,
  675 + height: ScreenUtil().setWidth(80),
  676 + radius: ScreenUtil().setWidth(14),
  677 + isBold: true,
  678 + fontSize: 28,
  679 + onPressed: () async {
  680 + NavigatorUtil.goCouponPosterPage(
  681 + context,
  682 + widget.idstr,
  683 + couponProvider.couponSunModel.use,
  684 + couponProvider.couponSunModel);
  685 + },
  686 + ),
  687 + HEmptyView(30),
  688 + Expanded(
  689 + child: RoundButton(
  690 + text: '分享给客户',
  691 + height: ScreenUtil().setWidth(80),
  692 + radius: ScreenUtil().setWidth(14),
  693 + isBold: false,
  694 + fontSize: 28,
  695 + onPressed: () {
  696 + if (couponProvider.couponSunModel.status != '1') {
  697 + Utils.showToast('请先启用优惠券后再进行操作!');
  698 + return;
  699 + }
  700 + if (couponProvider.couponSunModel.isType == '1' &&
  701 + couponProvider.couponSunModel.status == '1') {
  702 + //店铺券
  703 + Utils.goShareBuyCouponToWeChat(
  704 + context,
  705 + widget.idstr,
  706 + couponProvider.couponSunModel.use,
  707 + couponProvider.couponSunModel);
  708 + } else if (couponProvider.couponSunModel.isType ==
  709 + '2' &&
  710 + couponProvider.couponSunModel.status == '1') {
  711 + // 我的优惠券
  712 + Utils.goShareBuyCouponToWeChatMy(
  713 + context,
  714 + widget.idstr,
  715 + managerName,
  716 + couponProvider.couponSunModel);
  717 + }
  718 + },
  719 + ),
  720 + )
  721 + ],
  722 + ))
644 ]); 723 ]);
645 } 724 }
646 })); 725 }));
  1 +import 'package:cached_network_image/cached_network_image.dart';
  2 +import 'package:flutter/material.dart';
  3 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  4 +import 'package:one_key/provider/user_model.dart';
  5 +import 'package:one_key/utils/utils.dart';
  6 +import 'package:one_key/widgets/system_app_bar.dart';
  7 +import 'package:one_key/widgets/v_empty_view.dart';
  8 +import 'package:provider/provider.dart';
  9 +
  10 +import '../../models/coupon_model.dart';
  11 +import '../../models/user.dart';
  12 +import '../../provider/base_info_provider.dart';
  13 +import '../../res/colors.dart';
  14 +import '../../utils/screen_util.dart';
  15 +import '../../widgets/h_empty_view.dart';
  16 +import '../../widgets/round_button.dart';
  17 +
  18 +/**
  19 + * 优惠券分享海报
  20 + */
  21 +
  22 +class CouponPosterPage extends StatefulWidget {
  23 + final String id; //优惠券ID
  24 +
  25 + final CouponUse use;
  26 + final CouponSunModel couponSunModel;
  27 + CouponPosterPage({Key key, this.id, this.use, this.couponSunModel})
  28 + : super(key: key);
  29 +
  30 + @override
  31 + _CouponPosterPageState createState() => _CouponPosterPageState();
  32 +}
  33 +
  34 +class _CouponPosterPageState extends State<CouponPosterPage> {
  35 + String managerName = '';
  36 +
  37 + @override
  38 + void initState() {
  39 + // TODO: implement initState
  40 + super.initState();
  41 + WidgetsBinding.instance.addPostFrameCallback((_) {
  42 + // if (widget.idstr != null && widget.idstr != 'null') {
  43 + _getCustomerActivityBaseinfo();
  44 + });
  45 + }
  46 +
  47 + _getCustomerActivityBaseinfo() async {
  48 + BaseIndoProvider _baseIndoProvider =
  49 + Provider.of<BaseIndoProvider>(context, listen: false);
  50 + Map<String, String> params = {
  51 + 'sellerid': Provider.of<UserModel>(context, listen: false).user.sellerid,
  52 + "uid": Provider.of<UserModel>(context, listen: false).user.openid,
  53 + };
  54 +
  55 + bool success =
  56 + await _baseIndoProvider.getCustomerActivityBaseinfo(context, params);
  57 + if (success) {
  58 + managerName = _baseIndoProvider.baseInfoSunModel.name;
  59 + }
  60 + }
  61 +
  62 + @override
  63 + Widget build(BuildContext context) {
  64 + User user = Provider.of<UserModel>(context, listen: false).user;
  65 + String times = '营业时间:';
  66 + if (user.morning != "") {
  67 + times += user.morning;
  68 + }
  69 + if (user.noon != "") {
  70 + times += ' ${user.noon}';
  71 + }
  72 + if (user.night != "") {
  73 + times += ' ${user.night}';
  74 + }
  75 + String phone = user.sellerphone.replaceAll(',', ' ');
  76 + String address = '地址:' + user.sellerAddr;
  77 + String title = "${user.sellername}向您推荐一张优惠券";
  78 + String name = '';
  79 + if (widget.couponSunModel.isType == '1') {
  80 + //店铺优惠券
  81 + String price = widget.couponSunModel.price;
  82 +
  83 + if (widget.use != null) {
  84 + if (widget.use.isCash) {
  85 + if (price == '0') {
  86 + title = '免费获取';
  87 + } else {
  88 + title = '仅需${price}元,获取';
  89 + }
  90 + name = '${user.sellername}${widget.use.cash}元代金券';
  91 + } else if (widget.use.isDiscount) {
  92 + if (price == '0') {
  93 + title = '免费获取';
  94 + } else {
  95 + title = '仅需${price}元,获取';
  96 + }
  97 + name = '${user.sellername}${widget.use.discount}折折扣券';
  98 + } else if (widget.use.isDish) {
  99 + if (price == '0') {
  100 + title = '免费获取';
  101 + } else {
  102 + title = '仅需${price}元,获取';
  103 + }
  104 + name = '${user.sellername}${widget.couponSunModel.aname}';
  105 + }
  106 + }
  107 + } else {
  108 + // title = "${managerName}给您赠送${widget.couponSunModel.aname}";
  109 + // title = "${widget.couponSunModel.aname}";
  110 + name = "${widget.couponSunModel.aname}";
  111 + }
  112 +
  113 + return Scaffold(
  114 + appBar: SystemAppBar('优惠券详情'),
  115 + backgroundColor: MyColours.color_ffffff,
  116 + body: Column(
  117 + mainAxisAlignment: MainAxisAlignment.start,
  118 + children: [
  119 + Expanded(
  120 + child: SingleChildScrollView(
  121 + child: Column(
  122 + mainAxisAlignment: MainAxisAlignment.start,
  123 + children: [
  124 + Stack(
  125 + clipBehavior: Clip.none,
  126 + children: [
  127 + CachedNetworkImage(
  128 + imageUrl: user.sellerimage,
  129 + width: double.infinity,
  130 + height: w(280),
  131 + fit: BoxFit.cover,
  132 + ),
  133 + Positioned(
  134 + bottom: -w(64),
  135 + child: Container(
  136 + // width: double.infinity,
  137 + // height: w(128),
  138 + padding: EdgeInsets.symmetric(
  139 + horizontal: w(10), vertical: w(18)),
  140 + margin: EdgeInsets.symmetric(horizontal: w(20)),
  141 + decoration: BoxDecoration(
  142 + color: Colors.white,
  143 + borderRadius: BorderRadius.circular(r(8))),
  144 + child: Column(
  145 + crossAxisAlignment: CrossAxisAlignment.start,
  146 + children: [
  147 + Text(
  148 + user.sellername,
  149 + overflow: TextOverflow.ellipsis,
  150 + style: TextStyle(
  151 + color: MyColours.color_E4461D,
  152 + fontSize: font(16),
  153 + fontWeight: FontWeight.bold),
  154 + ),
  155 + VEmptyView(30),
  156 + Text(
  157 + times,
  158 + overflow: TextOverflow.ellipsis,
  159 + style: TextStyle(
  160 + color: MyColours.color_515151,
  161 + fontSize: font(14),
  162 + ),
  163 + ),
  164 + VEmptyView(10),
  165 + RichText(
  166 + text: TextSpan(
  167 + style: TextStyle(
  168 + fontSize: ScreenUtil().setSp(28),
  169 + ),
  170 + children: [
  171 + TextSpan(
  172 + text: '电话:',
  173 + style: TextStyle(
  174 + fontSize: font(14),
  175 + color: MyColours.color_515151)),
  176 + TextSpan(
  177 + text: phone,
  178 + style: TextStyle(
  179 + overflow: TextOverflow.ellipsis,
  180 + fontSize: font(14),
  181 + color: MyColours.color_E4461D)),
  182 + ])),
  183 + VEmptyView(10),
  184 + Row(
  185 + children: [
  186 + Text(
  187 + address,
  188 + overflow: TextOverflow.ellipsis,
  189 + style: TextStyle(
  190 + color: MyColours.color_515151,
  191 + fontSize: font(14),
  192 + ),
  193 + ),
  194 + Image.asset(
  195 + Utils.getImgPath('location_orange'),
  196 + width: w(25),
  197 + )
  198 + ],
  199 + ),
  200 + ],
  201 + ),
  202 + ))
  203 + ],
  204 + ),
  205 + VEmptyView(170),
  206 + Text(
  207 + title,
  208 + style: TextStyle(
  209 + fontSize: font(32), color: MyColours.color_000000),
  210 + ),
  211 + VEmptyView(30),
  212 + Padding(
  213 + padding: EdgeInsets.symmetric(horizontal: w(20)),
  214 + child: Row(
  215 + children: [
  216 + Image.asset(
  217 + Utils.getImgPath('coupon_l'),
  218 + height: w(100),
  219 + ),
  220 + HEmptyView(1),
  221 + Expanded(
  222 + child: Container(
  223 + alignment: Alignment.center,
  224 + constraints: BoxConstraints(minHeight: w(120)),
  225 + decoration: BoxDecoration(color: Colors.red),
  226 + child: Text(name,
  227 + textAlign: TextAlign.center,
  228 + style: TextStyle(
  229 + fontSize: font(32),
  230 + color: MyColours.color_ffffff)),
  231 + )),
  232 + HEmptyView(1),
  233 + Image.asset(
  234 + Utils.getImgPath('coupon_r'),
  235 + // width: w(20),
  236 + height: w(100),
  237 + ),
  238 + ],
  239 + )),
  240 + VEmptyView(30),
  241 + // CachedNetworkImage(imageUrl: imageUrl)
  242 + ],
  243 + )),
  244 + ),
  245 + Container(
  246 + height: ScreenUtil().setWidth(91 * 2),
  247 + padding: EdgeInsets.only(
  248 + top: ScreenUtil().setWidth(16 * 2),
  249 + bottom: ScreenUtil().setWidth(35 * 2),
  250 + left: ScreenUtil().setWidth(23 * 2),
  251 + right: ScreenUtil().setWidth(23 * 2),
  252 + ),
  253 + decoration: BoxDecoration(
  254 + color: MyColours.color_ffffff,
  255 + boxShadow: [
  256 + BoxShadow(
  257 + spreadRadius: ScreenUtil().setWidth(2),
  258 + color: Color.fromRGBO(0, 0, 0, 0.1),
  259 + offset: Offset(0, ScreenUtil().setWidth(-2)),
  260 + blurRadius: ScreenUtil().setWidth(8))
  261 + ],
  262 + borderRadius: BorderRadius.only(
  263 + topLeft: Radius.circular(ScreenUtil().setWidth(16)),
  264 + topRight: Radius.circular(ScreenUtil().setWidth(16))),
  265 + ),
  266 + child: Row(
  267 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  268 + children: [
  269 + RoundButton(
  270 + text: '保存海报图片',
  271 + width: w(100),
  272 + gradientStart: MyColours.color_ffffff,
  273 + gradientEnd: MyColours.color_ffffff,
  274 + borderColor: MyColours.color_438E93,
  275 + textColor: MyColours.color_438E93,
  276 + height: ScreenUtil().setWidth(80),
  277 + radius: ScreenUtil().setWidth(14),
  278 + isBold: true,
  279 + fontSize: 28,
  280 + onPressed: () {},
  281 + ),
  282 + HEmptyView(30),
  283 + Expanded(
  284 + child: RoundButton(
  285 + text: '分享给客户',
  286 + height: ScreenUtil().setWidth(80),
  287 + radius: ScreenUtil().setWidth(14),
  288 + isBold: false,
  289 + fontSize: 28,
  290 + onPressed: () {},
  291 + ),
  292 + )
  293 + ],
  294 + ))
  295 + ],
  296 + ));
  297 + }
  298 +}
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 2
3 class MyColours { 3 class MyColours {
4 -  
5 -  
6 -  
7 - static const Color color_F8F7F3 = Color(0xFFF8F7F3); 4 + static const Color color_E4461D = Color(0xFFE4461D);
  5 + static const Color color_F8F7F3 = Color(0xFFF8F7F3);
8 static const Color color_33438E93 = Color(0x33438E93); 6 static const Color color_33438E93 = Color(0x33438E93);
9 static const Color color_E89243 = Color(0xFFE89243); 7 static const Color color_E89243 = Color(0xFFE89243);
10 static const Color color_3E6F51 = Color(0xFF3E6F51); 8 static const Color color_3E6F51 = Color(0xFF3E6F51);
@@ -1895,10 +1895,25 @@ class NavigatorUtil { @@ -1895,10 +1895,25 @@ class NavigatorUtil {
1895 1895
1896 ///预订通知短信模板选择 1896 ///预订通知短信模板选择
1897 static Future<dynamic> goSmsTemplateSettingPage( 1897 static Future<dynamic> goSmsTemplateSettingPage(
1898 - BuildContext context, String smsTemplate,{ 1898 + BuildContext context,
  1899 + String smsTemplate, {
  1900 + replace = false,
  1901 + }) {
  1902 + return _navigateTo(context,
  1903 + "${Routes.sms_template_setting_page}?smsTemplate=${Uri.encodeComponent(smsTemplate)}",
  1904 + replace: replace);
  1905 + }
  1906 +
  1907 + ///优惠券海报
  1908 + static Future<dynamic> goCouponPosterPage(
  1909 + BuildContext context,
  1910 + String id,
  1911 + CouponUse use,
  1912 + CouponSunModel couponSunModel, {
1899 replace = false, 1913 replace = false,
1900 }) { 1914 }) {
1901 - return _navigateTo(context, "${Routes.sms_template_setting_page}?smsTemplate=${Uri.encodeComponent(smsTemplate)}", 1915 + return _navigateTo(context,
  1916 + "${Routes.coupon_poster_page}?id=$id&use=${FluroConvertUtils.object2string(use)}&couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}",
1902 replace: replace); 1917 replace: replace);
1903 } 1918 }
1904 } 1919 }
@@ -167,6 +167,7 @@ import '../models/set_xuan_tai_model.dart'; @@ -167,6 +167,7 @@ import '../models/set_xuan_tai_model.dart';
167 import '../models/setmeal_by_id_model.dart'; 167 import '../models/setmeal_by_id_model.dart';
168 import '../models/setmeal_model.dart'; 168 import '../models/setmeal_model.dart';
169 import '../models/wine_manage_model.dart'; 169 import '../models/wine_manage_model.dart';
  170 +import '../pages/coupon/coupon_poster_pgae.dart';
170 import '../pages/coupon/coupon_setting_page.dart'; 171 import '../pages/coupon/coupon_setting_page.dart';
171 import '../pages/coupon/coupon_verification_detail_page.dart'; 172 import '../pages/coupon/coupon_verification_detail_page.dart';
172 import '../pages/coupon/verification_coupon_page.dart'; 173 import '../pages/coupon/verification_coupon_page.dart';
@@ -3234,5 +3235,21 @@ var smsTemplateSettingPageHandle = new Handler( @@ -3234,5 +3235,21 @@ var smsTemplateSettingPageHandle = new Handler(
3234 String smsTemplate = params["smsTemplate"].first; 3235 String smsTemplate = params["smsTemplate"].first;
3235 return ChangeNotifierProvider<MarketingCenterProvider>( 3236 return ChangeNotifierProvider<MarketingCenterProvider>(
3236 create: (_) => MarketingCenterProvider(), 3237 create: (_) => MarketingCenterProvider(),
3237 - child: SmsTemplateSettingPage(smsTemplate:smsTemplate)); 3238 + child: SmsTemplateSettingPage(smsTemplate: smsTemplate));
  3239 +});
  3240 +
  3241 +//优惠券海报
  3242 +
  3243 +var couponPosterPageHandle = new Handler(
  3244 + handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
  3245 + String id = params["id"].first;
  3246 + // String smsTemplate = params["smsTemplate"].first;
  3247 + CouponUse use = CouponUse.fromJson(
  3248 + json.decode(FluroConvertUtils.fluroCnParamsDecode(params["use"].first)));
  3249 + CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode(
  3250 + FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first)));
  3251 + return ChangeNotifierProvider<BaseIndoProvider>(
  3252 + create: (_) => BaseIndoProvider(),
  3253 + child:
  3254 + CouponPosterPage(id: id, use: use, couponSunModel: couponSunModel));
3238 }); 3255 });
@@ -309,6 +309,10 @@ class Routes { @@ -309,6 +309,10 @@ class Routes {
309 309
310 static String sms_template_setting_page = "/sms_template_setting_page"; //短信模版设置 310 static String sms_template_setting_page = "/sms_template_setting_page"; //短信模版设置
311 311
  312 + static String coupon_poster_page = "/coupon_poster_page"; //优惠券海报
  313 +
  314 +
  315 +
312 316
313 317
314 318
@@ -582,6 +586,11 @@ router.define(export_book_data_page, handler: exportBookDataPageHandle); @@ -582,6 +586,11 @@ router.define(export_book_data_page, handler: exportBookDataPageHandle);
582 router.define(sms_template_setting_page, handler: smsTemplateSettingPageHandle); 586 router.define(sms_template_setting_page, handler: smsTemplateSettingPageHandle);
583 587
584 588
  589 +router.define(coupon_poster_page, handler: couponPosterPageHandle);
  590 +
  591 +
  592 +
  593 +
585 594
586 595
587 } 596 }