Commit 2f1c0d647b388d72c3452878b33f7219075b8cd8

Authored by weixin_45529955
1 parent 0a8bad06

过期优惠券点击进入详情,可复用

@@ -31,7 +31,9 @@ import '../online_check/photo_view_wiget.dart'; @@ -31,7 +31,9 @@ import '../online_check/photo_view_wiget.dart';
31 class CouponDetailPage extends StatefulWidget { 31 class CouponDetailPage extends StatefulWidget {
32 final CouponSunModel? couponSunModel; 32 final CouponSunModel? couponSunModel;
33 final String? idstr; 33 final String? idstr;
34 - CouponDetailPage({Key? key, this.couponSunModel, this.idstr}) 34 + final bool isHistory;
  35 + CouponDetailPage(
  36 + {Key? key, this.couponSunModel, this.idstr, this.isHistory = false})
35 : super(key: key); 37 : super(key: key);
36 38
37 @override 39 @override
@@ -79,8 +81,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -79,8 +81,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
79 "uid": Provider.of<UserModel>(context, listen: false).user!.openid, 81 "uid": Provider.of<UserModel>(context, listen: false).user!.openid,
80 }; 82 };
81 83
82 - bool success =  
83 - await _baseIndoProvider.getCustomerActivityBaseinfo(context, params,isShowLoading: false); 84 + bool success = await _baseIndoProvider
  85 + .getCustomerActivityBaseinfo(context, params, isShowLoading: false);
84 if (success) { 86 if (success) {
85 managerName = _baseIndoProvider.baseInfoSunModel!.name; 87 managerName = _baseIndoProvider.baseInfoSunModel!.name;
86 } 88 }
@@ -109,7 +111,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -109,7 +111,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
109 } 111 }
110 112
111 ///时间选择 113 ///时间选择
112 - Widget _select(String title, String hintText, GestureTapCallback onTap,{bool canEdit = false}) { 114 + Widget _select(String title, String hintText, GestureTapCallback onTap,
  115 + {bool canEdit = false}) {
113 return InkWell( 116 return InkWell(
114 onTap: onTap, 117 onTap: onTap,
115 child: Container( 118 child: Container(
@@ -140,7 +143,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -140,7 +143,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
140 ))), 143 ))),
141 HEmptyView(20), 144 HEmptyView(20),
142 Image.asset( 145 Image.asset(
143 - Utils.getImgPath(canEdit ? 'enter_store_arrow_r':'arrow_right_new'), 146 + Utils.getImgPath(
  147 + canEdit ? 'enter_store_arrow_r' : 'arrow_right_new'),
144 width: ScreenUtil().setWidth(20), 148 width: ScreenUtil().setWidth(20),
145 ), 149 ),
146 // HEmptyView(32), 150 // HEmptyView(32),
@@ -800,9 +804,11 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -800,9 +804,11 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
800 color: MyColours.color_E7E7E7, 804 color: MyColours.color_E7E7E7,
801 ), 805 ),
802 VEmptyView(24), 806 VEmptyView(24),
803 - Utils.getAuthority(context, '优惠券详情-编辑发放人')  
804 - ? _select('谁可以发放', nickNameShow,canEdit: true,  
805 - () async { 807 + Utils.getAuthority(
  808 + context, '优惠券详情-编辑发放人') &&
  809 + !widget.isHistory
  810 + ? _select('谁可以发放', nickNameShow,
  811 + canEdit: true, () async {
806 Map? temp = await NavigatorUtil 812 Map? temp = await NavigatorUtil
807 .goCouponToPersonnalPage( 813 .goCouponToPersonnalPage(
808 context, 814 context,
@@ -921,7 +927,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -921,7 +927,8 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
921 child: Row( 927 child: Row(
922 mainAxisAlignment: MainAxisAlignment.spaceBetween, 928 mainAxisAlignment: MainAxisAlignment.spaceBetween,
923 children: [ 929 children: [
924 - if (couponProvider.couponSunModel!.liteQrcode != null) 930 + if (couponProvider.couponSunModel!.liteQrcode != null &&
  931 + !widget.isHistory)
925 RoundButton( 932 RoundButton(
926 text: '生成海报', 933 text: '生成海报',
927 width: w(100), 934 width: w(100),
@@ -986,6 +993,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -986,6 +993,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
986 //复用,跳转至编辑页面 993 //复用,跳转至编辑页面
987 dynamic needRefresh = 994 dynamic needRefresh =
988 await NavigatorUtil.goCouponEditPage(context, 995 await NavigatorUtil.goCouponEditPage(context,
  996 + replace: widget.isHistory ? true : false,
989 isMine: couponProvider 997 isMine: couponProvider
990 .couponSunModel!.isType == 998 .couponSunModel!.isType ==
991 '1' 999 '1'
@@ -995,7 +1003,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -995,7 +1003,7 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
995 couponProvider.couponSunModel); 1003 couponProvider.couponSunModel);
996 if (needRefresh != null && needRefresh) { 1004 if (needRefresh != null && needRefresh) {
997 if (Navigator.canPop(context)) { 1005 if (Navigator.canPop(context)) {
998 - Navigator.pop(context); 1006 + Navigator.pop(context, true);
999 } 1007 }
1000 } 1008 }
1001 } else { 1009 } else {
@@ -1011,47 +1019,36 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -1011,47 +1019,36 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
1011 couponSunModel: 1019 couponSunModel:
1012 couponProvider.couponSunModel); 1020 couponProvider.couponSunModel);
1013 if (needRefresh != null && needRefresh) { 1021 if (needRefresh != null && needRefresh) {
1014 - if (Navigator.canPop(context)) {  
1015 - Navigator.pop(context); 1022 + if (mounted) {
  1023 + if (Navigator.canPop(context)) {
  1024 + Navigator.pop(context, true);
  1025 + }
1016 } 1026 }
1017 } 1027 }
1018 } 1028 }
1019 }, 1029 },
1020 ), 1030 ),
1021 HEmptyView(30), 1031 HEmptyView(30),
1022 - Expanded(  
1023 - child: RoundButton(  
1024 - text: '分享给客户',  
1025 - height: ScreenUtil().setWidth(80),  
1026 - radius: ScreenUtil().setWidth(14),  
1027 - gradientStart: MyColours.color_438E93,  
1028 - gradientEnd: MyColours.color_438E93,  
1029 - isBold: false,  
1030 - fontSize: 28,  
1031 - onPressed: () {  
1032 - if (couponProvider.couponSunModel!.status != '1') {  
1033 - Utils.showToast('请先启用优惠券后再进行操作!');  
1034 - return;  
1035 - }  
1036 - if (couponProvider.couponSunModel!.status == '1') {  
1037 - if (couponProvider.couponSunModel!.isType ==  
1038 - '3') {  
1039 - Utils.goShareBuyCouponToWeChat(  
1040 - context,  
1041 - widget.idstr,  
1042 - couponProvider.couponSunModel!.isType,  
1043 - couponProvider.couponSunModel!.use,  
1044 - couponProvider.couponSunModel);  
1045 - } else {  
1046 - // 谁可以发放  
1047 - // 可以发放的才能分享  
1048 - if (couponProvider.couponSunModel!.uidList!  
1049 - .split(',')  
1050 - .contains(Provider.of<UserModel>(context,  
1051 - listen: false)  
1052 - .user!  
1053 - .openid)) {  
1054 - //包含当前登录人 1032 + if (!widget.isHistory)
  1033 + Expanded(
  1034 + child: RoundButton(
  1035 + text: '分享给客户',
  1036 + height: ScreenUtil().setWidth(80),
  1037 + radius: ScreenUtil().setWidth(14),
  1038 + gradientStart: MyColours.color_438E93,
  1039 + gradientEnd: MyColours.color_438E93,
  1040 + isBold: false,
  1041 + fontSize: 28,
  1042 + onPressed: () {
  1043 + if (couponProvider.couponSunModel!.status !=
  1044 + '1') {
  1045 + Utils.showToast('请先启用优惠券后再进行操作!');
  1046 + return;
  1047 + }
  1048 + if (couponProvider.couponSunModel!.status ==
  1049 + '1') {
  1050 + if (couponProvider.couponSunModel!.isType ==
  1051 + '3') {
1055 Utils.goShareBuyCouponToWeChat( 1052 Utils.goShareBuyCouponToWeChat(
1056 context, 1053 context,
1057 widget.idstr, 1054 widget.idstr,
@@ -1059,23 +1056,39 @@ class _CouponDetailPageState extends State<CouponDetailPage> { @@ -1059,23 +1056,39 @@ class _CouponDetailPageState extends State<CouponDetailPage> {
1059 couponProvider.couponSunModel!.use, 1056 couponProvider.couponSunModel!.use,
1060 couponProvider.couponSunModel); 1057 couponProvider.couponSunModel);
1061 } else { 1058 } else {
1062 - Utils.showToast('您没有此权限'); 1059 + // 谁可以发放
  1060 + // 可以发放的才能分享
  1061 + if (couponProvider.couponSunModel!.uidList!
  1062 + .split(',')
  1063 + .contains(Provider.of<UserModel>(context,
  1064 + listen: false)
  1065 + .user!
  1066 + .openid)) {
  1067 + //包含当前登录人
  1068 + Utils.goShareBuyCouponToWeChat(
  1069 + context,
  1070 + widget.idstr,
  1071 + couponProvider.couponSunModel!.isType,
  1072 + couponProvider.couponSunModel!.use,
  1073 + couponProvider.couponSunModel);
  1074 + } else {
  1075 + Utils.showToast('您没有此权限');
  1076 + }
1063 } 1077 }
1064 } 1078 }
1065 - }  
1066 - // else if (couponProvider.couponSunModel.isType ==  
1067 - // '2' &&  
1068 - // couponProvider.couponSunModel.status == '1') {  
1069 - // // 我的优惠券  
1070 - // Utils.goShareBuyCouponToWeChatMy(  
1071 - // context,  
1072 - // widget.idstr,  
1073 - // managerName,  
1074 - // couponProvider.couponSunModel);  
1075 - // }  
1076 - },  
1077 - ),  
1078 - ) 1079 + // else if (couponProvider.couponSunModel.isType ==
  1080 + // '2' &&
  1081 + // couponProvider.couponSunModel.status == '1') {
  1082 + // // 我的优惠券
  1083 + // Utils.goShareBuyCouponToWeChatMy(
  1084 + // context,
  1085 + // widget.idstr,
  1086 + // managerName,
  1087 + // couponProvider.couponSunModel);
  1088 + // }
  1089 + },
  1090 + ),
  1091 + )
1079 ], 1092 ],
1080 )) 1093 ))
1081 ]); 1094 ]);
@@ -256,12 +256,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> { @@ -256,12 +256,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
256 DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse( 256 DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse(
257 widget.couponSunModel!.expirationDate!.etime.toString()) * 257 widget.couponSunModel!.expirationDate!.etime.toString()) *
258 1000); 258 1000);
259 - fromDate = '${dateTimes.year}' +  
260 - '-${Utils.addZeroNumber(dateTimes.month)}' +  
261 - '-${Utils.addZeroNumber(dateTimes.day)}'; //活动有效期开始时间  
262 - endDate = '${dateTimee.year}' +  
263 - '-${Utils.addZeroNumber(dateTimee.month)}' +  
264 - '-${Utils.addZeroNumber(dateTimee.day)}'; 259 + int comparison = dateTimes.compareTo(
  260 + DateTime.now()); // 返回0表示相等,负数表示date1小于date2,正数表示date1大于date2
  261 + if (comparison > 0) {
  262 + fromDate = '${dateTimes.year}' +
  263 + '-${Utils.addZeroNumber(dateTimes.month)}' +
  264 + '-${Utils.addZeroNumber(dateTimes.day)}'; //活动有效期开始时间
  265 + endDate = '${dateTimee.year}' +
  266 + '-${Utils.addZeroNumber(dateTimee.month)}' +
  267 + '-${Utils.addZeroNumber(dateTimee.day)}';
  268 + }
265 } 269 }
266 } 270 }
267 if (widget.couponSunModel!.aexpiration != null) { 271 if (widget.couponSunModel!.aexpiration != null) {
@@ -281,12 +285,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> { @@ -281,12 +285,16 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
281 DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch( 285 DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
282 int.parse(widget.couponSunModel!.aexpiration!.etime.toString()) * 286 int.parse(widget.couponSunModel!.aexpiration!.etime.toString()) *
283 1000); 287 1000);
284 - fromDateCus = '${dateTimes.year}' +  
285 - '-${Utils.addZeroNumber(dateTimes.month)}' +  
286 - '-${Utils.addZeroNumber(dateTimes.day)}'; //领取后有效期开始时间  
287 - endDateCus = '${dateTimee.year}' +  
288 - '-${Utils.addZeroNumber(dateTimee.month)}' +  
289 - '-${Utils.addZeroNumber(dateTimee.day)}'; 288 + int comparison = dateTimes.compareTo(
  289 + DateTime.now()); // 返回0表示相等,负数表示date1小于date2,正数表示date1大于date2
  290 + if (comparison > 0) {
  291 + fromDateCus = '${dateTimes.year}' +
  292 + '-${Utils.addZeroNumber(dateTimes.month)}' +
  293 + '-${Utils.addZeroNumber(dateTimes.day)}'; //领取后有效期开始时间
  294 + endDateCus = '${dateTimee.year}' +
  295 + '-${Utils.addZeroNumber(dateTimee.month)}' +
  296 + '-${Utils.addZeroNumber(dateTimee.day)}';
  297 + }
290 } 298 }
291 if (widget.couponSunModel!.aexpiration!.today != null && 299 if (widget.couponSunModel!.aexpiration!.today != null &&
292 widget.couponSunModel!.aexpiration!.today != '') { 300 widget.couponSunModel!.aexpiration!.today != '') {
@@ -198,10 +198,14 @@ class _CouponEidtPayPageState extends State<CouponEidtPayPage> { @@ -198,10 +198,14 @@ class _CouponEidtPayPageState extends State<CouponEidtPayPage> {
198 _couponExplainEditControl.text = widget.couponSunModel!.explain ?? ''; 198 _couponExplainEditControl.text = widget.couponSunModel!.explain ?? '';
199 DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch( 199 DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(
200 int.parse(widget.couponSunModel!.stime.toString()) * 1000); 200 int.parse(widget.couponSunModel!.stime.toString()) * 1000);
201 - fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);  
202 - DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(  
203 - int.parse(widget.couponSunModel!.etime.toString()) * 1000);  
204 - endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d); 201 + int comparison = dateTimes.compareTo(
  202 + DateTime.now()); // 返回0表示相等,负数表示date1小于date2,正数表示date1大于date2
  203 + if (comparison > 0) {
  204 + fromDate = DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
  205 + DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
  206 + int.parse(widget.couponSunModel!.etime.toString()) * 1000);
  207 + endDate = DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
  208 + }
205 209
206 swichState = widget.couponSunModel!.status == '1' ? true : false; 210 swichState = widget.couponSunModel!.status == '1' ? true : false;
207 211
1 -  
2 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
3 import 'package:flutter_easyrefresh/easy_refresh.dart'; 2 import 'package:flutter_easyrefresh/easy_refresh.dart';
4 import 'package:one_key/constant/state.dart'; 3 import 'package:one_key/constant/state.dart';
@@ -6,6 +5,7 @@ import 'package:one_key/pages/coupon/coupon_item_f.dart'; @@ -6,6 +5,7 @@ import 'package:one_key/pages/coupon/coupon_item_f.dart';
6 import 'package:one_key/provider/coupon_provider.dart'; 5 import 'package:one_key/provider/coupon_provider.dart';
7 import 'package:one_key/provider/user_model.dart'; 6 import 'package:one_key/provider/user_model.dart';
8 import 'package:one_key/res/colors.dart'; 7 import 'package:one_key/res/colors.dart';
  8 +import 'package:one_key/route/navigator_util.dart';
9 import 'package:one_key/widgets/page_exception.dart'; 9 import 'package:one_key/widgets/page_exception.dart';
10 import 'package:one_key/widgets/system_app_bar.dart'; 10 import 'package:one_key/widgets/system_app_bar.dart';
11 import 'package:one_key/widgets/v_empty_view.dart'; 11 import 'package:one_key/widgets/v_empty_view.dart';
@@ -117,16 +117,29 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { @@ -117,16 +117,29 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
117 // ); 117 // );
118 return CouponItemF( 118 return CouponItemF(
119 from: 'history', 119 from: 'history',
120 - couponSonModel: couponProvider.couponListHistory![index], 120 + couponSonModel:
  121 + couponProvider.couponListHistory![index],
121 showBtn: true, 122 showBtn: true,
122 onPressedSwich: () { 123 onPressedSwich: () {
123 // couponProvider.couponList[index].isOpenBool = 124 // couponProvider.couponList[index].isOpenBool =
124 // !couponProvider.couponList[index].isOpenBool; 125 // !couponProvider.couponList[index].isOpenBool;
125 // _setCustomerActivity(index); 126 // _setCustomerActivity(index);
126 }, 127 },
127 - onPressed: () {  
128 - // NavigatorUtil.goCouponDetailPage(  
129 - // context, couponProvider.couponList[index]); 128 + onPressed: () async {
  129 + //复用,跳转至编辑页面
  130 + dynamic needRefresh =
  131 + await NavigatorUtil.goCouponDetailPage(context,
  132 + couponProvider.couponListHistory![index],
  133 + idStr: couponProvider
  134 + .couponListHistory![index].id,
  135 + isHistory: true);
  136 + if (needRefresh != null && needRefresh) {
  137 + if (mounted) {
  138 + if (Navigator.canPop(context)) {
  139 + Navigator.pop(context);
  140 + }
  141 + }
  142 + }
130 }, 143 },
131 ); 144 );
132 }, childCount: couponProvider.couponListHistory!.length), 145 }, childCount: couponProvider.couponListHistory!.length),
@@ -55,7 +55,7 @@ class _GrantPageState extends State<GrantPage> { @@ -55,7 +55,7 @@ class _GrantPageState extends State<GrantPage> {
55 } 55 }
56 } 56 }
57 57
58 - _createConsumeQrcode(String amounts) async { 58 + _createConsumeQrcode(String amounts) async {
59 Map<String, String> pramas = { 59 Map<String, String> pramas = {
60 'sellerid': 60 'sellerid':
61 Provider.of<UserModel>(context, listen: false).user!.sellerid!, 61 Provider.of<UserModel>(context, listen: false).user!.sellerid!,
@@ -399,9 +399,9 @@ class NavigatorUtil { @@ -399,9 +399,9 @@ class NavigatorUtil {
399 /// 优惠券详情页 399 /// 优惠券详情页
400 static Future<dynamic> goCouponDetailPage( 400 static Future<dynamic> goCouponDetailPage(
401 BuildContext context, CouponSunModel? couponSunModel, 401 BuildContext context, CouponSunModel? couponSunModel,
402 - {replace = false, String? idStr}) { 402 + {replace = false, String? idStr, bool isHistory = false}) {
403 return _navigateTo(context, 403 return _navigateTo(context,
404 - "${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}&idStr=$idStr", 404 + "${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}&idStr=$idStr&isHistory=${isHistory}",
405 replace: replace); 405 replace: replace);
406 } 406 }
407 407
@@ -935,6 +935,9 @@ var handleCouponSelectPageHandler = new Handler( @@ -935,6 +935,9 @@ var handleCouponSelectPageHandler = new Handler(
935 var handleCouponDetailPageHandler = new Handler( 935 var handleCouponDetailPageHandler = new Handler(
936 handlerFunc: (BuildContext? context, Map<String, List<Object>> params) { 936 handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
937 String idStr = params["idStr"]!.first as String; 937 String idStr = params["idStr"]!.first as String;
  938 +
  939 + bool isHistory =
  940 + FluroConvertUtils.string2bool(params["isHistory"]!.first as String);
938 CouponSunModel? couponSunModel; 941 CouponSunModel? couponSunModel;
939 if (idStr == null || idStr == 'null') { 942 if (idStr == null || idStr == 'null') {
940 couponSunModel = CouponSunModel.fromJson(json.decode( 943 couponSunModel = CouponSunModel.fromJson(json.decode(
@@ -944,7 +947,7 @@ var handleCouponDetailPageHandler = new Handler( @@ -944,7 +947,7 @@ var handleCouponDetailPageHandler = new Handler(
944 947
945 return ChangeNotifierProvider<BaseIndoProvider>( 948 return ChangeNotifierProvider<BaseIndoProvider>(
946 create: (_) => BaseIndoProvider(), 949 create: (_) => BaseIndoProvider(),
947 - child: CouponDetailPage(couponSunModel: couponSunModel, idstr: idStr)); 950 + child: CouponDetailPage(couponSunModel: couponSunModel, idstr: idStr,isHistory:isHistory));
948 }); 951 });
949 952
950 ///个人资料页面 953 ///个人资料页面