Showing
18 changed files
with
1144 additions
and
265 deletions
lib/models/coupon_model.dart
0 → 100644
| 1 | +import 'package:json_annotation/json_annotation.dart'; | ||
| 2 | + | ||
| 3 | +part 'coupon_model.g.dart'; | ||
| 4 | + | ||
| 5 | +@JsonSerializable() | ||
| 6 | +class CouponModel extends Object { | ||
| 7 | + @JsonKey(name: 'ret') | ||
| 8 | + int ret; | ||
| 9 | + | ||
| 10 | + @JsonKey(name: 'data') | ||
| 11 | + List<CouponSunModel> data; | ||
| 12 | + | ||
| 13 | + @JsonKey(name: 'msg') | ||
| 14 | + String msg; | ||
| 15 | + | ||
| 16 | + CouponModel( | ||
| 17 | + this.ret, | ||
| 18 | + this.data, | ||
| 19 | + this.msg, | ||
| 20 | + ); | ||
| 21 | + | ||
| 22 | + factory CouponModel.fromJson(Map<String, dynamic> srcJson) => | ||
| 23 | + _$CouponModelFromJson(srcJson); | ||
| 24 | + | ||
| 25 | + Map<String, dynamic> toJson() => _$CouponModelToJson(this); | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +@JsonSerializable() | ||
| 29 | +class CouponSunModel extends Object { | ||
| 30 | + @JsonKey(name: 'id') | ||
| 31 | + String id; | ||
| 32 | + | ||
| 33 | + @JsonKey(name: 'uid') | ||
| 34 | + String uid; | ||
| 35 | + | ||
| 36 | + @JsonKey(name: 'aname') | ||
| 37 | + String aname; | ||
| 38 | + | ||
| 39 | + @JsonKey(name: 'desc') | ||
| 40 | + String desc; | ||
| 41 | + | ||
| 42 | + @JsonKey(name: 'stime') | ||
| 43 | + String stime; | ||
| 44 | + | ||
| 45 | + @JsonKey(name: 'etime') | ||
| 46 | + String etime; | ||
| 47 | + | ||
| 48 | + @JsonKey(name: 'explain') | ||
| 49 | + String explain; | ||
| 50 | + | ||
| 51 | + @JsonKey(name: 'status') | ||
| 52 | + String status; | ||
| 53 | + | ||
| 54 | + @JsonKey(name: 'cdate') | ||
| 55 | + String cdate; | ||
| 56 | + | ||
| 57 | + @JsonKey(name: 'receive_num') | ||
| 58 | + String receiveNum; | ||
| 59 | + | ||
| 60 | + @JsonKey(name: 'use_num') | ||
| 61 | + String useNum; | ||
| 62 | + | ||
| 63 | + @JsonKey(name: 'is_open') | ||
| 64 | + String isOpen; | ||
| 65 | + | ||
| 66 | + @JsonKey(name: 'is_open') | ||
| 67 | + bool isOpenBool = false; | ||
| 68 | + | ||
| 69 | + bool isCheck = false; | ||
| 70 | + | ||
| 71 | + CouponSunModel( | ||
| 72 | + this.id, | ||
| 73 | + this.uid, | ||
| 74 | + this.aname, | ||
| 75 | + this.desc, | ||
| 76 | + this.stime, | ||
| 77 | + this.etime, | ||
| 78 | + this.explain, | ||
| 79 | + this.status, | ||
| 80 | + this.cdate, | ||
| 81 | + this.receiveNum, | ||
| 82 | + this.useNum, | ||
| 83 | + this.isOpen, | ||
| 84 | + this.isOpenBool); | ||
| 85 | + | ||
| 86 | + factory CouponSunModel.fromJson(Map<String, dynamic> srcJson) => | ||
| 87 | + _$CouponSunModelFromJson(srcJson); | ||
| 88 | + | ||
| 89 | + Map<String, dynamic> toJson() => _$CouponSunModelToJson(this); | ||
| 90 | +} |
lib/models/coupon_model.g.dart
0 → 100644
| 1 | +// GENERATED CODE - DO NOT MODIFY BY HAND | ||
| 2 | + | ||
| 3 | +part of 'coupon_model.dart'; | ||
| 4 | + | ||
| 5 | +// ************************************************************************** | ||
| 6 | +// JsonSerializableGenerator | ||
| 7 | +// ************************************************************************** | ||
| 8 | + | ||
| 9 | +CouponModel _$CouponModelFromJson(Map<String, dynamic> json) { | ||
| 10 | + return CouponModel( | ||
| 11 | + json['ret'] as int, | ||
| 12 | + (json['data'] as List) | ||
| 13 | + ?.map((e) => e == null | ||
| 14 | + ? null | ||
| 15 | + : CouponSunModel.fromJson(e as Map<String, dynamic>)) | ||
| 16 | + ?.toList(), | ||
| 17 | + json['msg'] as String); | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +Map<String, dynamic> _$CouponModelToJson(CouponModel instance) => | ||
| 21 | + <String, dynamic>{ | ||
| 22 | + 'ret': instance.ret, | ||
| 23 | + 'data': instance.data, | ||
| 24 | + 'msg': instance.msg | ||
| 25 | + }; | ||
| 26 | + | ||
| 27 | +CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) { | ||
| 28 | + return CouponSunModel( | ||
| 29 | + json['id'] as String, | ||
| 30 | + json['uid'] as String, | ||
| 31 | + json['aname'] as String, | ||
| 32 | + json['desc'] as String, | ||
| 33 | + json['stime'] as String, | ||
| 34 | + json['etime'] as String, | ||
| 35 | + json['explain'] as String, | ||
| 36 | + json['status'] as String, | ||
| 37 | + json['cdate'] as String, | ||
| 38 | + json['receive_num'] as String, | ||
| 39 | + json['use_num'] as String, | ||
| 40 | + json['is_open'] as String, | ||
| 41 | + json['status'] == "1" ? true : false, | ||
| 42 | + ); | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) => | ||
| 46 | + <String, dynamic>{ | ||
| 47 | + 'id': instance.id, | ||
| 48 | + 'uid': instance.uid, | ||
| 49 | + 'aname': instance.aname, | ||
| 50 | + 'desc': instance.desc, | ||
| 51 | + 'stime': instance.stime, | ||
| 52 | + 'etime': instance.etime, | ||
| 53 | + 'explain': instance.explain, | ||
| 54 | + 'status': instance.status, | ||
| 55 | + 'cdate': instance.cdate, | ||
| 56 | + 'receiveNum': instance.receiveNum, | ||
| 57 | + 'useNum': instance.useNum, | ||
| 58 | + 'isOpen': instance.isOpen, | ||
| 59 | + 'isOpenBool': instance.isOpenBool | ||
| 60 | + }; |
| @@ -179,7 +179,7 @@ class DioUtil { | @@ -179,7 +179,7 @@ class DioUtil { | ||
| 179 | bool showLoading = true}) async { | 179 | bool showLoading = true}) async { |
| 180 | bool connectivity = await Utils.checkConnectiviy(); | 180 | bool connectivity = await Utils.checkConnectiviy(); |
| 181 | if (!connectivity) { | 181 | if (!connectivity) { |
| 182 | -// Utils.showToast("网络错误,请稍后重试"); | 182 | + Utils.showToast("网络错误,请稍后重试"); |
| 183 | throw MyError(type: 1); | 183 | throw MyError(type: 1); |
| 184 | } | 184 | } |
| 185 | if (showLoading) Loading.showLoading(context); | 185 | if (showLoading) Loading.showLoading(context); |
| @@ -71,5 +71,15 @@ class HttpUrl { | @@ -71,5 +71,15 @@ class HttpUrl { | ||
| 71 | "?service=App.Customer.UpdateOrderInfo"; // 商家确认账单 | 71 | "?service=App.Customer.UpdateOrderInfo"; // 商家确认账单 |
| 72 | static const String new_get_reserve_list = | 72 | static const String new_get_reserve_list = |
| 73 | "?service=App.Reserve.NewGetReserveList"; //商家预订本列表【2019-11-26】 | 73 | "?service=App.Reserve.NewGetReserveList"; //商家预订本列表【2019-11-26】 |
| 74 | + static const String create_customer_activity = | ||
| 75 | + "?service=App.Activity.CreateCustomerActivity"; //客户经理创建活动 | ||
| 76 | + static const String get_customer_activity = | ||
| 77 | + "?service=App.Activity.CustomerActivityList"; //获取所创建活动的列表 | ||
| 78 | + static const String set_customer_activity = | ||
| 79 | + "?service=App.Activity.SetCustomerActivity"; //修改所创建活动的列表 | ||
| 80 | + static const String set_activity_as_reserve = | ||
| 81 | + "?service=App.Activity.SetActivityAsReserve"; //设置预定绑定活动ID | ||
| 82 | + static const String get_activity_by_rid = | ||
| 83 | + "?service=App.Activity.GetActivityByRid"; //获取预定绑定活动 | ||
| 74 | 84 | ||
| 75 | } | 85 | } |
lib/pages/coupon/coupon_detail_page.dart
0 → 100644
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 2 | +import 'package:flutter/material.dart'; | ||
| 3 | +import 'package:flutter_picker/flutter_picker.dart'; | ||
| 4 | +import 'package:flutter_screenutil/screenutil.dart'; | ||
| 5 | +import 'package:fluttertoast/fluttertoast.dart'; | ||
| 6 | +import 'package:one_key/models/coupon_model.dart'; | ||
| 7 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 8 | +import 'package:one_key/provider/user_model.dart'; | ||
| 9 | +import 'package:one_key/res/colors.dart'; | ||
| 10 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 11 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 12 | +import 'package:one_key/utils/navigator_util.dart'; | ||
| 13 | +import 'package:one_key/utils/utils.dart'; | ||
| 14 | +import 'package:one_key/widgets/h_empty_view.dart'; | ||
| 15 | +import 'package:one_key/widgets/round_button.dart'; | ||
| 16 | +import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 17 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 18 | +import 'package:provider/provider.dart'; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 新建券 | ||
| 22 | + */ | ||
| 23 | + | ||
| 24 | +class CouponDetailPage extends StatefulWidget { | ||
| 25 | + final CouponSunModel couponSunModel; | ||
| 26 | + CouponDetailPage({Key key, this.couponSunModel}) : super(key: key); | ||
| 27 | + | ||
| 28 | + @override | ||
| 29 | + _CouponDetailPageState createState() => _CouponDetailPageState(); | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +class _CouponDetailPageState extends State<CouponDetailPage> { | ||
| 33 | + ScrollController controller = ScrollController(); | ||
| 34 | + final heightCell = ScreenUtil().setWidth(80); | ||
| 35 | + CouponProvider couponProvider; | ||
| 36 | + | ||
| 37 | + @override | ||
| 38 | + void initState() { | ||
| 39 | + super.initState(); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + ///输入框 | ||
| 43 | + Widget _item(String title, String subTitle) { | ||
| 44 | + return Container( | ||
| 45 | + constraints: BoxConstraints(minHeight: heightCell), | ||
| 46 | + child: Row( | ||
| 47 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
| 48 | + mainAxisAlignment: MainAxisAlignment.center, | ||
| 49 | + children: [ | ||
| 50 | + Container( | ||
| 51 | + child: Text( | ||
| 52 | + title, | ||
| 53 | + style: TextStyle( | ||
| 54 | + fontWeight: FontWeight.bold, | ||
| 55 | + fontSize: ScreenUtil().setSp(30)), | ||
| 56 | + ), | ||
| 57 | + ), | ||
| 58 | + HEmptyView(60), | ||
| 59 | + Expanded( | ||
| 60 | + child: Text( | ||
| 61 | + subTitle, | ||
| 62 | + maxLines: 20, | ||
| 63 | + textAlign: TextAlign.right, | ||
| 64 | + overflow: TextOverflow.ellipsis, | ||
| 65 | + style: TextStyle( | ||
| 66 | + color: MyColours.color_333333, | ||
| 67 | + fontSize: ScreenUtil().setSp(26), | ||
| 68 | + ), | ||
| 69 | + )) | ||
| 70 | + ], | ||
| 71 | + ), | ||
| 72 | + ); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @override | ||
| 76 | + Widget build(BuildContext context) { | ||
| 77 | + couponProvider = Provider.of<CouponProvider>(context, listen: true); | ||
| 78 | + return Scaffold( | ||
| 79 | + appBar: SystemAppBar( | ||
| 80 | + '券详情', | ||
| 81 | + onTap: () { | ||
| 82 | + Navigator.pop(context); | ||
| 83 | + }, | ||
| 84 | + ), | ||
| 85 | + body: Column(children: [ | ||
| 86 | + Expanded( | ||
| 87 | + child: SingleChildScrollView( | ||
| 88 | + controller: controller, | ||
| 89 | + physics: BouncingScrollPhysics(), | ||
| 90 | + child: Padding( | ||
| 91 | + padding: EdgeInsets.symmetric( | ||
| 92 | + horizontal: ScreenUtil().setWidth(40)), | ||
| 93 | + child: Column( | ||
| 94 | + children: [ | ||
| 95 | + VEmptyView(20), | ||
| 96 | + _item('券名称', widget.couponSunModel.aname), | ||
| 97 | + VEmptyView(5), | ||
| 98 | + _item('券要求', widget.couponSunModel.desc), | ||
| 99 | + VEmptyView(5), | ||
| 100 | + _item( | ||
| 101 | + '有效期从', | ||
| 102 | + Utils.getDateStrFromJiekou( | ||
| 103 | + widget.couponSunModel.stime)), | ||
| 104 | + VEmptyView(5), | ||
| 105 | + _item( | ||
| 106 | + '有效期至', | ||
| 107 | + Utils.getDateStrFromJiekou( | ||
| 108 | + widget.couponSunModel.etime)), | ||
| 109 | + widget.couponSunModel.explain != null || | ||
| 110 | + widget.couponSunModel.explain != '' | ||
| 111 | + ? VEmptyView(5) | ||
| 112 | + : Container(), | ||
| 113 | + widget.couponSunModel.explain != null && | ||
| 114 | + widget.couponSunModel.explain != '' | ||
| 115 | + ? _item('券说明', widget.couponSunModel.explain) | ||
| 116 | + : Container(), | ||
| 117 | + VEmptyView(5), | ||
| 118 | + _item('券状态', | ||
| 119 | + widget.couponSunModel.status == '1' ? '启用' : '停用') | ||
| 120 | + ], | ||
| 121 | + ))), | ||
| 122 | + ) | ||
| 123 | + ]), | ||
| 124 | + ); | ||
| 125 | + } | ||
| 126 | +} |
| @@ -3,14 +3,18 @@ import 'package:flutter/material.dart'; | @@ -3,14 +3,18 @@ import 'package:flutter/material.dart'; | ||
| 3 | import 'package:flutter_picker/flutter_picker.dart'; | 3 | import 'package:flutter_picker/flutter_picker.dart'; |
| 4 | import 'package:flutter_screenutil/screenutil.dart'; | 4 | import 'package:flutter_screenutil/screenutil.dart'; |
| 5 | import 'package:fluttertoast/fluttertoast.dart'; | 5 | import 'package:fluttertoast/fluttertoast.dart'; |
| 6 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 7 | +import 'package:one_key/provider/user_model.dart'; | ||
| 6 | import 'package:one_key/res/colors.dart'; | 8 | import 'package:one_key/res/colors.dart'; |
| 7 | import 'package:one_key/utils/dialog_util.dart'; | 9 | import 'package:one_key/utils/dialog_util.dart'; |
| 10 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 8 | import 'package:one_key/utils/navigator_util.dart'; | 11 | import 'package:one_key/utils/navigator_util.dart'; |
| 9 | import 'package:one_key/utils/utils.dart'; | 12 | import 'package:one_key/utils/utils.dart'; |
| 10 | import 'package:one_key/widgets/h_empty_view.dart'; | 13 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 11 | import 'package:one_key/widgets/round_button.dart'; | 14 | import 'package:one_key/widgets/round_button.dart'; |
| 12 | import 'package:one_key/widgets/system_app_bar.dart'; | 15 | import 'package:one_key/widgets/system_app_bar.dart'; |
| 13 | import 'package:one_key/widgets/v_empty_view.dart'; | 16 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 17 | +import 'package:provider/provider.dart'; | ||
| 14 | 18 | ||
| 15 | /** | 19 | /** |
| 16 | * 新建券 | 20 | * 新建券 |
| @@ -36,6 +40,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -36,6 +40,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 36 | FocusNode _nameFocusNode = FocusNode(); | 40 | FocusNode _nameFocusNode = FocusNode(); |
| 37 | FocusNode _requireFocusNode = FocusNode(); | 41 | FocusNode _requireFocusNode = FocusNode(); |
| 38 | bool showDateSelWidget = false; | 42 | bool showDateSelWidget = false; |
| 43 | + CouponProvider couponProvider; | ||
| 39 | 44 | ||
| 40 | @override | 45 | @override |
| 41 | void initState() { | 46 | void initState() { |
| @@ -66,6 +71,32 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -66,6 +71,32 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 66 | }); | 71 | }); |
| 67 | } | 72 | } |
| 68 | 73 | ||
| 74 | + //创建新券 客户经理创建活动 | ||
| 75 | + _createNewCoupon() async { | ||
| 76 | + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 77 | + Map<String, String> params = { | ||
| 78 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 79 | + "aname": _couponNameEditControl.text.trim(), | ||
| 80 | + "desc": _couponRequireEditControl.text.trim(), | ||
| 81 | + "stime": fromDate == '点击选择' | ||
| 82 | + ? "" | ||
| 83 | + : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}', | ||
| 84 | + "etime": endDate == '点击选择' | ||
| 85 | + ? '' | ||
| 86 | + : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}', | ||
| 87 | + "explain": _couponExplainEditControl.text, | ||
| 88 | + "is_open": swichState ? "1" : "0", | ||
| 89 | + "status": swichState ? "1" : "0" | ||
| 90 | + }; | ||
| 91 | + bool isSuccess = | ||
| 92 | + await couponProvider.createCustomerActivity(context, params); | ||
| 93 | + if (isSuccess) { | ||
| 94 | + //成功之后跳回前一个页面 | ||
| 95 | + // bus.emit('refresh_coupon_list'); | ||
| 96 | + Navigator.pop(context, true); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + | ||
| 69 | ///输入框 | 100 | ///输入框 |
| 70 | Widget _textfield(String title, String hintText) { | 101 | Widget _textfield(String title, String hintText) { |
| 71 | return Container( | 102 | return Container( |
| @@ -284,6 +315,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -284,6 +315,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 284 | 315 | ||
| 285 | @override | 316 | @override |
| 286 | Widget build(BuildContext context) { | 317 | Widget build(BuildContext context) { |
| 318 | + couponProvider = Provider.of<CouponProvider>(context, listen: true); | ||
| 287 | return Scaffold( | 319 | return Scaffold( |
| 288 | key: scaffoldKey, | 320 | key: scaffoldKey, |
| 289 | appBar: SystemAppBar( | 321 | appBar: SystemAppBar( |
| @@ -338,10 +370,6 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -338,10 +370,6 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 338 | Utils.showToast('请选择有效期结束时间'); | 370 | Utils.showToast('请选择有效期结束时间'); |
| 339 | return; | 371 | return; |
| 340 | } | 372 | } |
| 341 | - if (_couponExplainEditControl.text.trim().length == 0) { | ||
| 342 | - Utils.showToast('请填写券说明'); | ||
| 343 | - return; | ||
| 344 | - } | ||
| 345 | if (DateUtil.getDateTime(endDate) | 373 | if (DateUtil.getDateTime(endDate) |
| 346 | .compareTo(DateUtil.getDateTime(fromDate)) < | 374 | .compareTo(DateUtil.getDateTime(fromDate)) < |
| 347 | 0) { | 375 | 0) { |
| @@ -355,9 +383,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -355,9 +383,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 355 | // endDate | 383 | // endDate |
| 356 | // _couponExplainEditControl.text | 384 | // _couponExplainEditControl.text |
| 357 | // swichState | 385 | // swichState |
| 358 | - | ||
| 359 | - //成功之后跳回前一个页面 | ||
| 360 | - Navigator.pop(context, true); | 386 | + _createNewCoupon(); |
| 361 | }, | 387 | }, |
| 362 | text: '保存', | 388 | text: '保存', |
| 363 | fontSize: 34, | 389 | fontSize: 34, |
| @@ -3,6 +3,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | @@ -3,6 +3,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 3 | import 'package:one_key/constant/state.dart'; | 3 | import 'package:one_key/constant/state.dart'; |
| 4 | import 'package:one_key/pages/coupon/coupon_item.dart'; | 4 | import 'package:one_key/pages/coupon/coupon_item.dart'; |
| 5 | import 'package:one_key/provider/coupon_provider.dart'; | 5 | import 'package:one_key/provider/coupon_provider.dart'; |
| 6 | +import 'package:one_key/provider/user_model.dart'; | ||
| 6 | import 'package:one_key/widgets/page_exception.dart'; | 7 | import 'package:one_key/widgets/page_exception.dart'; |
| 7 | import 'package:one_key/widgets/system_app_bar.dart'; | 8 | import 'package:one_key/widgets/system_app_bar.dart'; |
| 8 | import 'package:provider/provider.dart'; | 9 | import 'package:provider/provider.dart'; |
| @@ -21,12 +22,14 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | @@ -21,12 +22,14 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | ||
| 21 | EasyRefreshController _controller = EasyRefreshController(); | 22 | EasyRefreshController _controller = EasyRefreshController(); |
| 22 | CouponProvider couponProvider; | 23 | CouponProvider couponProvider; |
| 23 | 24 | ||
| 24 | - ///获取优惠券列表数据 | ||
| 25 | - _couponNetworkData() { | ||
| 26 | - return Future.delayed(Duration(seconds: 1), () { | ||
| 27 | - couponProvider.pageStateHistory = PageState.Success; | ||
| 28 | - couponProvider.notifyListeners(); | ||
| 29 | - }); | 25 | + ///获取优惠券历史列表数据 |
| 26 | + _couponNetworkData({bool isShowLoading = true}) async { | ||
| 27 | + Map<String, String> params = { | ||
| 28 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 29 | + 'is_time': '1' | ||
| 30 | + }; | ||
| 31 | + await couponProvider.getCustomerHistoryActivity(context, params, | ||
| 32 | + isShowLoading: isShowLoading); | ||
| 30 | } | 33 | } |
| 31 | 34 | ||
| 32 | @override | 35 | @override |
| @@ -69,25 +72,25 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | @@ -69,25 +72,25 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | ||
| 69 | delegate: SliverChildBuilderDelegate( | 72 | delegate: SliverChildBuilderDelegate( |
| 70 | (BuildContext context, int index) { | 73 | (BuildContext context, int index) { |
| 71 | return CouponItem( | 74 | return CouponItem( |
| 72 | - index: index, | ||
| 73 | - couponProvider: couponProvider, | 75 | + from: 'history', |
| 76 | + couponSonModel: couponProvider.couponListHistory[index], | ||
| 74 | onPressed: () { | 77 | onPressed: () { |
| 75 | - couponProvider.swichStateData[index] = | ||
| 76 | - !couponProvider.swichStateData[index]; | ||
| 77 | - couponProvider.notifyListeners(); | 78 | + // couponProvider.couponListHistory[index] = |
| 79 | + // !couponProvider.couponListHistory[index]; | ||
| 80 | + // couponProvider.notifyListeners(); | ||
| 78 | }, | 81 | }, |
| 79 | ); | 82 | ); |
| 80 | - }, childCount: couponProvider.swichStateData.length), | 83 | + }, childCount: couponProvider.couponListHistory.length), |
| 81 | ) | 84 | ) |
| 82 | ], | 85 | ], |
| 83 | - onRefresh: () async { | ||
| 84 | - // offset = 0; | ||
| 85 | - // getMessage(showLoading: false); | ||
| 86 | - }, | ||
| 87 | - onLoad: () async { | ||
| 88 | - // offset++; | ||
| 89 | - // getMessage(showLoading: false); | ||
| 90 | - }, | 86 | + // onRefresh: () async { |
| 87 | + // // offset = 0; | ||
| 88 | + // // getMessage(showLoading: false); | ||
| 89 | + // }, | ||
| 90 | + // onLoad: () async { | ||
| 91 | + // // offset++; | ||
| 92 | + // // getMessage(showLoading: false); | ||
| 93 | + // }, | ||
| 91 | ); | 94 | ); |
| 92 | } | 95 | } |
| 93 | }, | 96 | }, |
| 1 | +import 'package:common_utils/common_utils.dart'; | ||
| 1 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | +import 'package:one_key/models/coupon_model.dart'; | ||
| 3 | import 'package:one_key/provider/coupon_provider.dart'; | 5 | import 'package:one_key/provider/coupon_provider.dart'; |
| 4 | import 'package:one_key/res/colors.dart'; | 6 | import 'package:one_key/res/colors.dart'; |
| 7 | +import 'package:one_key/utils/utils.dart'; | ||
| 5 | import 'package:one_key/widgets/h_empty_view.dart'; | 8 | import 'package:one_key/widgets/h_empty_view.dart'; |
| 6 | import 'package:one_key/widgets/round_button.dart'; | 9 | import 'package:one_key/widgets/round_button.dart'; |
| 7 | import 'package:one_key/widgets/v_empty_view.dart'; | 10 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 8 | 11 | ||
| 9 | class CouponItem extends StatefulWidget { | 12 | class CouponItem extends StatefulWidget { |
| 10 | - final int index; | 13 | + final String from; |
| 11 | final VoidCallback onPressed; | 14 | final VoidCallback onPressed; |
| 12 | - final CouponProvider couponProvider; | 15 | + final VoidCallback onPressedSwich; |
| 16 | + final CouponSunModel couponSonModel; | ||
| 13 | final bool showBtn; | 17 | final bool showBtn; |
| 14 | CouponItem( | 18 | CouponItem( |
| 15 | {Key key, | 19 | {Key key, |
| 16 | - this.index, | 20 | + this.from, |
| 17 | this.onPressed, | 21 | this.onPressed, |
| 18 | - this.couponProvider, | 22 | + this.onPressedSwich, |
| 23 | + this.couponSonModel, | ||
| 19 | this.showBtn = false}) | 24 | this.showBtn = false}) |
| 20 | : super(key: key); | 25 | : super(key: key); |
| 21 | 26 | ||
| @@ -26,101 +31,141 @@ class CouponItem extends StatefulWidget { | @@ -26,101 +31,141 @@ class CouponItem extends StatefulWidget { | ||
| 26 | class _CouponItemState extends State<CouponItem> { | 31 | class _CouponItemState extends State<CouponItem> { |
| 27 | @override | 32 | @override |
| 28 | Widget build(BuildContext context) { | 33 | Widget build(BuildContext context) { |
| 29 | - bool switchState = widget.couponProvider.swichStateData[widget.index]; | ||
| 30 | - return Stack( | ||
| 31 | - children: [ | ||
| 32 | - Container( | ||
| 33 | - // width: ScreenUtil().setWidth(610), | ||
| 34 | - margin: EdgeInsets.symmetric( | ||
| 35 | - horizontal: ScreenUtil().setWidth(30), | ||
| 36 | - vertical: ScreenUtil().setWidth(12)), | ||
| 37 | - padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 38 | - decoration: BoxDecoration( | ||
| 39 | - color: switchState ? MyColours.app_main : MyColours.color_E0E0E0, | ||
| 40 | - borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 41 | - child: Column( | ||
| 42 | - mainAxisSize: MainAxisSize.min, | ||
| 43 | - crossAxisAlignment: CrossAxisAlignment.start, | ||
| 44 | - children: [ | ||
| 45 | - Row( | ||
| 46 | - crossAxisAlignment: CrossAxisAlignment.end, | ||
| 47 | - children: [ | ||
| 48 | - Text( | ||
| 49 | - '九折券', | ||
| 50 | - style: TextStyle( | ||
| 51 | - color: MyColours.color_ffffff, | ||
| 52 | - fontSize: ScreenUtil().setSp(50), | ||
| 53 | - fontWeight: FontWeight.bold), | 34 | + CouponSunModel sunModel = widget.couponSonModel; |
| 35 | + bool notSelect = false; | ||
| 36 | + if (widget.from == 'history') { | ||
| 37 | + notSelect = false; | ||
| 38 | + } else { | ||
| 39 | + notSelect = sunModel.isOpenBool; | ||
| 40 | + } | ||
| 41 | + return InkWell( | ||
| 42 | + onTap: widget.onPressed, | ||
| 43 | + child: Stack( | ||
| 44 | + children: [ | ||
| 45 | + Container( | ||
| 46 | + // width: ScreenUtil().setWidth(610), | ||
| 47 | + margin: EdgeInsets.symmetric( | ||
| 48 | + horizontal: ScreenUtil().setWidth(30), | ||
| 49 | + vertical: ScreenUtil().setWidth(12)), | ||
| 50 | + padding: EdgeInsets.all(ScreenUtil().setWidth(30)), | ||
| 51 | + decoration: BoxDecoration( | ||
| 52 | + color: notSelect ? MyColours.app_main : MyColours.color_E0E0E0, | ||
| 53 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 54 | + child: Column( | ||
| 55 | + mainAxisSize: MainAxisSize.min, | ||
| 56 | + crossAxisAlignment: CrossAxisAlignment.start, | ||
| 57 | + children: [ | ||
| 58 | + Container( | ||
| 59 | + width: ScreenUtil().setWidth(360), | ||
| 60 | + child: Row( | ||
| 61 | + crossAxisAlignment: CrossAxisAlignment.end, | ||
| 62 | + children: [ | ||
| 63 | + Container( | ||
| 64 | + constraints: BoxConstraints( | ||
| 65 | + maxWidth: ScreenUtil().setWidth(190)), | ||
| 66 | + child: Text( | ||
| 67 | + sunModel.aname, | ||
| 68 | + maxLines: 2, | ||
| 69 | + overflow: TextOverflow.ellipsis, | ||
| 70 | + style: TextStyle( | ||
| 71 | + color: MyColours.color_ffffff, | ||
| 72 | + fontSize: ScreenUtil().setSp(34), | ||
| 73 | + fontWeight: FontWeight.bold), | ||
| 74 | + ), | ||
| 75 | + ), | ||
| 76 | + Expanded( | ||
| 77 | + flex: 1, | ||
| 78 | + child: Container( | ||
| 79 | + padding: EdgeInsets.only( | ||
| 80 | + bottom: ScreenUtil().setWidth(6)), | ||
| 81 | + child: Text('( ${sunModel.desc} )', | ||
| 82 | + maxLines: 1, | ||
| 83 | + overflow: TextOverflow.ellipsis, | ||
| 84 | + style: TextStyle( | ||
| 85 | + color: MyColours.color_ffffff, | ||
| 86 | + fontSize: ScreenUtil().setSp(22), | ||
| 87 | + fontWeight: FontWeight.bold)), | ||
| 88 | + )) | ||
| 89 | + ], | ||
| 54 | ), | 90 | ), |
| 55 | - Text('(无门槛)', | ||
| 56 | - style: TextStyle( | ||
| 57 | - color: MyColours.color_ffffff, | ||
| 58 | - fontSize: ScreenUtil().setSp(22), | ||
| 59 | - fontWeight: FontWeight.bold)) | ||
| 60 | - ], | ||
| 61 | - ), | ||
| 62 | - VEmptyView(20), | ||
| 63 | - Container( | ||
| 64 | - padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 65 | - child: Text('说明:大哈就快费复大家发哈接电话费哈就快递费快回复解答快回复', | ||
| 66 | - maxLines: 30, | ||
| 67 | - overflow: TextOverflow.ellipsis, | ||
| 68 | - softWrap: false, | ||
| 69 | - style: TextStyle( | ||
| 70 | - color: switchState | ||
| 71 | - ? MyColours.app_main | ||
| 72 | - : MyColours.color_e5e5e5, | ||
| 73 | - fontSize: ScreenUtil().setSp(22))), | ||
| 74 | - decoration: BoxDecoration( | ||
| 75 | - color: MyColours.color_ffffff, | ||
| 76 | - borderRadius: | ||
| 77 | - BorderRadius.circular(ScreenUtil().setWidth(10))), | ||
| 78 | - ), | ||
| 79 | - Container( | ||
| 80 | - padding: EdgeInsets.only(top: ScreenUtil().setWidth(20)), | ||
| 81 | - child: Text('有效期:2021.01.01 00:00:00 至 2021.01.31 23:59:59', | ||
| 82 | - style: TextStyle( | ||
| 83 | - color: MyColours.color_ffffff, | ||
| 84 | - fontSize: ScreenUtil().setSp(22))), | ||
| 85 | - ), | ||
| 86 | - ], | 91 | + ), |
| 92 | + ObjectUtil.isNotEmpty(sunModel.explain) | ||
| 93 | + ? Container( | ||
| 94 | + margin: EdgeInsets.only(top: ScreenUtil().setWidth(30)), | ||
| 95 | + padding: EdgeInsets.all(ScreenUtil().setWidth(20)), | ||
| 96 | + width: double.infinity, | ||
| 97 | + child: Text('说明:${sunModel.explain}', | ||
| 98 | + maxLines: 30, | ||
| 99 | + overflow: TextOverflow.ellipsis, | ||
| 100 | + softWrap: false, | ||
| 101 | + style: TextStyle( | ||
| 102 | + color: notSelect | ||
| 103 | + ? MyColours.app_main | ||
| 104 | + : MyColours.color_e5e5e5, | ||
| 105 | + fontSize: ScreenUtil().setSp(22))), | ||
| 106 | + decoration: BoxDecoration( | ||
| 107 | + color: MyColours.color_ffffff, | ||
| 108 | + borderRadius: BorderRadius.circular( | ||
| 109 | + ScreenUtil().setWidth(10))), | ||
| 110 | + ) | ||
| 111 | + : Container(), | ||
| 112 | + (ObjectUtil.isNotEmpty(sunModel.stime) && | ||
| 113 | + sunModel.stime != '0') || | ||
| 114 | + (ObjectUtil.isNotEmpty(sunModel.etime) && | ||
| 115 | + sunModel.etime != '0') | ||
| 116 | + ? Container( | ||
| 117 | + padding: | ||
| 118 | + EdgeInsets.only(top: ScreenUtil().setWidth(20)), | ||
| 119 | + child: Text( | ||
| 120 | + '有效期:${ObjectUtil.isNotEmpty(sunModel.stime) ? Utils.getDateStrFromJiekou(sunModel.stime) : '--'} 至 ${ObjectUtil.isNotEmpty(sunModel.etime) ? Utils.getDateStrFromJiekou(sunModel.etime) : '--'}', | ||
| 121 | + style: TextStyle( | ||
| 122 | + color: MyColours.color_ffffff, | ||
| 123 | + fontSize: ScreenUtil().setSp(22))), | ||
| 124 | + ) | ||
| 125 | + : Container(), | ||
| 126 | + ], | ||
| 127 | + ), | ||
| 87 | ), | 128 | ), |
| 88 | - ), | ||
| 89 | - Positioned( | ||
| 90 | - top: ScreenUtil().setWidth(40), | ||
| 91 | - right: ScreenUtil().setWidth(40), | ||
| 92 | - child: Row( | ||
| 93 | - children: [ | ||
| 94 | - Column( | ||
| 95 | - crossAxisAlignment: CrossAxisAlignment.start, | 129 | + Positioned( |
| 130 | + top: ScreenUtil().setWidth(30), | ||
| 131 | + right: ScreenUtil().setWidth(60), | ||
| 132 | + child: InkWell( | ||
| 133 | + onTap: widget.onPressedSwich, | ||
| 134 | + child: Row( | ||
| 96 | children: [ | 135 | children: [ |
| 97 | - Text('被领取:99张', | ||
| 98 | - style: TextStyle( | ||
| 99 | - color: MyColours.color_ffffff, | ||
| 100 | - fontSize: ScreenUtil().setSp(22))), | ||
| 101 | - Text('已使用:9张', | ||
| 102 | - style: TextStyle( | ||
| 103 | - color: MyColours.color_ffffff, | ||
| 104 | - fontSize: ScreenUtil().setSp(22))), | 136 | + Column( |
| 137 | + crossAxisAlignment: CrossAxisAlignment.start, | ||
| 138 | + children: [ | ||
| 139 | + Text('被领取:${sunModel.receiveNum}张', | ||
| 140 | + style: TextStyle( | ||
| 141 | + color: MyColours.color_ffffff, | ||
| 142 | + fontSize: ScreenUtil().setSp(22))), | ||
| 143 | + VEmptyView(5), | ||
| 144 | + Text('已使用:${sunModel.useNum}张', | ||
| 145 | + style: TextStyle( | ||
| 146 | + color: MyColours.color_ffffff, | ||
| 147 | + fontSize: ScreenUtil().setSp(22))), | ||
| 148 | + ], | ||
| 149 | + ), | ||
| 150 | + HEmptyView(20), | ||
| 151 | + widget.showBtn | ||
| 152 | + ? RoundButton( | ||
| 153 | + width: ScreenUtil().setWidth(100), | ||
| 154 | + height: ScreenUtil().setWidth(50), | ||
| 155 | + radius: ScreenUtil().setWidth(10), | ||
| 156 | + text: notSelect ? '停用' : '启用', | ||
| 157 | + textColor: MyColours.color_666666, | ||
| 158 | + gradientStart: Colors.white, | ||
| 159 | + gradientEnd: Colors.white, | ||
| 160 | + onPressed: widget.onPressedSwich, | ||
| 161 | + ) | ||
| 162 | + : Container() | ||
| 105 | ], | 163 | ], |
| 106 | ), | 164 | ), |
| 107 | - HEmptyView(20), | ||
| 108 | - widget.showBtn | ||
| 109 | - ? RoundButton( | ||
| 110 | - width: ScreenUtil().setWidth(100), | ||
| 111 | - height: ScreenUtil().setWidth(50), | ||
| 112 | - radius: ScreenUtil().setWidth(10), | ||
| 113 | - text: switchState ? '停用' : '启用', | ||
| 114 | - textColor: MyColours.color_666666, | ||
| 115 | - gradientStart: Colors.white, | ||
| 116 | - gradientEnd: Colors.white, | ||
| 117 | - onPressed: widget.onPressed, | ||
| 118 | - ) | ||
| 119 | - : Container() | ||
| 120 | - ], | ||
| 121 | - ), | ||
| 122 | - ) | ||
| 123 | - ], | 165 | + ), |
| 166 | + ) | ||
| 167 | + ], | ||
| 168 | + ), | ||
| 124 | ); | 169 | ); |
| 125 | } | 170 | } |
| 126 | } | 171 | } |
| @@ -4,6 +4,8 @@ import 'package:flutter_screenutil/screenutil.dart'; | @@ -4,6 +4,8 @@ import 'package:flutter_screenutil/screenutil.dart'; | ||
| 4 | import 'package:one_key/constant/state.dart'; | 4 | import 'package:one_key/constant/state.dart'; |
| 5 | import 'package:one_key/pages/coupon/coupon_item.dart'; | 5 | import 'package:one_key/pages/coupon/coupon_item.dart'; |
| 6 | import 'package:one_key/provider/coupon_provider.dart'; | 6 | import 'package:one_key/provider/coupon_provider.dart'; |
| 7 | +import 'package:one_key/provider/user_model.dart'; | ||
| 8 | +import 'package:one_key/res/colors.dart'; | ||
| 7 | import 'package:one_key/utils/event_bus.dart'; | 9 | import 'package:one_key/utils/event_bus.dart'; |
| 8 | import 'package:one_key/utils/navigator_util.dart'; | 10 | import 'package:one_key/utils/navigator_util.dart'; |
| 9 | import 'package:one_key/widgets/page_exception.dart'; | 11 | import 'package:one_key/widgets/page_exception.dart'; |
| @@ -28,11 +30,32 @@ class _CouponPageState extends State<CouponPage> { | @@ -28,11 +30,32 @@ class _CouponPageState extends State<CouponPage> { | ||
| 28 | CouponProvider couponProvider; | 30 | CouponProvider couponProvider; |
| 29 | 31 | ||
| 30 | ///获取优惠券列表数据 | 32 | ///获取优惠券列表数据 |
| 31 | - _couponNetworkData() { | ||
| 32 | - return Future.delayed(Duration(seconds: 1), () { | ||
| 33 | - couponProvider.pageState = PageState.Success; | ||
| 34 | - couponProvider.notifyListeners(); | ||
| 35 | - }); | 33 | + _couponNetworkData({bool isShowLoading = true}) async { |
| 34 | + Map<String, String> params = { | ||
| 35 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 36 | + // 'is_time': '0' | ||
| 37 | + }; | ||
| 38 | + await couponProvider.getCustomerActivity(context, params, | ||
| 39 | + isShowLoading: isShowLoading); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + ///修改活动信息 | ||
| 43 | + _setCustomerActivity(int index) async { | ||
| 44 | + Map<String, String> params = { | ||
| 45 | + "id": couponProvider.couponList[index].id, | ||
| 46 | + "status": couponProvider.couponList[index].isOpenBool ? '1' : '0' | ||
| 47 | + }; | ||
| 48 | + bool isSuccess = await couponProvider.setCustomerActivity(context, params, | ||
| 49 | + isShowLoading: false); | ||
| 50 | + print(isSuccess); | ||
| 51 | + _couponNetworkData(isShowLoading: false); | ||
| 52 | + // if (isSuccess) { | ||
| 53 | + // couponProvider.notifyListeners(); | ||
| 54 | + // } else { | ||
| 55 | + // couponProvider.couponList[index].isOpenBool = | ||
| 56 | + // !couponProvider.couponList[index].isOpenBool; | ||
| 57 | + // couponProvider.notifyListeners(); | ||
| 58 | + // } | ||
| 36 | } | 59 | } |
| 37 | 60 | ||
| 38 | @override | 61 | @override |
| @@ -42,6 +65,16 @@ class _CouponPageState extends State<CouponPage> { | @@ -42,6 +65,16 @@ class _CouponPageState extends State<CouponPage> { | ||
| 42 | WidgetsBinding.instance.addPostFrameCallback((_) { | 65 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 43 | _couponNetworkData(); | 66 | _couponNetworkData(); |
| 44 | }); | 67 | }); |
| 68 | + // bus.on("refresh_coupon_list", (arg) { | ||
| 69 | + // _couponNetworkData(); | ||
| 70 | + // }); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @override | ||
| 74 | + void dispose() { | ||
| 75 | + EventBus().emit('changeStatusColor'); | ||
| 76 | + // bus.off("refresh_coupon_list"); | ||
| 77 | + super.dispose(); | ||
| 45 | } | 78 | } |
| 46 | 79 | ||
| 47 | @override | 80 | @override |
| @@ -64,6 +97,7 @@ class _CouponPageState extends State<CouponPage> { | @@ -64,6 +97,7 @@ class _CouponPageState extends State<CouponPage> { | ||
| 64 | callback: () { | 97 | callback: () { |
| 65 | // offset = 0; | 98 | // offset = 0; |
| 66 | // getMessage(showLoading: true); | 99 | // getMessage(showLoading: true); |
| 100 | + _couponNetworkData(); | ||
| 67 | }, | 101 | }, |
| 68 | emptyMsg: "暂时没有列表信息哦", | 102 | emptyMsg: "暂时没有列表信息哦", |
| 69 | emptyImg: "empty_search", | 103 | emptyImg: "empty_search", |
| @@ -81,33 +115,46 @@ class _CouponPageState extends State<CouponPage> { | @@ -81,33 +115,46 @@ class _CouponPageState extends State<CouponPage> { | ||
| 81 | padding: | 115 | padding: |
| 82 | EdgeInsets.all(ScreenUtil().setWidth(20)), | 116 | EdgeInsets.all(ScreenUtil().setWidth(20)), |
| 83 | child: Text( | 117 | child: Text( |
| 84 | - '使用说明:回家啊喝点酒啊喝酒啊电话噶记得发快递费哈咖啡和大号发客服哈空腹喝酒啊快递费哈快递费哈看警方还会发卡号发快回复')); | 118 | + '使用说明:需在结账前出示优惠券二维码,店内工作人员微信扫码核销。超过有效期的券,会自动作废并移出列表。优惠券不可找零、兑现。', |
| 119 | + style: TextStyle( | ||
| 120 | + color: MyColours.color_333333, | ||
| 121 | + fontSize: ScreenUtil().setSp(28), | ||
| 122 | + ), | ||
| 123 | + strutStyle: StrutStyle( | ||
| 124 | + forceStrutHeight: true, | ||
| 125 | + height: 1, | ||
| 126 | + leading: 0.3), | ||
| 127 | + )); | ||
| 85 | }, childCount: 1), | 128 | }, childCount: 1), |
| 86 | ), | 129 | ), |
| 87 | SliverList( | 130 | SliverList( |
| 88 | delegate: SliverChildBuilderDelegate( | 131 | delegate: SliverChildBuilderDelegate( |
| 89 | (BuildContext context, int index) { | 132 | (BuildContext context, int index) { |
| 90 | return CouponItem( | 133 | return CouponItem( |
| 91 | - index: index, | ||
| 92 | - couponProvider: couponProvider, | 134 | + from: 'quan', |
| 135 | + couponSonModel: couponProvider.couponList[index], | ||
| 93 | showBtn: true, | 136 | showBtn: true, |
| 137 | + onPressedSwich: () { | ||
| 138 | + couponProvider.couponList[index].isOpenBool = | ||
| 139 | + !couponProvider.couponList[index].isOpenBool; | ||
| 140 | + _setCustomerActivity(index); | ||
| 141 | + }, | ||
| 94 | onPressed: () { | 142 | onPressed: () { |
| 95 | - couponProvider.swichStateData[index] = | ||
| 96 | - !couponProvider.swichStateData[index]; | ||
| 97 | - couponProvider.notifyListeners(); | 143 | + NavigatorUtil.goCouponDetailPage( |
| 144 | + context, couponProvider.couponList[index]); | ||
| 98 | }, | 145 | }, |
| 99 | ); | 146 | ); |
| 100 | - }, childCount: couponProvider.swichStateData.length), | 147 | + }, childCount: couponProvider.couponList.length), |
| 101 | ) | 148 | ) |
| 102 | ], | 149 | ], |
| 103 | - onRefresh: () async { | ||
| 104 | - // offset = 0; | ||
| 105 | - // getMessage(showLoading: false); | ||
| 106 | - }, | ||
| 107 | - onLoad: () async { | ||
| 108 | - // offset++; | ||
| 109 | - // getMessage(showLoading: false); | ||
| 110 | - }, | 150 | + // onRefresh: () async { |
| 151 | + // // offset = 0; | ||
| 152 | + // // getMessage(showLoading: false); | ||
| 153 | + // }, | ||
| 154 | + // onLoad: () async { | ||
| 155 | + // // offset++; | ||
| 156 | + // // getMessage(showLoading: false); | ||
| 157 | + // }, | ||
| 111 | ); | 158 | ); |
| 112 | } | 159 | } |
| 113 | }, | 160 | }, |
| @@ -123,7 +170,8 @@ class _CouponPageState extends State<CouponPage> { | @@ -123,7 +170,8 @@ class _CouponPageState extends State<CouponPage> { | ||
| 123 | print(needRefresh); | 170 | print(needRefresh); |
| 124 | if (needRefresh != null && needRefresh) { | 171 | if (needRefresh != null && needRefresh) { |
| 125 | //刷新页面数据 | 172 | //刷新页面数据 |
| 126 | - _controller.callRefresh(); | 173 | + // _controller.callRefresh(); |
| 174 | + _couponNetworkData(); | ||
| 127 | } | 175 | } |
| 128 | }, | 176 | }, |
| 129 | text: '创建新券', | 177 | text: '创建新券', |
| @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/screenutil.dart'; | @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/screenutil.dart'; | ||
| 4 | import 'package:one_key/constant/state.dart'; | 4 | import 'package:one_key/constant/state.dart'; |
| 5 | import 'package:one_key/pages/coupon/coupon_item.dart'; | 5 | import 'package:one_key/pages/coupon/coupon_item.dart'; |
| 6 | import 'package:one_key/provider/coupon_provider.dart'; | 6 | import 'package:one_key/provider/coupon_provider.dart'; |
| 7 | +import 'package:one_key/provider/user_model.dart'; | ||
| 7 | import 'package:one_key/res/colors.dart'; | 8 | import 'package:one_key/res/colors.dart'; |
| 8 | import 'package:one_key/utils/event_bus.dart'; | 9 | import 'package:one_key/utils/event_bus.dart'; |
| 9 | import 'package:one_key/utils/navigator_util.dart'; | 10 | import 'package:one_key/utils/navigator_util.dart'; |
| @@ -16,7 +17,9 @@ import 'package:one_key/widgets/v_empty_view.dart'; | @@ -16,7 +17,9 @@ import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 16 | import 'package:provider/provider.dart'; | 17 | import 'package:provider/provider.dart'; |
| 17 | 18 | ||
| 18 | class CouponSelectPage extends StatefulWidget { | 19 | class CouponSelectPage extends StatefulWidget { |
| 19 | - CouponSelectPage({Key key}) : super(key: key); | 20 | + final String rid; |
| 21 | + final bool hasModify; | ||
| 22 | + CouponSelectPage({Key key, this.rid, this.hasModify}) : super(key: key); | ||
| 20 | 23 | ||
| 21 | @override | 24 | @override |
| 22 | _CouponSelectPageState createState() => _CouponSelectPageState(); | 25 | _CouponSelectPageState createState() => _CouponSelectPageState(); |
| @@ -26,12 +29,17 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | @@ -26,12 +29,17 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | ||
| 26 | EasyRefreshController _controller = EasyRefreshController(); | 29 | EasyRefreshController _controller = EasyRefreshController(); |
| 27 | CouponProvider couponProvider; | 30 | CouponProvider couponProvider; |
| 28 | 31 | ||
| 29 | - ///获取优惠券列表数据 | ||
| 30 | - _couponNetworkData() { | ||
| 31 | - return Future.delayed(Duration(seconds: 1), () { | ||
| 32 | - couponProvider.pageStateSelect = PageState.Success; | ||
| 33 | - couponProvider.notifyListeners(); | ||
| 34 | - }); | 32 | + ///获取优惠券列表数据(status == 1) |
| 33 | + | ||
| 34 | + _couponNetworkData({bool isShowLoading = true}) async { | ||
| 35 | + Map<String, String> params = { | ||
| 36 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 37 | + }; | ||
| 38 | + if (!widget.hasModify) { | ||
| 39 | + params['status'] = '1'; | ||
| 40 | + } | ||
| 41 | + await couponProvider.getCustomerSelectActivity(context, params, | ||
| 42 | + isShowLoading: isShowLoading); | ||
| 35 | } | 43 | } |
| 36 | 44 | ||
| 37 | @override | 45 | @override |
| @@ -39,11 +47,21 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | @@ -39,11 +47,21 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | ||
| 39 | // TODO: implement initState | 47 | // TODO: implement initState |
| 40 | super.initState(); | 48 | super.initState(); |
| 41 | WidgetsBinding.instance.addPostFrameCallback((_) { | 49 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 50 | + // if (!couponProvider.hasModify) { | ||
| 42 | _couponNetworkData(); | 51 | _couponNetworkData(); |
| 52 | + // } else { | ||
| 53 | + // couponProvider.pageStateSelect = PageState.Success; | ||
| 54 | + // // couponProvider.notifyListeners(); | ||
| 55 | + // } | ||
| 43 | }); | 56 | }); |
| 44 | } | 57 | } |
| 45 | 58 | ||
| 46 | @override | 59 | @override |
| 60 | + void dispose() { | ||
| 61 | + super.dispose(); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @override | ||
| 47 | Widget build(BuildContext context) { | 65 | Widget build(BuildContext context) { |
| 48 | couponProvider = Provider.of<CouponProvider>(context, listen: true); | 66 | couponProvider = Provider.of<CouponProvider>(context, listen: true); |
| 49 | return Scaffold( | 67 | return Scaffold( |
| @@ -53,7 +71,12 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | @@ -53,7 +71,12 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | ||
| 53 | Navigator.pop(context); | 71 | Navigator.pop(context); |
| 54 | Utils.changeStatusColor(color: Colors.transparent); | 72 | Utils.changeStatusColor(color: Colors.transparent); |
| 55 | }, | 73 | }, |
| 56 | - rightImgName: couponProvider.checkValue ? '取消全选' : '全选', | 74 | + rightImgName: !widget.hasModify && |
| 75 | + couponProvider.pageStateSelect == PageState.Success | ||
| 76 | + ? couponProvider.checkValue | ||
| 77 | + ? '取消全选' | ||
| 78 | + : '全选' | ||
| 79 | + : '', | ||
| 57 | onTapRight: () { | 80 | onTapRight: () { |
| 58 | if (couponProvider.checkValue) { | 81 | if (couponProvider.checkValue) { |
| 59 | couponProvider.cancelAll(); | 82 | couponProvider.cancelAll(); |
| @@ -88,9 +111,11 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | @@ -88,9 +111,11 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | ||
| 88 | (BuildContext context, int index) { | 111 | (BuildContext context, int index) { |
| 89 | return InkWell( | 112 | return InkWell( |
| 90 | onTap: () { | 113 | onTap: () { |
| 91 | - couponProvider.listData[index]['checked'] = | ||
| 92 | - !couponProvider.listData[index]['checked']; | ||
| 93 | - if (couponProvider.listData[index]['checked']) { | 114 | + couponProvider.couponListSelect[index].isCheck = |
| 115 | + !couponProvider | ||
| 116 | + .couponListSelect[index].isCheck; | ||
| 117 | + if (couponProvider | ||
| 118 | + .couponListSelect[index].isCheck) { | ||
| 94 | couponProvider.addData(index); | 119 | couponProvider.addData(index); |
| 95 | } else { | 120 | } else { |
| 96 | couponProvider.cancelData(index); | 121 | couponProvider.cancelData(index); |
| @@ -100,24 +125,30 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | @@ -100,24 +125,30 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | ||
| 100 | child: Row( | 125 | child: Row( |
| 101 | children: [ | 126 | children: [ |
| 102 | HEmptyView(30), | 127 | HEmptyView(30), |
| 103 | - Checkbox( | ||
| 104 | - value: couponProvider.listData[index] | ||
| 105 | - ['checked'], | ||
| 106 | - checkColor: MyColours.color_ffffff, | ||
| 107 | - activeColor: MyColours.app_main, | ||
| 108 | - onChanged: (bool value) { | ||
| 109 | - couponProvider.listData[index]['checked'] = | ||
| 110 | - !couponProvider.listData[index] | ||
| 111 | - ['checked']; | ||
| 112 | - if (couponProvider.listData[index] | ||
| 113 | - ['checked']) { | ||
| 114 | - couponProvider.addData(index); | ||
| 115 | - } else { | ||
| 116 | - couponProvider.cancelData(index); | ||
| 117 | - } | ||
| 118 | - couponProvider.getCheckValue(); | ||
| 119 | - }, | ||
| 120 | - ), | 128 | + !widget.hasModify |
| 129 | + ? Checkbox( | ||
| 130 | + value: couponProvider | ||
| 131 | + .couponListSelect[index].isCheck, | ||
| 132 | + checkColor: MyColours.color_ffffff, | ||
| 133 | + activeColor: MyColours.app_main, | ||
| 134 | + onChanged: (bool value) { | ||
| 135 | + //改这里 ******8 | ||
| 136 | + couponProvider.couponListSelect[index] | ||
| 137 | + .isCheck = | ||
| 138 | + !couponProvider | ||
| 139 | + .couponListSelect[index] | ||
| 140 | + .isCheck; | ||
| 141 | + if (couponProvider | ||
| 142 | + .couponListSelect[index] | ||
| 143 | + .isCheck) { | ||
| 144 | + couponProvider.addData(index); | ||
| 145 | + } else { | ||
| 146 | + couponProvider.cancelData(index); | ||
| 147 | + } | ||
| 148 | + couponProvider.getCheckValue(); | ||
| 149 | + }, | ||
| 150 | + ) | ||
| 151 | + : Container(), | ||
| 121 | // Image.asset( | 152 | // Image.asset( |
| 122 | // couponProvider.listData[index]['checked'] | 153 | // couponProvider.listData[index]['checked'] |
| 123 | // ? 'assets/select.png' | 154 | // ? 'assets/select.png' |
| @@ -125,54 +156,47 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | @@ -125,54 +156,47 @@ class _CouponSelectPageState extends State<CouponSelectPage> { | ||
| 125 | // width: ScreenUtil().setWidth(44)), | 156 | // width: ScreenUtil().setWidth(44)), |
| 126 | Expanded( | 157 | Expanded( |
| 127 | child: CouponItem( | 158 | child: CouponItem( |
| 128 | - index: index, | ||
| 129 | - couponProvider: couponProvider, | ||
| 130 | - onPressed: () { | ||
| 131 | - couponProvider.listData[index]['checked'] = | ||
| 132 | - !couponProvider.listData[index] | ||
| 133 | - ['checked']; | ||
| 134 | - if (couponProvider.listData[index] | ||
| 135 | - ['checked']) { | ||
| 136 | - couponProvider.addData(index); | ||
| 137 | - } else { | ||
| 138 | - couponProvider.cancelData(index); | ||
| 139 | - } | ||
| 140 | - couponProvider.getCheckValue(); | ||
| 141 | - }, | 159 | + from: 'select', |
| 160 | + couponSonModel: | ||
| 161 | + couponProvider.couponListSelect[index], | ||
| 162 | + onPressed: () {}, | ||
| 142 | )) | 163 | )) |
| 143 | ], | 164 | ], |
| 144 | ), | 165 | ), |
| 145 | ); | 166 | ); |
| 146 | - }, childCount: couponProvider.listData.length), | 167 | + }, childCount: couponProvider.couponListSelect.length), |
| 147 | ) | 168 | ) |
| 148 | ], | 169 | ], |
| 149 | - onRefresh: () async { | ||
| 150 | - // offset = 0; | ||
| 151 | - // getMessage(showLoading: false); | ||
| 152 | - }, | ||
| 153 | - onLoad: () async { | ||
| 154 | - // offset++; | ||
| 155 | - // getMessage(showLoading: false); | ||
| 156 | - }, | 170 | + // onRefresh: () async { |
| 171 | + // // offset = 0; | ||
| 172 | + // // getMessage(showLoading: false); | ||
| 173 | + // }, | ||
| 174 | + // onLoad: () async { | ||
| 175 | + // // offset++; | ||
| 176 | + // // getMessage(showLoading: false); | ||
| 177 | + // }, | ||
| 157 | ); | 178 | ); |
| 158 | } | 179 | } |
| 159 | }, | 180 | }, |
| 160 | )), | 181 | )), |
| 161 | VEmptyView(20), | 182 | VEmptyView(20), |
| 162 | - Padding( | ||
| 163 | - padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0, | ||
| 164 | - ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), | ||
| 165 | - child: RoundButton( | ||
| 166 | - onPressed: () { | ||
| 167 | - Navigator.pop(context); | ||
| 168 | - }, | ||
| 169 | - text: '已选${couponProvider.coupons.length}个 确定', | ||
| 170 | - fontSize: 34, | ||
| 171 | - isBold: false, | ||
| 172 | - height: ScreenUtil().setWidth(80), | ||
| 173 | - width: double.infinity, | ||
| 174 | - radius: ScreenUtil().setWidth(10), | ||
| 175 | - )) | 183 | + !widget.hasModify && |
| 184 | + couponProvider.pageStateSelect == PageState.Success | ||
| 185 | + ? Padding( | ||
| 186 | + padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0, | ||
| 187 | + ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)), | ||
| 188 | + child: RoundButton( | ||
| 189 | + onPressed: () async { | ||
| 190 | + Navigator.pop(context); | ||
| 191 | + }, | ||
| 192 | + text: '已选${couponProvider.coupons.length}个 确定', | ||
| 193 | + fontSize: 34, | ||
| 194 | + isBold: false, | ||
| 195 | + height: ScreenUtil().setWidth(80), | ||
| 196 | + width: double.infinity, | ||
| 197 | + radius: ScreenUtil().setWidth(10), | ||
| 198 | + )) | ||
| 199 | + : Container() | ||
| 176 | ], | 200 | ], |
| 177 | ), | 201 | ), |
| 178 | onWillPop: () async { | 202 | onWillPop: () async { |
| @@ -31,12 +31,16 @@ class InvicationPageState extends State<InvicationPage> { | @@ -31,12 +31,16 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 31 | DateTime dateTime; | 31 | DateTime dateTime; |
| 32 | String dateTimeStr = ""; | 32 | String dateTimeStr = ""; |
| 33 | ScrollController controller = ScrollController(); | 33 | ScrollController controller = ScrollController(); |
| 34 | - final double couponHeight = 180.0; | 34 | + double couponHeight = 180.0; |
| 35 | CouponProvider couponProvider; | 35 | CouponProvider couponProvider; |
| 36 | 36 | ||
| 37 | @override | 37 | @override |
| 38 | void initState() { | 38 | void initState() { |
| 39 | super.initState(); | 39 | super.initState(); |
| 40 | + | ||
| 41 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 42 | + _getActivityByRid(); | ||
| 43 | + }); | ||
| 40 | Utils.changeStatusColor(color: Colors.transparent); | 44 | Utils.changeStatusColor(color: Colors.transparent); |
| 41 | dateTime = | 45 | dateTime = |
| 42 | DateTime.fromMillisecondsSinceEpoch(int.parse(widget.ddate) * 1000); | 46 | DateTime.fromMillisecondsSinceEpoch(int.parse(widget.ddate) * 1000); |
| @@ -45,9 +49,51 @@ class InvicationPageState extends State<InvicationPage> { | @@ -45,9 +49,51 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 45 | "${dateTime.year}/${Utils.addZeroNumber(dateTime.month)}/${Utils.addZeroNumber(dateTime.day)} 星期${Utils.formatWeekDayNum(dateTime.weekday)} ${widget.ddateStr}"; | 49 | "${dateTime.year}/${Utils.addZeroNumber(dateTime.month)}/${Utils.addZeroNumber(dateTime.day)} 星期${Utils.formatWeekDayNum(dateTime.weekday)} ${widget.ddateStr}"; |
| 46 | } | 50 | } |
| 47 | 51 | ||
| 52 | + _getActivityByRid() async { | ||
| 53 | + Map<String, String> params = { | ||
| 54 | + "rid": widget.rid, | ||
| 55 | + }; | ||
| 56 | + await couponProvider.getActivityByRid(context, params, isShowLoading: true); | ||
| 57 | + //flase默认5个 true 不默认5个 | ||
| 58 | + if (!couponProvider.hasModify) { | ||
| 59 | + //没有绑定的券,默认给5个,获取优惠券列表 | ||
| 60 | + _couponNetworkData(isShowLoading: true); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + ///消费券默认5张 | ||
| 65 | + _couponNetworkData({bool isShowLoading = true}) async { | ||
| 66 | + Map<String, String> params = { | ||
| 67 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 68 | + 'status': '1' | ||
| 69 | + }; | ||
| 70 | + await couponProvider.getCustomerSelectActivity(context, params, | ||
| 71 | + isShowLoading: isShowLoading); | ||
| 72 | + //此人已经新建好券 | ||
| 73 | + if (couponProvider.couponListSelect.length > 0) { | ||
| 74 | + couponProvider.initCouponSelect(context); | ||
| 75 | + | ||
| 76 | + if (couponProvider.coupons.length == 0) { | ||
| 77 | + setState(() { | ||
| 78 | + couponHeight = 0; | ||
| 79 | + }); | ||
| 80 | + } else { | ||
| 81 | + setState(() { | ||
| 82 | + couponHeight = 180.0; | ||
| 83 | + }); | ||
| 84 | + } | ||
| 85 | + } else { | ||
| 86 | + //没有新建的优惠券 | ||
| 87 | + setState(() { | ||
| 88 | + couponHeight = 0; | ||
| 89 | + }); | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + | ||
| 48 | @override | 93 | @override |
| 49 | void dispose() { | 94 | void dispose() { |
| 50 | Utils.changeStatusColor(); | 95 | Utils.changeStatusColor(); |
| 96 | + couponProvider.clearSelect(); | ||
| 51 | super.dispose(); | 97 | super.dispose(); |
| 52 | } | 98 | } |
| 53 | 99 | ||
| @@ -239,8 +285,34 @@ class InvicationPageState extends State<InvicationPage> { | @@ -239,8 +285,34 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 239 | ), | 285 | ), |
| 240 | Expanded( | 286 | Expanded( |
| 241 | child: GestureDetector( | 287 | child: GestureDetector( |
| 242 | - onTap: () { | ||
| 243 | - Utils.goShareInvicationToWeChat(widget.rid); | 288 | + onTap: () async { |
| 289 | + if (!couponProvider.hasModify && | ||
| 290 | + couponProvider.coupons.length > 0) { | ||
| 291 | + Map<String, String> params = { | ||
| 292 | + "rid": widget.rid, | ||
| 293 | + "aid": Utils.listToStringEnglish( | ||
| 294 | + couponProvider.coupons) | ||
| 295 | + }; | ||
| 296 | + bool isSuc = await couponProvider | ||
| 297 | + .setActivityAsReserve(context, params); | ||
| 298 | + if (isSuc) { | ||
| 299 | + couponProvider.hasModify = true; | ||
| 300 | + bool isSuccess = | ||
| 301 | + await Utils.goShareInvicationToWeChat( | ||
| 302 | + widget.rid); | ||
| 303 | + print(isSuccess); | ||
| 304 | + // couponProvider.couponsShow = []; | ||
| 305 | + // couponProvider.couponsShow | ||
| 306 | + // .addAll(couponProvider.coupons); | ||
| 307 | + // couponProvider.coupons = []; | ||
| 308 | + // couponProvider.notifyListeners(); | ||
| 309 | + } | ||
| 310 | + } else { | ||
| 311 | + bool isSuccess = | ||
| 312 | + await Utils.goShareInvicationToWeChat( | ||
| 313 | + widget.rid); | ||
| 314 | + print(isSuccess); | ||
| 315 | + } | ||
| 244 | }, | 316 | }, |
| 245 | child: Container( | 317 | child: Container( |
| 246 | width: double.infinity, | 318 | width: double.infinity, |
| @@ -288,32 +360,38 @@ class InvicationPageState extends State<InvicationPage> { | @@ -288,32 +360,38 @@ class InvicationPageState extends State<InvicationPage> { | ||
| 288 | left: ScreenUtil().setWidth(180), | 360 | left: ScreenUtil().setWidth(180), |
| 289 | bottom: ScreenUtil().setWidth(130), | 361 | bottom: ScreenUtil().setWidth(130), |
| 290 | right: ScreenUtil().setWidth(180), | 362 | right: ScreenUtil().setWidth(180), |
| 291 | - child: GestureDetector( | ||
| 292 | - onTap: () { | ||
| 293 | - NavigatorUtil.goCouponSelectPage(context); | ||
| 294 | - }, | ||
| 295 | - behavior: HitTestBehavior.opaque, | ||
| 296 | - child: Center( | ||
| 297 | - child: Container( | ||
| 298 | - // width: ScreenUtil().setWidth(400), | ||
| 299 | - padding: EdgeInsets.symmetric( | ||
| 300 | - horizontal: ScreenUtil().setWidth(40), | ||
| 301 | - vertical: ScreenUtil().setWidth(20)), | ||
| 302 | - // height: ScreenUtil().setWidth(100), | ||
| 303 | - decoration: BoxDecoration( | ||
| 304 | - color: MyColours.color_ffffff, | ||
| 305 | - borderRadius: BorderRadius.circular( | ||
| 306 | - ScreenUtil().setWidth(20))), | ||
| 307 | - child: Text( | ||
| 308 | - '共赠送${couponProvider.coupons.length}张优惠券\n点击查看', | ||
| 309 | - textAlign: TextAlign.center, | ||
| 310 | - style: TextStyle( | ||
| 311 | - fontSize: ScreenUtil().setSp(28), | 363 | + child: couponProvider.hasModify || |
| 364 | + couponProvider.coupons.length > 0 || | ||
| 365 | + couponProvider.couponListSelect.length > 0 | ||
| 366 | + ? GestureDetector( | ||
| 367 | + onTap: () async { | ||
| 368 | + NavigatorUtil.goCouponSelectPage(context, | ||
| 369 | + rid: widget.rid, | ||
| 370 | + hasModify: couponProvider.hasModify); | ||
| 371 | + }, | ||
| 372 | + behavior: HitTestBehavior.opaque, | ||
| 373 | + child: Center( | ||
| 374 | + child: Container( | ||
| 375 | + // width: ScreenUtil().setWidth(400), | ||
| 376 | + padding: EdgeInsets.symmetric( | ||
| 377 | + horizontal: ScreenUtil().setWidth(40), | ||
| 378 | + vertical: ScreenUtil().setWidth(20)), | ||
| 379 | + // height: ScreenUtil().setWidth(100), | ||
| 380 | + decoration: BoxDecoration( | ||
| 381 | + color: MyColours.color_ffffff, | ||
| 382 | + borderRadius: BorderRadius.circular( | ||
| 383 | + ScreenUtil().setWidth(20))), | ||
| 384 | + child: Text( | ||
| 385 | + '共赠送${couponProvider.coupons.length}张优惠券\n点击查看', | ||
| 386 | + textAlign: TextAlign.center, | ||
| 387 | + style: TextStyle( | ||
| 388 | + fontSize: ScreenUtil().setSp(28), | ||
| 389 | + ), | ||
| 390 | + ), | ||
| 391 | + ), | ||
| 312 | ), | 392 | ), |
| 313 | - ), | ||
| 314 | - ), | ||
| 315 | - ), | ||
| 316 | - ), | 393 | + ) |
| 394 | + : Container(), | ||
| 317 | ) | 395 | ) |
| 318 | ], | 396 | ], |
| 319 | )))); | 397 | )))); |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | +import 'package:one_key/constant/constant.dart'; | ||
| 3 | +import 'package:one_key/constant/error.dart'; | ||
| 2 | import 'package:one_key/constant/state.dart'; | 4 | import 'package:one_key/constant/state.dart'; |
| 5 | +import 'package:one_key/models/coupon_model.dart'; | ||
| 6 | +import 'package:one_key/net/dio_util.dart'; | ||
| 7 | +import 'package:one_key/net/http_url.dart'; | ||
| 8 | +import 'package:one_key/net/base_resp.dart'; | ||
| 9 | +import 'package:one_key/provider/user_model.dart'; | ||
| 10 | +import 'package:one_key/utils/utils.dart'; | ||
| 11 | +import 'package:provider/provider.dart'; | ||
| 3 | 12 | ||
| 4 | class CouponProvider with ChangeNotifier { | 13 | class CouponProvider with ChangeNotifier { |
| 5 | List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 | 14 | List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 |
| 6 | PageState pageState = PageState.Loading; | 15 | PageState pageState = PageState.Loading; |
| 7 | PageState pageStateHistory = PageState.Loading; | 16 | PageState pageStateHistory = PageState.Loading; |
| 8 | PageState pageStateSelect = PageState.Loading; | 17 | PageState pageStateSelect = PageState.Loading; |
| 18 | + bool hasModify = false; | ||
| 9 | 19 | ||
| 10 | bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true | 20 | bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true |
| 11 | - List<Map<String, dynamic>> listData = []; //优惠券页面数据 | ||
| 12 | - List coupons = []; //选中的优惠券id集合 | 21 | + // List<Map<String, dynamic>> listData = []; //优惠券页面数据 |
| 22 | + List<String> coupons = []; //选中的优惠券id集合 | ||
| 23 | + // List<String> couponsShow = []; //邀请函显示数量 选中的优惠券id集合 | ||
| 24 | + | ||
| 25 | + List<CouponSunModel> couponListHistory = []; //优惠券历史列表 | ||
| 26 | + List<CouponSunModel> couponList = []; //优惠券列表 | ||
| 27 | + List<CouponSunModel> couponListSelect = []; //优惠券选择列表 | ||
| 13 | 28 | ||
| 14 | CouponProvider() { | 29 | CouponProvider() { |
| 15 | - for (int i = 0; i < 20; i++) { | ||
| 16 | - swichStateData.add(true); | ||
| 17 | - listData.add({'checked': true, 'id': '${i}'}); | ||
| 18 | - } | 30 | + // for (int i = 0; i < 20; i++) { |
| 31 | + // swichStateData.add(true); | ||
| 32 | + // listData.add({'checked': true, 'id': '${i}'}); | ||
| 33 | + // } | ||
| 19 | } | 34 | } |
| 20 | 35 | ||
| 21 | //全选按钮执行“全选” | 36 | //全选按钮执行“全选” |
| 22 | addAll() async { | 37 | addAll() async { |
| 23 | //把数据状态全部改成true,即选中状态 | 38 | //把数据状态全部改成true,即选中状态 |
| 24 | coupons = []; | 39 | coupons = []; |
| 25 | - for (var i = 0; i < listData.length; i++) { | ||
| 26 | - listData[i]['checked'] = true; | ||
| 27 | - coupons.add(listData[i]['id']); | 40 | + for (var i = 0; i < couponListSelect.length; i++) { |
| 41 | + couponListSelect[i].isCheck = true; | ||
| 42 | + coupons.add(couponListSelect[i].id); | ||
| 28 | } | 43 | } |
| 29 | checkValue = true; | 44 | checkValue = true; |
| 30 | notifyListeners(); | 45 | notifyListeners(); |
| 31 | } | 46 | } |
| 32 | 47 | ||
| 48 | + ///清楚选择 | ||
| 49 | + clearSelect() { | ||
| 50 | + coupons = []; | ||
| 51 | + // couponsShow = []; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + //默认选择前5个 | ||
| 55 | + initCouponSelect(BuildContext context) { | ||
| 56 | + coupons = []; | ||
| 57 | + // couponsShow = []; | ||
| 58 | + for (var i = 0; i < couponListSelect.length; i++) { | ||
| 59 | + if (i < 5) { | ||
| 60 | + couponListSelect[i].isCheck = true; | ||
| 61 | + coupons.add(couponListSelect[i].id); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + // couponsShow.addAll(coupons); | ||
| 65 | + // coupons = []; | ||
| 66 | + notifyListeners(); | ||
| 67 | + } | ||
| 68 | + | ||
| 33 | //全选按钮执行“全不选” | 69 | //全选按钮执行“全不选” |
| 34 | cancelAll() async { | 70 | cancelAll() async { |
| 35 | //把数据状态全部改成false,即不选中状态 | 71 | //把数据状态全部改成false,即不选中状态 |
| 36 | - for (var i = 0; i < listData.length; i++) { | ||
| 37 | - listData[i]['checked'] = false; | 72 | + for (var i = 0; i < couponListSelect.length; i++) { |
| 73 | + couponListSelect[i].isCheck = false; | ||
| 38 | } | 74 | } |
| 39 | coupons = []; | 75 | coupons = []; |
| 40 | checkValue = false; | 76 | checkValue = false; |
| @@ -43,22 +79,22 @@ class CouponProvider with ChangeNotifier { | @@ -43,22 +79,22 @@ class CouponProvider with ChangeNotifier { | ||
| 43 | 79 | ||
| 44 | //选中 | 80 | //选中 |
| 45 | addData(int index) { | 81 | addData(int index) { |
| 46 | - listData[index]['checked'] = true; | ||
| 47 | - coupons.add(listData[index]['id']); | 82 | + couponListSelect[index].isCheck = true; |
| 83 | + coupons.add(couponListSelect[index].id); | ||
| 48 | notifyListeners(); | 84 | notifyListeners(); |
| 49 | } | 85 | } |
| 50 | 86 | ||
| 51 | //未选中 | 87 | //未选中 |
| 52 | cancelData(int index) { | 88 | cancelData(int index) { |
| 53 | - listData[index]['checked'] = false; | ||
| 54 | - coupons.removeWhere((element) => element == listData[index]['id']); | 89 | + couponListSelect[index].isCheck = false; |
| 90 | + coupons.removeWhere((element) => element == couponListSelect[index].id); | ||
| 55 | notifyListeners(); | 91 | notifyListeners(); |
| 56 | } | 92 | } |
| 57 | 93 | ||
| 58 | //获取全选按钮的状态 true or false | 94 | //获取全选按钮的状态 true or false |
| 59 | getCheckValue() { | 95 | getCheckValue() { |
| 60 | - bool temp = listData.any((value) { | ||
| 61 | - return value['checked'] == false; | 96 | + bool temp = couponListSelect.any((value) { |
| 97 | + return value.isCheck == false; | ||
| 62 | }); | 98 | }); |
| 63 | if (temp == true) { | 99 | if (temp == true) { |
| 64 | checkValue = false; | 100 | checkValue = false; |
| @@ -67,4 +103,292 @@ class CouponProvider with ChangeNotifier { | @@ -67,4 +103,292 @@ class CouponProvider with ChangeNotifier { | ||
| 67 | } | 103 | } |
| 68 | notifyListeners(); | 104 | notifyListeners(); |
| 69 | } | 105 | } |
| 106 | + | ||
| 107 | + ///客户经理创建活动 | ||
| 108 | + Future<dynamic> createCustomerActivity( | ||
| 109 | + BuildContext context, Map<String, String> params, | ||
| 110 | + {isShowLoading = true}) async { | ||
| 111 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 112 | + .request<dynamic>(context, Method.get, HttpUrl.create_customer_activity, | ||
| 113 | + data: params, showLoading: isShowLoading) | ||
| 114 | + .catchError((error) { | ||
| 115 | + print(error.toString()); | ||
| 116 | + if (error is MyError) { | ||
| 117 | + // switch (error.type) { | ||
| 118 | + // case 1: | ||
| 119 | + // pageState = PageState.ConnectivityError; | ||
| 120 | + // break; | ||
| 121 | + // case 2: | ||
| 122 | + // pageState = PageState.ConnectivityTimeOut; | ||
| 123 | + // break; | ||
| 124 | + // default: | ||
| 125 | + // pageState = PageState.ConnectivityError; | ||
| 126 | + // break; | ||
| 127 | + // } | ||
| 128 | + } | ||
| 129 | + // notifyListeners(); | ||
| 130 | + return false; | ||
| 131 | + }); | ||
| 132 | + if (baseResp.code == Constant.status_success) { | ||
| 133 | + if (baseResp.data.isEmpty) { | ||
| 134 | + // pageState = PageState.ConnectivityError; | ||
| 135 | + return false; | ||
| 136 | + } else { | ||
| 137 | + // pageState = PageState.Success; | ||
| 138 | + return true; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + // notifyListeners(); | ||
| 142 | + // return NotebookDetail.fromJson(baseResp.data); | ||
| 143 | + } else { | ||
| 144 | + // pageState = PageState.ConnectivityError; | ||
| 145 | + if (baseResp != null) { | ||
| 146 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 147 | + } | ||
| 148 | + return false; | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + ///客户经理获取所创建活动列表 | ||
| 153 | + Future<List<CouponSunModel>> getCustomerActivity( | ||
| 154 | + BuildContext context, Map<String, String> params, | ||
| 155 | + {isShowLoading = true}) async { | ||
| 156 | + if (isShowLoading) { | ||
| 157 | + pageState = PageState.Loading; | ||
| 158 | + notifyListeners(); | ||
| 159 | + } | ||
| 160 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 161 | + .request<dynamic>(context, Method.get, HttpUrl.get_customer_activity, | ||
| 162 | + data: params, showLoading: false) | ||
| 163 | + .catchError((error) { | ||
| 164 | + print(error.toString()); | ||
| 165 | + if (error is MyError) { | ||
| 166 | + switch (error.type) { | ||
| 167 | + case 1: | ||
| 168 | + pageState = PageState.ConnectivityError; | ||
| 169 | + break; | ||
| 170 | + case 2: | ||
| 171 | + pageState = PageState.ConnectivityTimeOut; | ||
| 172 | + break; | ||
| 173 | + default: | ||
| 174 | + pageState = PageState.ConnectivityError; | ||
| 175 | + break; | ||
| 176 | + } | ||
| 177 | + } | ||
| 178 | + notifyListeners(); | ||
| 179 | + }); | ||
| 180 | + if (baseResp.code == Constant.status_success) { | ||
| 181 | + if (baseResp.data.isEmpty) { | ||
| 182 | + pageState = PageState.Empty; | ||
| 183 | + } else { | ||
| 184 | + pageState = PageState.Success; | ||
| 185 | + } | ||
| 186 | + couponList = CouponModel.fromJson(baseResp.responseData).data; | ||
| 187 | + notifyListeners(); | ||
| 188 | + } else { | ||
| 189 | + pageState = PageState.ConnectivityError; | ||
| 190 | + if (baseResp != null) { | ||
| 191 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + return couponList; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + ///客户经理获取所创建活动列表 | ||
| 198 | + Future<List<CouponSunModel>> getCustomerHistoryActivity( | ||
| 199 | + BuildContext context, Map<String, String> params, | ||
| 200 | + {isShowLoading = true}) async { | ||
| 201 | + if (isShowLoading) { | ||
| 202 | + pageStateHistory = PageState.Loading; | ||
| 203 | + notifyListeners(); | ||
| 204 | + } | ||
| 205 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 206 | + .request<dynamic>(context, Method.get, HttpUrl.get_customer_activity, | ||
| 207 | + data: params, showLoading: false) | ||
| 208 | + .catchError((error) { | ||
| 209 | + print(error.toString()); | ||
| 210 | + if (error is MyError) { | ||
| 211 | + switch (error.type) { | ||
| 212 | + case 1: | ||
| 213 | + pageStateHistory = PageState.ConnectivityError; | ||
| 214 | + break; | ||
| 215 | + case 2: | ||
| 216 | + pageStateHistory = PageState.ConnectivityTimeOut; | ||
| 217 | + break; | ||
| 218 | + default: | ||
| 219 | + pageStateHistory = PageState.ConnectivityError; | ||
| 220 | + break; | ||
| 221 | + } | ||
| 222 | + } | ||
| 223 | + notifyListeners(); | ||
| 224 | + }); | ||
| 225 | + if (baseResp.code == Constant.status_success) { | ||
| 226 | + if (baseResp.data.isEmpty) { | ||
| 227 | + pageStateHistory = PageState.Empty; | ||
| 228 | + } else { | ||
| 229 | + pageStateHistory = PageState.Success; | ||
| 230 | + } | ||
| 231 | + couponListHistory = CouponModel.fromJson(baseResp.responseData).data; | ||
| 232 | + notifyListeners(); | ||
| 233 | + } else { | ||
| 234 | + pageStateHistory = PageState.ConnectivityError; | ||
| 235 | + if (baseResp != null) { | ||
| 236 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + return couponListHistory; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + ///客户经理获取所创建活动列表(选择优惠券) | ||
| 243 | + Future<List<CouponSunModel>> getCustomerSelectActivity( | ||
| 244 | + BuildContext context, Map<String, String> params, | ||
| 245 | + {isShowLoading = true}) async { | ||
| 246 | + if (isShowLoading) { | ||
| 247 | + pageStateSelect = PageState.Loading; | ||
| 248 | + notifyListeners(); | ||
| 249 | + } | ||
| 250 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 251 | + .request<dynamic>(context, Method.get, HttpUrl.get_customer_activity, | ||
| 252 | + data: params, showLoading: false) | ||
| 253 | + .catchError((error) { | ||
| 254 | + print(error.toString()); | ||
| 255 | + if (error is MyError) { | ||
| 256 | + switch (error.type) { | ||
| 257 | + case 1: | ||
| 258 | + pageStateSelect = PageState.ConnectivityError; | ||
| 259 | + break; | ||
| 260 | + case 2: | ||
| 261 | + pageStateSelect = PageState.ConnectivityTimeOut; | ||
| 262 | + break; | ||
| 263 | + default: | ||
| 264 | + pageStateSelect = PageState.ConnectivityError; | ||
| 265 | + break; | ||
| 266 | + } | ||
| 267 | + } | ||
| 268 | + notifyListeners(); | ||
| 269 | + }); | ||
| 270 | + if (baseResp.code == Constant.status_success) { | ||
| 271 | + if (baseResp.data.isEmpty) { | ||
| 272 | + pageStateSelect = PageState.Empty; | ||
| 273 | + } else { | ||
| 274 | + pageStateSelect = PageState.Success; | ||
| 275 | + } | ||
| 276 | + couponListSelect = CouponModel.fromJson(baseResp.responseData).data; | ||
| 277 | + if (hasModify) { | ||
| 278 | + //已经绑定 | ||
| 279 | + List<CouponSunModel> temp = []; | ||
| 280 | + for (int i = 0; i < couponListSelect.length; i++) { | ||
| 281 | + for (int j = 0; j < coupons.length; j++) { | ||
| 282 | + if (couponListSelect[i].id == coupons[j]) { | ||
| 283 | + temp.add(couponListSelect[i]); | ||
| 284 | + } | ||
| 285 | + } | ||
| 286 | + } | ||
| 287 | + couponListSelect = temp; | ||
| 288 | + } else { | ||
| 289 | + for (int i = 0; i < couponListSelect.length; i++) { | ||
| 290 | + for (int j = 0; j < coupons.length; j++) { | ||
| 291 | + if (couponListSelect[i].id == coupons[j]) { | ||
| 292 | + couponListSelect[i].isCheck = true; | ||
| 293 | + } | ||
| 294 | + } | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + getCheckValue(); | ||
| 299 | + notifyListeners(); | ||
| 300 | + } else { | ||
| 301 | + pageStateSelect = PageState.ConnectivityError; | ||
| 302 | + if (baseResp != null) { | ||
| 303 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 304 | + } | ||
| 305 | + } | ||
| 306 | + return couponListSelect; | ||
| 307 | + } | ||
| 308 | + | ||
| 309 | + ///客户经理修改活动 | ||
| 310 | + Future<dynamic> setCustomerActivity( | ||
| 311 | + BuildContext context, Map<String, String> params, | ||
| 312 | + {isShowLoading = true}) async { | ||
| 313 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 314 | + .request<dynamic>(context, Method.get, HttpUrl.set_customer_activity, | ||
| 315 | + data: params, showLoading: isShowLoading) | ||
| 316 | + .catchError((error) { | ||
| 317 | + print(error.toString()); | ||
| 318 | + if (error is MyError) {} | ||
| 319 | + return false; | ||
| 320 | + }); | ||
| 321 | + if (baseResp.code == Constant.status_success) { | ||
| 322 | + if (int.parse(baseResp.data.toString()) == 1) { | ||
| 323 | + return true; | ||
| 324 | + } else { | ||
| 325 | + // Utils.showToast(baseResp.msg ?? "修改失败"); | ||
| 326 | + return false; | ||
| 327 | + } | ||
| 328 | + } else { | ||
| 329 | + if (baseResp != null) { | ||
| 330 | + // Utils.showToast(baseResp.msg ?? ""); | ||
| 331 | + } | ||
| 332 | + return false; | ||
| 333 | + } | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + ///设置预定绑定活动ID | ||
| 337 | + Future<dynamic> setActivityAsReserve( | ||
| 338 | + BuildContext context, Map<String, String> params, | ||
| 339 | + {isShowLoading = true}) async { | ||
| 340 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 341 | + .request<dynamic>(context, Method.get, HttpUrl.set_activity_as_reserve, | ||
| 342 | + data: params, showLoading: isShowLoading) | ||
| 343 | + .catchError((error) { | ||
| 344 | + print(error.toString()); | ||
| 345 | + if (error is MyError) {} | ||
| 346 | + return false; | ||
| 347 | + }); | ||
| 348 | + if (baseResp.code == Constant.status_success) { | ||
| 349 | + if (baseResp.data != null) { | ||
| 350 | + // coupons = baseResp.data['aid'].split(''); | ||
| 351 | + return true; | ||
| 352 | + } else { | ||
| 353 | + // Utils.showToast(baseResp.msg ?? "修改失败"); | ||
| 354 | + return false; | ||
| 355 | + } | ||
| 356 | + } else { | ||
| 357 | + if (baseResp != null) { | ||
| 358 | + // Utils.showToast(baseResp.msg ?? ""); | ||
| 359 | + } | ||
| 360 | + return false; | ||
| 361 | + } | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + ///获取预定绑定活动 | ||
| 365 | + Future<bool> getActivityByRid( | ||
| 366 | + BuildContext context, Map<String, String> params, | ||
| 367 | + {isShowLoading = true}) async { | ||
| 368 | + BaseResp<dynamic> baseResp = await DioUtil() | ||
| 369 | + .request<dynamic>(context, Method.get, HttpUrl.get_activity_by_rid, | ||
| 370 | + data: params, showLoading: isShowLoading) | ||
| 371 | + .catchError((error) { | ||
| 372 | + print(error.toString()); | ||
| 373 | + if (error is MyError) {} | ||
| 374 | + }); | ||
| 375 | + if (baseResp.code == Constant.status_success) { | ||
| 376 | + if (baseResp.data == null) { | ||
| 377 | + hasModify = false; | ||
| 378 | + } else { | ||
| 379 | + couponListSelect = CouponModel.fromJson(baseResp.responseData).data; | ||
| 380 | + for (int i = 0; i < couponListSelect.length; i++) { | ||
| 381 | + coupons.add(couponListSelect[i].id); | ||
| 382 | + // couponsShow.add(couponTemp[i].id); | ||
| 383 | + } | ||
| 384 | + hasModify = true; | ||
| 385 | + notifyListeners(); | ||
| 386 | + } | ||
| 387 | + } else { | ||
| 388 | + if (baseResp != null) { | ||
| 389 | + Utils.showToast(baseResp.msg ?? ""); | ||
| 390 | + } | ||
| 391 | + return false; | ||
| 392 | + } | ||
| 393 | + } | ||
| 70 | } | 394 | } |
| @@ -46,7 +46,7 @@ class NotebookDetailModel extends ChangeNotifier { | @@ -46,7 +46,7 @@ class NotebookDetailModel extends ChangeNotifier { | ||
| 46 | }); | 46 | }); |
| 47 | if (baseResp.code == Constant.status_success) { | 47 | if (baseResp.code == Constant.status_success) { |
| 48 | if (baseResp.data.isEmpty) { | 48 | if (baseResp.data.isEmpty) { |
| 49 | - pageState = PageState.ConnectivityError; | 49 | + pageState = PageState.Empty; |
| 50 | } else { | 50 | } else { |
| 51 | pageState = PageState.Success; | 51 | pageState = PageState.Success; |
| 52 | } | 52 | } |
| @@ -47,7 +47,7 @@ class OrderFoodProvider extends ChangeNotifier { | @@ -47,7 +47,7 @@ class OrderFoodProvider extends ChangeNotifier { | ||
| 47 | }); | 47 | }); |
| 48 | if (baseResp.code == Constant.status_success) { | 48 | if (baseResp.code == Constant.status_success) { |
| 49 | if (baseResp.data.isEmpty) { | 49 | if (baseResp.data.isEmpty) { |
| 50 | - pageState = PageState.ConnectivityError; | 50 | + pageState = PageState.Empty; |
| 51 | } else { | 51 | } else { |
| 52 | pageState = PageState.Success; | 52 | pageState = PageState.Success; |
| 53 | createdOrderSunModel = | 53 | createdOrderSunModel = |
| @@ -2,9 +2,11 @@ import 'dart:convert'; | @@ -2,9 +2,11 @@ import 'dart:convert'; | ||
| 2 | 2 | ||
| 3 | import 'package:fluro/fluro.dart'; | 3 | import 'package:fluro/fluro.dart'; |
| 4 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 5 | +import 'package:one_key/models/coupon_model.dart'; | ||
| 5 | import 'package:one_key/models/notebook.dart'; | 6 | import 'package:one_key/models/notebook.dart'; |
| 6 | import 'package:one_key/models/notebook_detail.dart'; | 7 | import 'package:one_key/models/notebook_detail.dart'; |
| 7 | import 'package:one_key/models/table_list.dart'; | 8 | import 'package:one_key/models/table_list.dart'; |
| 9 | +import 'package:one_key/pages/coupon/coupon_detail_page.dart'; | ||
| 8 | import 'package:one_key/pages/coupon/coupon_edit_page.dart'; | 10 | import 'package:one_key/pages/coupon/coupon_edit_page.dart'; |
| 9 | import 'package:one_key/pages/coupon/coupon_history_page.dart'; | 11 | import 'package:one_key/pages/coupon/coupon_history_page.dart'; |
| 10 | import 'package:one_key/pages/coupon/coupon_page.dart'; | 12 | import 'package:one_key/pages/coupon/coupon_page.dart'; |
| @@ -244,7 +246,16 @@ var handleCouponEditPageHandler = new Handler( | @@ -244,7 +246,16 @@ var handleCouponEditPageHandler = new Handler( | ||
| 244 | ///选择优惠券 | 246 | ///选择优惠券 |
| 245 | var handleCouponSelectPageHandler = new Handler( | 247 | var handleCouponSelectPageHandler = new Handler( |
| 246 | handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | 248 | handlerFunc: (BuildContext context, Map<String, List<Object>> params) { |
| 247 | - // String rid = params["rid"].first; | ||
| 248 | - // bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first); | ||
| 249 | - return CouponSelectPage(); | 249 | + String rid = params["rid"].first; |
| 250 | + bool hasModify = FluroConvertUtils.string2bool(params["hasModify"].first); | ||
| 251 | + return CouponSelectPage(rid: rid,hasModify:hasModify); | ||
| 252 | +}); | ||
| 253 | + | ||
| 254 | +///优惠券详情页 | ||
| 255 | +var handleCouponDetailPageHandler = new Handler( | ||
| 256 | + handlerFunc: (BuildContext context, Map<String, List<Object>> params) { | ||
| 257 | + CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode( | ||
| 258 | + FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first))); | ||
| 259 | + | ||
| 260 | + return CouponDetailPage(couponSunModel: couponSunModel); | ||
| 250 | }); | 261 | }); |
| @@ -26,6 +26,7 @@ class Routes { | @@ -26,6 +26,7 @@ class Routes { | ||
| 26 | static String coupon_history = "/coupon_history"; //优惠券历史列表页 | 26 | static String coupon_history = "/coupon_history"; //优惠券历史列表页 |
| 27 | static String coupon_edit = "/coupon_edit"; //创建优惠券 | 27 | static String coupon_edit = "/coupon_edit"; //创建优惠券 |
| 28 | static String coupon_select = "/coupon_select"; //优惠券选择 | 28 | static String coupon_select = "/coupon_select"; //优惠券选择 |
| 29 | + static String coupon_detail = "/coupon_detail"; //优惠券详情页 | ||
| 29 | 30 | ||
| 30 | static void configureRoutes(FluroRouter router) { | 31 | static void configureRoutes(FluroRouter router) { |
| 31 | router.notFoundHandler = new Handler( | 32 | router.notFoundHandler = new Handler( |
| @@ -55,8 +56,7 @@ class Routes { | @@ -55,8 +56,7 @@ class Routes { | ||
| 55 | router.define(coupon, handler: handleCouponPageHandler); | 56 | router.define(coupon, handler: handleCouponPageHandler); |
| 56 | router.define(coupon_history, handler: handleCouponHistoryPageHandler); | 57 | router.define(coupon_history, handler: handleCouponHistoryPageHandler); |
| 57 | router.define(coupon_edit, handler: handleCouponEditPageHandler); | 58 | router.define(coupon_edit, handler: handleCouponEditPageHandler); |
| 58 | - router.define(coupon_select, handler: handleCouponSelectPageHandler); | ||
| 59 | - | ||
| 60 | - | 59 | + router.define(coupon_select, handler: handleCouponSelectPageHandler); |
| 60 | + router.define(coupon_detail, handler: handleCouponDetailPageHandler); | ||
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 1 | import 'package:fluro/fluro.dart'; | 1 | import 'package:fluro/fluro.dart'; |
| 2 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 3 | +import 'package:one_key/models/coupon_model.dart'; | ||
| 3 | import 'package:one_key/models/notebook.dart'; | 4 | import 'package:one_key/models/notebook.dart'; |
| 4 | import 'package:one_key/models/notebook_detail.dart'; | 5 | import 'package:one_key/models/notebook_detail.dart'; |
| 5 | import 'package:one_key/models/table_list.dart'; | 6 | import 'package:one_key/models/table_list.dart'; |
| @@ -171,7 +172,18 @@ class NavigatorUtil { | @@ -171,7 +172,18 @@ class NavigatorUtil { | ||
| 171 | 172 | ||
| 172 | /// 选择优惠券 | 173 | /// 选择优惠券 |
| 173 | static Future<dynamic> goCouponSelectPage(BuildContext context, | 174 | static Future<dynamic> goCouponSelectPage(BuildContext context, |
| 175 | + {String rid, bool hasModify, replace = false}) { | ||
| 176 | + return _navigateTo( | ||
| 177 | + context, "${Routes.coupon_select}?rid=${rid}&hasModify=${hasModify}", | ||
| 178 | + replace: replace); | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /// 优惠券详情页 | ||
| 182 | + static Future<dynamic> goCouponDetailPage( | ||
| 183 | + BuildContext context, CouponSunModel couponSunModel, | ||
| 174 | {replace = false}) { | 184 | {replace = false}) { |
| 175 | - return _navigateTo(context, "${Routes.coupon_select}", replace: replace); | 185 | + return _navigateTo(context, |
| 186 | + "${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}", | ||
| 187 | + replace: replace); | ||
| 176 | } | 188 | } |
| 177 | } | 189 | } |
| @@ -22,6 +22,12 @@ import '../app.dart'; | @@ -22,6 +22,12 @@ import '../app.dart'; | ||
| 22 | typedef BookTimeSetCallback = void Function(bool needChange); | 22 | typedef BookTimeSetCallback = void Function(bool needChange); |
| 23 | 23 | ||
| 24 | class Utils { | 24 | class Utils { |
| 25 | + static getDateStrFromJiekou(String ms) { | ||
| 26 | + return DateUtil.formatDate( | ||
| 27 | + DateTime.fromMillisecondsSinceEpoch(int.parse(ms) * 1000), | ||
| 28 | + format: DateFormats.full); | ||
| 29 | + } | ||
| 30 | + | ||
| 25 | static setBarStatus(bool isDarkIcon, | 31 | static setBarStatus(bool isDarkIcon, |
| 26 | {Color color: Colors.transparent}) async { | 32 | {Color color: Colors.transparent}) async { |
| 27 | if (Platform.isAndroid) { | 33 | if (Platform.isAndroid) { |
| @@ -181,7 +187,7 @@ class Utils { | @@ -181,7 +187,7 @@ class Utils { | ||
| 181 | } | 187 | } |
| 182 | 188 | ||
| 183 | //分享邀请函 | 189 | //分享邀请函 |
| 184 | - static goShareInvicationToWeChat(String rid) { | 190 | + static goShareInvicationToWeChat(String rid) async { |
| 185 | String _webPageUrl = "http://colorcun.com/"; | 191 | String _webPageUrl = "http://colorcun.com/"; |
| 186 | String _thumbnail = | 192 | String _thumbnail = |
| 187 | "https://qn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148572.jpg"; | 193 | "https://qn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148572.jpg"; |
| @@ -196,7 +202,8 @@ class Utils { | @@ -196,7 +202,8 @@ class Utils { | ||
| 196 | path: _path, | 202 | path: _path, |
| 197 | description: _description, | 203 | description: _description, |
| 198 | thumbnail: WeChatImage.network(_thumbnail)); | 204 | thumbnail: WeChatImage.network(_thumbnail)); |
| 199 | - shareToWeChat(model); | 205 | + bool isSuccess = await shareToWeChat(model); |
| 206 | + return isSuccess; | ||
| 200 | } | 207 | } |
| 201 | 208 | ||
| 202 | //检查网络连接 | 209 | //检查网络连接 |
| @@ -227,6 +234,21 @@ class Utils { | @@ -227,6 +234,21 @@ class Utils { | ||
| 227 | return result.toString(); | 234 | return result.toString(); |
| 228 | } | 235 | } |
| 229 | 236 | ||
| 237 | + static String listToStringEnglish(List<String> list) { | ||
| 238 | + if (list == null) { | ||
| 239 | + return null; | ||
| 240 | + } | ||
| 241 | + String result; | ||
| 242 | + list.forEach((string) { | ||
| 243 | + if (result == null) { | ||
| 244 | + result = string; | ||
| 245 | + } else { | ||
| 246 | + result = '$result,$string'; | ||
| 247 | + } | ||
| 248 | + }); | ||
| 249 | + return result.toString(); | ||
| 250 | + } | ||
| 251 | + | ||
| 230 | /// 获取日期 今天 明天 后天等等 | 252 | /// 获取日期 今天 明天 后天等等 |
| 231 | static int getDdate(List dateList) { | 253 | static int getDdate(List dateList) { |
| 232 | String ymyStr = ""; //年月日 | 254 | String ymyStr = ""; //年月日 |
-
Please register or login to post a comment