Showing
13 changed files
with
600 additions
and
433 deletions
| @@ -60,11 +60,14 @@ class CouponSunModel extends Object { | @@ -60,11 +60,14 @@ class CouponSunModel extends Object { | ||
| 60 | @JsonKey(name: 'use_num') | 60 | @JsonKey(name: 'use_num') |
| 61 | String useNum; | 61 | String useNum; |
| 62 | 62 | ||
| 63 | + @JsonKey(name: 'nickname') | ||
| 64 | + String nickname; | ||
| 65 | + | ||
| 63 | @JsonKey(name: 'uid_list') | 66 | @JsonKey(name: 'uid_list') |
| 64 | String uidList; | 67 | String uidList; |
| 65 | @JsonKey(name: 'is_examine') | 68 | @JsonKey(name: 'is_examine') |
| 66 | String isExamine; | 69 | String isExamine; |
| 67 | - @JsonKey(name: 'is_type') | 70 | + @JsonKey(name: 'is_type') |
| 68 | String isType; | 71 | String isType; |
| 69 | 72 | ||
| 70 | @JsonKey(name: 'is_open') | 73 | @JsonKey(name: 'is_open') |
| @@ -88,6 +91,7 @@ class CouponSunModel extends Object { | @@ -88,6 +91,7 @@ class CouponSunModel extends Object { | ||
| 88 | this.cdate, | 91 | this.cdate, |
| 89 | this.receiveNum, | 92 | this.receiveNum, |
| 90 | this.useNum, | 93 | this.useNum, |
| 94 | + this.nickname, | ||
| 91 | this.uidList, | 95 | this.uidList, |
| 92 | this.isExamine, | 96 | this.isExamine, |
| 93 | this.isType, | 97 | this.isType, |
| @@ -37,6 +37,7 @@ CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) { | @@ -37,6 +37,7 @@ CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) { | ||
| 37 | json['cdate'] as String, | 37 | json['cdate'] as String, |
| 38 | json['receive_num'] as String, | 38 | json['receive_num'] as String, |
| 39 | json['use_num'] as String, | 39 | json['use_num'] as String, |
| 40 | + json['nickname'] as String, | ||
| 40 | json['uid_list'] as String, | 41 | json['uid_list'] as String, |
| 41 | json['is_examine'] as String, | 42 | json['is_examine'] as String, |
| 42 | json['is_type'] as String, | 43 | json['is_type'] as String, |
| @@ -58,6 +59,7 @@ Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) => | @@ -58,6 +59,7 @@ Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) => | ||
| 58 | 'cdate': instance.cdate, | 59 | 'cdate': instance.cdate, |
| 59 | 'receiveNum': instance.receiveNum, | 60 | 'receiveNum': instance.receiveNum, |
| 60 | 'useNum': instance.useNum, | 61 | 'useNum': instance.useNum, |
| 62 | + 'nickname': instance.nickname, | ||
| 61 | 'uid_list': instance.uidList, | 63 | 'uid_list': instance.uidList, |
| 62 | 'is_examine': instance.isExamine, | 64 | 'is_examine': instance.isExamine, |
| 63 | 'is_type': instance.isType, | 65 | 'is_type': instance.isType, |
| @@ -74,7 +74,8 @@ class HttpUrl { | @@ -74,7 +74,8 @@ class HttpUrl { | ||
| 74 | static const String create_customer_activity = | 74 | static const String create_customer_activity = |
| 75 | "?service=App.Activity.CreateCustomerActivity"; //客户经理创建活动 | 75 | "?service=App.Activity.CreateCustomerActivity"; //客户经理创建活动 |
| 76 | static const String get_customer_activity = | 76 | static const String get_customer_activity = |
| 77 | - "?service=App.Activity.CustomerActivityList"; //获取所创建活动的列表 | 77 | + "?service=App.Activity.NewCustomerActivityList"; //获取所创建活动的列表 |
| 78 | + | ||
| 78 | static const String set_customer_activity = | 79 | static const String set_customer_activity = |
| 79 | "?service=App.Activity.SetCustomerActivity"; //修改所创建活动的列表 | 80 | "?service=App.Activity.SetCustomerActivity"; //修改所创建活动的列表 |
| 80 | static const String set_activity_as_reserve = | 81 | static const String set_activity_as_reserve = |
| @@ -180,11 +180,12 @@ class _CouponCreateSelectTypePageState | @@ -180,11 +180,12 @@ class _CouponCreateSelectTypePageState | ||
| 180 | isMine: selectF); | 180 | isMine: selectF); |
| 181 | print(needRefresh); | 181 | print(needRefresh); |
| 182 | if (needRefresh != null && needRefresh) { | 182 | if (needRefresh != null && needRefresh) { |
| 183 | + | ||
| 183 | Navigator.pop(context); | 184 | Navigator.pop(context); |
| 184 | //刷新页面数据 | 185 | //刷新页面数据 |
| 185 | // _controller.callRefresh(); | 186 | // _controller.callRefresh(); |
| 186 | // _couponNetworkData(); | 187 | // _couponNetworkData(); |
| 187 | - bus.emit('refresh_coupon_list_f'); | 188 | + |
| 188 | } | 189 | } |
| 189 | }, | 190 | }, |
| 190 | ) | 191 | ) |
| @@ -102,6 +102,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -102,6 +102,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 102 | if (isSuccess) { | 102 | if (isSuccess) { |
| 103 | //成功之后跳回前一个页面 | 103 | //成功之后跳回前一个页面 |
| 104 | // bus.emit('refresh_coupon_list'); | 104 | // bus.emit('refresh_coupon_list'); |
| 105 | + EventBus().emit('refresh_coupon_invitation'); | ||
| 106 | + bus.emit('refresh_coupon_list_f'); | ||
| 105 | Navigator.pop(context, true); | 107 | Navigator.pop(context, true); |
| 106 | } | 108 | } |
| 107 | } | 109 | } |
| @@ -375,178 +377,185 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | @@ -375,178 +377,185 @@ class _CouponEidtPageState extends State<CouponEidtPage> { | ||
| 375 | onTap: () { | 377 | onTap: () { |
| 376 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | 378 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 |
| 377 | }, | 379 | }, |
| 378 | - child: Column(children: [ | ||
| 379 | - Expanded( | ||
| 380 | - child: SingleChildScrollView( | ||
| 381 | - controller: controller, | ||
| 382 | - physics: BouncingScrollPhysics(), | ||
| 383 | - child: Padding( | ||
| 384 | - padding: EdgeInsets.only(left: ScreenUtil().setWidth(32)), | ||
| 385 | - child: Column( | ||
| 386 | - children: [ | ||
| 387 | - VEmptyView(56), | ||
| 388 | - _item('券类型', widget.isMine ? '我的优惠券' : '店铺优惠券'), | ||
| 389 | - Container( | ||
| 390 | - height: ScreenUtil().setWidth(2), | ||
| 391 | - color: MyColours.color_E7E7E7, | ||
| 392 | - ), | ||
| 393 | - VEmptyView(24), | ||
| 394 | - widget.isMine | ||
| 395 | - ? SizedBox() | ||
| 396 | - : _canUse('是否核销', swichHexiao, () { | ||
| 397 | - setState(() { | ||
| 398 | - swichHexiao = !swichHexiao; | ||
| 399 | - }); | ||
| 400 | - }), | ||
| 401 | - widget.isMine | ||
| 402 | - ? SizedBox() | ||
| 403 | - : Container( | ||
| 404 | - height: ScreenUtil().setWidth(2), | ||
| 405 | - color: MyColours.color_E7E7E7, | ||
| 406 | - ), | ||
| 407 | - widget.isMine ? SizedBox() : VEmptyView(24), | ||
| 408 | - _textfield('券名称', '例:9折券/200元代金券/菜品券'), | ||
| 409 | - Container( | ||
| 410 | - height: ScreenUtil().setWidth(2), | ||
| 411 | - color: MyColours.color_E7E7E7, | ||
| 412 | - ), | ||
| 413 | - VEmptyView(24), | ||
| 414 | - _textfield('券要求', '例:无门槛/满2000元'), | ||
| 415 | - Container( | ||
| 416 | - height: ScreenUtil().setWidth(2), | ||
| 417 | - color: MyColours.color_E7E7E7, | ||
| 418 | - ), | ||
| 419 | - VEmptyView(24), | ||
| 420 | - _select('有效期从', fromDate, () { | ||
| 421 | - FocusScope.of(context) | ||
| 422 | - .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 423 | - //弹出时间选择器 | ||
| 424 | - // showPickerDateTime(context); | ||
| 425 | - showDateSelWidget = true; | ||
| 426 | - DialogUtil.showPickerDateTime24( | ||
| 427 | - context, | ||
| 428 | - scaffoldKey, | ||
| 429 | - (value) { | ||
| 430 | - // {'text': picker.adapter.text, 'select': selecteds} | ||
| 431 | - if (value != null) { | ||
| 432 | - setState(() { | ||
| 433 | - print(value); | ||
| 434 | - fromDate = DateUtil.formatDateStr(value, | ||
| 435 | - format: DateFormats.full); | 380 | + child: Container( |
| 381 | + color: MyColours.color_ffffff, | ||
| 382 | + child: Column(children: [ | ||
| 383 | + Expanded( | ||
| 384 | + child: SingleChildScrollView( | ||
| 385 | + controller: controller, | ||
| 386 | + physics: BouncingScrollPhysics(), | ||
| 387 | + child: Padding( | ||
| 388 | + padding: | ||
| 389 | + EdgeInsets.only(left: ScreenUtil().setWidth(32)), | ||
| 390 | + child: Column( | ||
| 391 | + children: [ | ||
| 392 | + VEmptyView(56), | ||
| 393 | + _item('券类型', widget.isMine ? '我的优惠券' : '店铺优惠券'), | ||
| 394 | + Container( | ||
| 395 | + height: ScreenUtil().setWidth(2), | ||
| 396 | + color: MyColours.color_E7E7E7, | ||
| 397 | + ), | ||
| 398 | + VEmptyView(24), | ||
| 399 | + widget.isMine | ||
| 400 | + ? SizedBox() | ||
| 401 | + : _canUse('是否核销', swichHexiao, () { | ||
| 402 | + setState(() { | ||
| 403 | + swichHexiao = !swichHexiao; | ||
| 404 | + }); | ||
| 405 | + }), | ||
| 406 | + widget.isMine | ||
| 407 | + ? SizedBox() | ||
| 408 | + : Container( | ||
| 409 | + height: ScreenUtil().setWidth(2), | ||
| 410 | + color: MyColours.color_E7E7E7, | ||
| 411 | + ), | ||
| 412 | + widget.isMine ? SizedBox() : VEmptyView(24), | ||
| 413 | + _textfield('券名称', '例:9折券/200元代金券/菜品券'), | ||
| 414 | + Container( | ||
| 415 | + height: ScreenUtil().setWidth(2), | ||
| 416 | + color: MyColours.color_E7E7E7, | ||
| 417 | + ), | ||
| 418 | + VEmptyView(24), | ||
| 419 | + _textfield('券要求', '例:无门槛/满2000元'), | ||
| 420 | + Container( | ||
| 421 | + height: ScreenUtil().setWidth(2), | ||
| 422 | + color: MyColours.color_E7E7E7, | ||
| 423 | + ), | ||
| 424 | + VEmptyView(24), | ||
| 425 | + _select('有效期从', fromDate, () { | ||
| 426 | + FocusScope.of(context) | ||
| 427 | + .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 428 | + //弹出时间选择器 | ||
| 429 | + // showPickerDateTime(context); | ||
| 430 | + showDateSelWidget = true; | ||
| 431 | + DialogUtil.showPickerDateTime24( | ||
| 432 | + context, | ||
| 433 | + scaffoldKey, | ||
| 434 | + (value) { | ||
| 435 | + // {'text': picker.adapter.text, 'select': selecteds} | ||
| 436 | + if (value != null) { | ||
| 437 | + setState(() { | ||
| 438 | + print(value); | ||
| 439 | + fromDate = DateUtil.formatDateStr( | ||
| 440 | + value, | ||
| 441 | + format: DateFormats.full); | ||
| 442 | + }); | ||
| 443 | + } | ||
| 444 | + showDateSelWidget = false; | ||
| 445 | + }, | ||
| 446 | + dateTime: DateUtil.getDateTime(fromDate), | ||
| 447 | + onCancel: () { | ||
| 448 | + showDateSelWidget = false; | ||
| 436 | }); | 449 | }); |
| 437 | - } | ||
| 438 | - showDateSelWidget = false; | ||
| 439 | - }, | ||
| 440 | - dateTime: DateUtil.getDateTime(fromDate), | ||
| 441 | - onCancel: () { | ||
| 442 | - showDateSelWidget = false; | ||
| 443 | - }); | ||
| 444 | - }), | ||
| 445 | - Container( | ||
| 446 | - height: ScreenUtil().setWidth(2), | ||
| 447 | - color: MyColours.color_E7E7E7, | ||
| 448 | - ), | ||
| 449 | - VEmptyView(24), | ||
| 450 | - _select('有效期至', endDate, () { | ||
| 451 | - FocusScope.of(context) | ||
| 452 | - .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 453 | - //弹出时间选择器 | ||
| 454 | - // showPickerDateTime(context); | ||
| 455 | - showDateSelWidget = true; | ||
| 456 | - DialogUtil.showPickerDateTime24( | ||
| 457 | - context, | ||
| 458 | - scaffoldKey, | ||
| 459 | - (value) { | ||
| 460 | - // {'text': picker.adapter.text, 'select': selecteds} | ||
| 461 | - if (value != null) { | ||
| 462 | - setState(() { | ||
| 463 | - print(value); | ||
| 464 | - endDate = DateUtil.formatDateStr(value, | ||
| 465 | - format: DateFormats.full); | 450 | + }), |
| 451 | + Container( | ||
| 452 | + height: ScreenUtil().setWidth(2), | ||
| 453 | + color: MyColours.color_E7E7E7, | ||
| 454 | + ), | ||
| 455 | + VEmptyView(24), | ||
| 456 | + _select('有效期至', endDate, () { | ||
| 457 | + FocusScope.of(context) | ||
| 458 | + .requestFocus(FocusNode()); //点击空白处隐藏键盘 | ||
| 459 | + //弹出时间选择器 | ||
| 460 | + // showPickerDateTime(context); | ||
| 461 | + showDateSelWidget = true; | ||
| 462 | + DialogUtil.showPickerDateTime24( | ||
| 463 | + context, | ||
| 464 | + scaffoldKey, | ||
| 465 | + (value) { | ||
| 466 | + // {'text': picker.adapter.text, 'select': selecteds} | ||
| 467 | + if (value != null) { | ||
| 468 | + setState(() { | ||
| 469 | + print(value); | ||
| 470 | + endDate = DateUtil.formatDateStr( | ||
| 471 | + value, | ||
| 472 | + format: DateFormats.full); | ||
| 473 | + }); | ||
| 474 | + } | ||
| 475 | + showDateSelWidget = false; | ||
| 476 | + }, | ||
| 477 | + dateTime: DateUtil.getDateTime(endDate), | ||
| 478 | + onCancel: () { | ||
| 479 | + showDateSelWidget = false; | ||
| 466 | }); | 480 | }); |
| 467 | - } | ||
| 468 | - showDateSelWidget = false; | ||
| 469 | - }, | ||
| 470 | - dateTime: DateUtil.getDateTime(endDate), | ||
| 471 | - onCancel: () { | ||
| 472 | - showDateSelWidget = false; | 481 | + }), |
| 482 | + Container( | ||
| 483 | + height: ScreenUtil().setWidth(2), | ||
| 484 | + color: MyColours.color_E7E7E7, | ||
| 485 | + ), | ||
| 486 | + VEmptyView(24), | ||
| 487 | + widget.isMine | ||
| 488 | + ? SizedBox() | ||
| 489 | + : _select('谁可以发放', '编辑', () async { | ||
| 490 | + Map temp = await NavigatorUtil | ||
| 491 | + .goCouponToPersonnalPage( | ||
| 492 | + context, uids); | ||
| 493 | + if (temp != null && | ||
| 494 | + temp['object'] != null) { | ||
| 495 | + uids = temp['object']; | ||
| 496 | + } | ||
| 497 | + }), | ||
| 498 | + widget.isMine | ||
| 499 | + ? SizedBox() | ||
| 500 | + : Container( | ||
| 501 | + height: ScreenUtil().setWidth(2), | ||
| 502 | + color: MyColours.color_E7E7E7, | ||
| 503 | + ), | ||
| 504 | + widget.isMine ? SizedBox() : VEmptyView(24), | ||
| 505 | + _explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'), | ||
| 506 | + VEmptyView(20), | ||
| 507 | + _canUse('立即启用', swichState, () { | ||
| 508 | + setState(() { | ||
| 509 | + swichState = !swichState; | ||
| 473 | }); | 510 | }); |
| 474 | - }), | ||
| 475 | - Container( | ||
| 476 | - height: ScreenUtil().setWidth(2), | ||
| 477 | - color: MyColours.color_E7E7E7, | ||
| 478 | - ), | ||
| 479 | - VEmptyView(24), | ||
| 480 | - widget.isMine | ||
| 481 | - ? SizedBox() | ||
| 482 | - : _select('谁可以发放', '编辑', () async { | ||
| 483 | - Map temp = await NavigatorUtil | ||
| 484 | - .goCouponToPersonnalPage(context, uids); | ||
| 485 | - if (temp != null && temp['object'] != null) { | ||
| 486 | - uids = temp['object']; | ||
| 487 | - } | ||
| 488 | - }), | ||
| 489 | - widget.isMine | ||
| 490 | - ? SizedBox() | ||
| 491 | - : Container( | ||
| 492 | - height: ScreenUtil().setWidth(2), | ||
| 493 | - color: MyColours.color_E7E7E7, | ||
| 494 | - ), | ||
| 495 | - widget.isMine ? SizedBox() : VEmptyView(24), | ||
| 496 | - _explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'), | ||
| 497 | - VEmptyView(20), | ||
| 498 | - _canUse('立即启用', swichState, () { | ||
| 499 | - setState(() { | ||
| 500 | - swichState = !swichState; | ||
| 501 | - }); | ||
| 502 | - }), | ||
| 503 | - VEmptyView(30), | ||
| 504 | - ], | ||
| 505 | - ))), | ||
| 506 | - ), | ||
| 507 | - VEmptyView(20), | ||
| 508 | - RoundButton( | ||
| 509 | - onPressed: () { | ||
| 510 | - if (_couponNameEditControl.text.trim().length == 0) { | ||
| 511 | - Utils.showToast('请填写券名称'); | ||
| 512 | - return; | ||
| 513 | - } | ||
| 514 | - if (_couponRequireEditControl.text.trim().length == 0) { | ||
| 515 | - Utils.showToast('请填写券要求'); | ||
| 516 | - return; | ||
| 517 | - } | ||
| 518 | - if (fromDate == '点击选择') { | ||
| 519 | - Utils.showToast('请选择有效期起始时间'); | ||
| 520 | - return; | ||
| 521 | - } | ||
| 522 | - if (endDate == '点击选择') { | ||
| 523 | - Utils.showToast('请选择有效期结束时间'); | ||
| 524 | - return; | ||
| 525 | - } | ||
| 526 | - if (DateUtil.getDateTime(endDate) | ||
| 527 | - .compareTo(DateUtil.getDateTime(fromDate)) < | ||
| 528 | - 0) { | ||
| 529 | - Utils.showToast('有效期结束时间不能早于起始时间'); | ||
| 530 | - return; | ||
| 531 | - } | ||
| 532 | - // ***参数*** | ||
| 533 | - // _couponNameEditControl.text | ||
| 534 | - // _couponRequireEditControl.text | ||
| 535 | - // fromDate | ||
| 536 | - // endDate | ||
| 537 | - // _couponExplainEditControl.text | ||
| 538 | - // swichState | ||
| 539 | - _createNewCoupon(); | ||
| 540 | - }, | ||
| 541 | - text: '立即创建', | ||
| 542 | - fontSize: 24, | ||
| 543 | - isBold: false, | ||
| 544 | - height: ScreenUtil().setWidth(37 * 2), | ||
| 545 | - width: ScreenUtil().setWidth(130 * 2), | ||
| 546 | - radius: ScreenUtil().setWidth(22), | ||
| 547 | - ), | ||
| 548 | - VEmptyView(32) | ||
| 549 | - ])), | 511 | + }), |
| 512 | + VEmptyView(30), | ||
| 513 | + ], | ||
| 514 | + ))), | ||
| 515 | + ), | ||
| 516 | + VEmptyView(20), | ||
| 517 | + RoundButton( | ||
| 518 | + onPressed: () { | ||
| 519 | + if (_couponNameEditControl.text.trim().length == 0) { | ||
| 520 | + Utils.showToast('请填写券名称'); | ||
| 521 | + return; | ||
| 522 | + } | ||
| 523 | + if (_couponRequireEditControl.text.trim().length == 0) { | ||
| 524 | + Utils.showToast('请填写券要求'); | ||
| 525 | + return; | ||
| 526 | + } | ||
| 527 | + if (fromDate == '点击选择') { | ||
| 528 | + Utils.showToast('请选择有效期起始时间'); | ||
| 529 | + return; | ||
| 530 | + } | ||
| 531 | + if (endDate == '点击选择') { | ||
| 532 | + Utils.showToast('请选择有效期结束时间'); | ||
| 533 | + return; | ||
| 534 | + } | ||
| 535 | + if (DateUtil.getDateTime(endDate) | ||
| 536 | + .compareTo(DateUtil.getDateTime(fromDate)) < | ||
| 537 | + 0) { | ||
| 538 | + Utils.showToast('有效期结束时间不能早于起始时间'); | ||
| 539 | + return; | ||
| 540 | + } | ||
| 541 | + // ***参数*** | ||
| 542 | + // _couponNameEditControl.text | ||
| 543 | + // _couponRequireEditControl.text | ||
| 544 | + // fromDate | ||
| 545 | + // endDate | ||
| 546 | + // _couponExplainEditControl.text | ||
| 547 | + // swichState | ||
| 548 | + _createNewCoupon(); | ||
| 549 | + }, | ||
| 550 | + text: '立即创建', | ||
| 551 | + fontSize: 24, | ||
| 552 | + isBold: false, | ||
| 553 | + height: ScreenUtil().setWidth(37 * 2), | ||
| 554 | + width: ScreenUtil().setWidth(130 * 2), | ||
| 555 | + radius: ScreenUtil().setWidth(22), | ||
| 556 | + ), | ||
| 557 | + VEmptyView(32) | ||
| 558 | + ]))), | ||
| 550 | ); | 559 | ); |
| 551 | } | 560 | } |
| 552 | } | 561 | } |
| @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; | @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; | ||
| 2 | import 'package:flutter_easyrefresh/easy_refresh.dart'; | 2 | 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/pages/coupon/coupon_item_f.dart'; | ||
| 5 | import 'package:one_key/provider/coupon_provider.dart'; | 6 | import 'package:one_key/provider/coupon_provider.dart'; |
| 6 | import 'package:one_key/provider/user_model.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'; |
| @@ -49,7 +50,7 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | @@ -49,7 +50,7 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | ||
| 49 | return Scaffold( | 50 | return Scaffold( |
| 50 | backgroundColor: MyColours.color_fefefe, | 51 | backgroundColor: MyColours.color_fefefe, |
| 51 | appBar: SystemAppBar( | 52 | appBar: SystemAppBar( |
| 52 | - ' 历史券', | 53 | + '过期优惠券', |
| 53 | onTap: () { | 54 | onTap: () { |
| 54 | Navigator.of(context).pop(); | 55 | Navigator.of(context).pop(); |
| 55 | }, | 56 | }, |
| @@ -80,13 +81,27 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | @@ -80,13 +81,27 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> { | ||
| 80 | SliverList( | 81 | SliverList( |
| 81 | delegate: SliverChildBuilderDelegate( | 82 | delegate: SliverChildBuilderDelegate( |
| 82 | (BuildContext context, int index) { | 83 | (BuildContext context, int index) { |
| 83 | - return CouponItem( | 84 | + // return CouponItem( |
| 85 | + // from: 'history', | ||
| 86 | + // couponSonModel: couponProvider.couponListHistory[index], | ||
| 87 | + // onPressed: () { | ||
| 88 | + // // couponProvider.couponListHistory[index] = | ||
| 89 | + // // !couponProvider.couponListHistory[index]; | ||
| 90 | + // // couponProvider.notifyListeners(); | ||
| 91 | + // }, | ||
| 92 | + // ); | ||
| 93 | + return CouponItemF( | ||
| 84 | from: 'history', | 94 | from: 'history', |
| 85 | couponSonModel: couponProvider.couponListHistory[index], | 95 | couponSonModel: couponProvider.couponListHistory[index], |
| 96 | + showBtn: true, | ||
| 97 | + onPressedSwich: () { | ||
| 98 | + // couponProvider.couponList[index].isOpenBool = | ||
| 99 | + // !couponProvider.couponList[index].isOpenBool; | ||
| 100 | + // _setCustomerActivity(index); | ||
| 101 | + }, | ||
| 86 | onPressed: () { | 102 | onPressed: () { |
| 87 | - // couponProvider.couponListHistory[index] = | ||
| 88 | - // !couponProvider.couponListHistory[index]; | ||
| 89 | - // couponProvider.notifyListeners(); | 103 | + // NavigatorUtil.goCouponDetailPage( |
| 104 | + // context, couponProvider.couponList[index]); | ||
| 90 | }, | 105 | }, |
| 91 | ); | 106 | ); |
| 92 | }, childCount: couponProvider.couponListHistory.length), | 107 | }, childCount: couponProvider.couponListHistory.length), |
| @@ -87,11 +87,13 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -87,11 +87,13 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 87 | padding: EdgeInsets.symmetric( | 87 | padding: EdgeInsets.symmetric( |
| 88 | horizontal: ScreenUtil().setWidth(24)), | 88 | horizontal: ScreenUtil().setWidth(24)), |
| 89 | decoration: BoxDecoration( | 89 | decoration: BoxDecoration( |
| 90 | - color: notSelect | ||
| 91 | - ? sunModel.isType == '1' | ||
| 92 | - ? MyColours.color_438E93 | ||
| 93 | - : MyColours.color_ED7B2F | ||
| 94 | - : MyColours.color_999999, | 90 | + color: widget.from == 'history' |
| 91 | + ? MyColours.color_BFC4D4 | ||
| 92 | + : notSelect | ||
| 93 | + ? sunModel.isType == '1' | ||
| 94 | + ? MyColours.color_438E93 | ||
| 95 | + : MyColours.color_ED7B2F | ||
| 96 | + : MyColours.color_999999, | ||
| 95 | borderRadius: BorderRadius.only( | 97 | borderRadius: BorderRadius.only( |
| 96 | topLeft: Radius.circular(ScreenUtil().setWidth(16)), | 98 | topLeft: Radius.circular(ScreenUtil().setWidth(16)), |
| 97 | topRight: | 99 | topRight: |
| @@ -115,7 +117,7 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -115,7 +117,7 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 115 | sunModel.isType == '1' | 117 | sunModel.isType == '1' |
| 116 | ? sunModel.isExamine == '1' | 118 | ? sunModel.isExamine == '1' |
| 117 | ? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张' | 119 | ? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张' |
| 118 | - : '创建人:${sunModel.uid} 被领取:${sunModel.receiveNum}张' | 120 | + : '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张' |
| 119 | : '被领取:${sunModel.receiveNum}张', | 121 | : '被领取:${sunModel.receiveNum}张', |
| 120 | maxLines: 1, | 122 | maxLines: 1, |
| 121 | overflow: TextOverflow.ellipsis, | 123 | overflow: TextOverflow.ellipsis, |
| @@ -146,9 +148,11 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -146,9 +148,11 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 146 | maxLines: 2, | 148 | maxLines: 2, |
| 147 | overflow: TextOverflow.ellipsis, | 149 | overflow: TextOverflow.ellipsis, |
| 148 | style: TextStyle( | 150 | style: TextStyle( |
| 149 | - color: notSelect | ||
| 150 | - ? MyColours.color_515151 | ||
| 151 | - : MyColours.color_999999, | 151 | + color: widget.from == 'history' |
| 152 | + ? MyColours.color_BFC4D4 | ||
| 153 | + : notSelect | ||
| 154 | + ? MyColours.color_515151 | ||
| 155 | + : MyColours.color_999999, | ||
| 152 | fontSize: ScreenUtil().setSp(36), | 156 | fontSize: ScreenUtil().setSp(36), |
| 153 | fontWeight: FontWeight.bold), | 157 | fontWeight: FontWeight.bold), |
| 154 | ), | 158 | ), |
| @@ -160,9 +164,11 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -160,9 +164,11 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 160 | maxLines: 1, | 164 | maxLines: 1, |
| 161 | overflow: TextOverflow.ellipsis, | 165 | overflow: TextOverflow.ellipsis, |
| 162 | style: TextStyle( | 166 | style: TextStyle( |
| 163 | - color: notSelect | ||
| 164 | - ? MyColours.color_515151 | ||
| 165 | - : MyColours.color_999999, | 167 | + color: widget.from == 'history' |
| 168 | + ? MyColours.color_BFC4D4 | ||
| 169 | + : notSelect | ||
| 170 | + ? MyColours.color_515151 | ||
| 171 | + : MyColours.color_999999, | ||
| 166 | fontSize: ScreenUtil().setSp(20), | 172 | fontSize: ScreenUtil().setSp(20), |
| 167 | )), | 173 | )), |
| 168 | ), | 174 | ), |
| @@ -175,7 +181,9 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -175,7 +181,9 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 175 | child: Text( | 181 | child: Text( |
| 176 | '使用时间:${ObjectUtil.isNotEmpty(sunModel.stime) ? Utils.getDateStrFromJiekou(sunModel.stime) : '--'} 至 ${ObjectUtil.isNotEmpty(sunModel.etime) ? Utils.getDateStrFromJiekou(sunModel.etime) : '--'}', | 182 | '使用时间:${ObjectUtil.isNotEmpty(sunModel.stime) ? Utils.getDateStrFromJiekou(sunModel.stime) : '--'} 至 ${ObjectUtil.isNotEmpty(sunModel.etime) ? Utils.getDateStrFromJiekou(sunModel.etime) : '--'}', |
| 177 | style: TextStyle( | 183 | style: TextStyle( |
| 178 | - color: MyColours.color_999999, | 184 | + color: widget.from == 'history' |
| 185 | + ? MyColours.color_BFC4D4 | ||
| 186 | + : MyColours.color_999999, | ||
| 179 | fontSize: ScreenUtil().setSp(20))), | 187 | fontSize: ScreenUtil().setSp(20))), |
| 180 | ) | 188 | ) |
| 181 | : Container(), | 189 | : Container(), |
| @@ -196,7 +204,9 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -196,7 +204,9 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 196 | // : Container() | 204 | // : Container() |
| 197 | // : | 205 | // : |
| 198 | ), | 206 | ), |
| 199 | - const MySeparator(width: 3, color: MyColours.color_f3f3f3), | 207 | + ObjectUtil.isNotEmpty(sunModel.explain) |
| 208 | + ? const MySeparator(width: 3, color: MyColours.color_f3f3f3) | ||
| 209 | + : SizedBox(), | ||
| 200 | ObjectUtil.isNotEmpty(sunModel.explain) | 210 | ObjectUtil.isNotEmpty(sunModel.explain) |
| 201 | ? InkWell( | 211 | ? InkWell( |
| 202 | onTap: () { | 212 | onTap: () { |
| @@ -210,9 +220,11 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -210,9 +220,11 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 210 | child: Container( | 220 | child: Container( |
| 211 | width: double.infinity, | 221 | width: double.infinity, |
| 212 | decoration: BoxDecoration( | 222 | decoration: BoxDecoration( |
| 213 | - color: notSelect | 223 | + color: widget.from == 'history' |
| 214 | ? MyColours.color_ffffff | 224 | ? MyColours.color_ffffff |
| 215 | - : MyColours.color_FAFAFA, | 225 | + : notSelect |
| 226 | + ? MyColours.color_ffffff | ||
| 227 | + : MyColours.color_FAFAFA, | ||
| 216 | borderRadius: BorderRadius.only( | 228 | borderRadius: BorderRadius.only( |
| 217 | bottomLeft: Radius.circular( | 229 | bottomLeft: Radius.circular( |
| 218 | ScreenUtil().setWidth(20)), | 230 | ScreenUtil().setWidth(20)), |
| @@ -233,7 +245,9 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -233,7 +245,9 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 233 | child: Text('说明:${sunModel.explain}', | 245 | child: Text('说明:${sunModel.explain}', |
| 234 | maxLines: 5, | 246 | maxLines: 5, |
| 235 | style: TextStyle( | 247 | style: TextStyle( |
| 236 | - color: MyColours.color_999999, | 248 | + color: widget.from == 'history' |
| 249 | + ? MyColours.color_BFC4D4 | ||
| 250 | + : MyColours.color_999999, | ||
| 237 | fontSize: | 251 | fontSize: |
| 238 | ScreenUtil().setSp(20))), | 252 | ScreenUtil().setSp(20))), |
| 239 | ) | 253 | ) |
| @@ -251,7 +265,9 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -251,7 +265,9 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 251 | overflow: TextOverflow.fade, | 265 | overflow: TextOverflow.fade, |
| 252 | softWrap: false, | 266 | softWrap: false, |
| 253 | style: TextStyle( | 267 | style: TextStyle( |
| 254 | - color: MyColours.color_999999, | 268 | + color: widget.from == 'history' |
| 269 | + ? MyColours.color_BFC4D4 | ||
| 270 | + : MyColours.color_999999, | ||
| 255 | fontSize: | 271 | fontSize: |
| 256 | ScreenUtil().setSp(20))), | 272 | ScreenUtil().setSp(20))), |
| 257 | ), | 273 | ), |
| @@ -283,19 +299,29 @@ class _CouponItemFState extends State<CouponItemF> { | @@ -283,19 +299,29 @@ class _CouponItemFState extends State<CouponItemF> { | ||
| 283 | top: ScreenUtil().setWidth(37 * 2), | 299 | top: ScreenUtil().setWidth(37 * 2), |
| 284 | child: widget.showBtn | 300 | child: widget.showBtn |
| 285 | ? RoundButton( | 301 | ? RoundButton( |
| 286 | - width: ScreenUtil().setWidth(32 * 2), | 302 | + width: widget.from == 'history' |
| 303 | + ? ScreenUtil().setWidth(44 * 2) | ||
| 304 | + : ScreenUtil().setWidth(32 * 2), | ||
| 287 | height: ScreenUtil().setWidth(21 * 2), | 305 | height: ScreenUtil().setWidth(21 * 2), |
| 288 | radius: ScreenUtil().setWidth(10), | 306 | radius: ScreenUtil().setWidth(10), |
| 289 | - text: notSelect ? '停用' : '启用', | 307 | + text: widget.from == 'history' |
| 308 | + ? '已过期' | ||
| 309 | + : notSelect | ||
| 310 | + ? '停用' | ||
| 311 | + : '启用', | ||
| 290 | fontSize: 24, | 312 | fontSize: 24, |
| 291 | - textColor: notSelect | ||
| 292 | - ? MyColours.color_438E93 | ||
| 293 | - : MyColours.color_999999, | 313 | + textColor: widget.from == 'history' |
| 314 | + ? MyColours.color_BFC4D4 | ||
| 315 | + : notSelect | ||
| 316 | + ? MyColours.color_438E93 | ||
| 317 | + : MyColours.color_999999, | ||
| 294 | gradientStart: MyColours.color_ffffff, | 318 | gradientStart: MyColours.color_ffffff, |
| 295 | gradientEnd: MyColours.color_ffffff, | 319 | gradientEnd: MyColours.color_ffffff, |
| 296 | - borderColor: notSelect | ||
| 297 | - ? MyColours.color_438E93 | ||
| 298 | - : MyColours.color_999999, | 320 | + borderColor: widget.from == 'history' |
| 321 | + ? MyColours.color_BFC4D4 | ||
| 322 | + : notSelect | ||
| 323 | + ? MyColours.color_438E93 | ||
| 324 | + : MyColours.color_999999, | ||
| 299 | onPressed: widget.onPressedSwich, | 325 | onPressed: widget.onPressedSwich, |
| 300 | ) | 326 | ) |
| 301 | : Container()) | 327 | : Container()) |
| @@ -2,14 +2,13 @@ import 'package:flutter/material.dart'; | @@ -2,14 +2,13 @@ import 'package:flutter/material.dart'; | ||
| 2 | import 'package:flutter_easyrefresh/easy_refresh.dart'; | 2 | import 'package:flutter_easyrefresh/easy_refresh.dart'; |
| 3 | import 'package:flutter_screenutil/screenutil.dart'; | 3 | 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'; | ||
| 6 | -import 'package:one_key/pages/coupon/coupon_item_f.dart'; | 5 | +import 'package:one_key/pages/coupon/coupon_sun_page.dart'; |
| 7 | import 'package:one_key/provider/coupon_provider.dart'; | 6 | import 'package:one_key/provider/coupon_provider.dart'; |
| 7 | +import 'package:one_key/provider/personnel_provider.dart'; | ||
| 8 | import 'package:one_key/provider/user_model.dart'; | 8 | import 'package:one_key/provider/user_model.dart'; |
| 9 | import 'package:one_key/res/colors.dart'; | 9 | import 'package:one_key/res/colors.dart'; |
| 10 | import 'package:one_key/utils/event_bus.dart'; | 10 | import 'package:one_key/utils/event_bus.dart'; |
| 11 | import 'package:one_key/route/navigator_util.dart'; | 11 | import 'package:one_key/route/navigator_util.dart'; |
| 12 | -import 'package:one_key/widgets/page_exception.dart'; | ||
| 13 | import 'package:one_key/widgets/round_button.dart'; | 12 | import 'package:one_key/widgets/round_button.dart'; |
| 14 | import 'package:one_key/widgets/system_app_bar.dart'; | 13 | import 'package:one_key/widgets/system_app_bar.dart'; |
| 15 | import 'package:one_key/widgets/v_empty_view.dart'; | 14 | import 'package:one_key/widgets/v_empty_view.dart'; |
| @@ -32,35 +31,35 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | @@ -32,35 +31,35 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | ||
| 32 | CouponProvider couponProvider; | 31 | CouponProvider couponProvider; |
| 33 | TabController tabController; | 32 | TabController tabController; |
| 34 | 33 | ||
| 35 | - ///获取优惠券列表数据 | ||
| 36 | - _couponNetworkData(int index, {bool isShowLoading = true}) async { | ||
| 37 | - Map<String, String> params = { | ||
| 38 | - "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 39 | - // 'is_time': '0' | ||
| 40 | - "is_type": index.toString() | ||
| 41 | - }; | ||
| 42 | - await couponProvider.getCustomerActivity(context, params, | ||
| 43 | - isShowLoading: isShowLoading); | ||
| 44 | - } | 34 | + // ///获取优惠券列表数据 |
| 35 | + // _couponNetworkData(int index, {bool isShowLoading = true}) async { | ||
| 36 | + // Map<String, String> params = { | ||
| 37 | + // "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 38 | + // // 'is_time': '0' | ||
| 39 | + // "is_type": index.toString() | ||
| 40 | + // }; | ||
| 41 | + // await couponProvider.getCustomerActivity(context, params, | ||
| 42 | + // isShowLoading: isShowLoading); | ||
| 43 | + // } | ||
| 45 | 44 | ||
| 46 | ///修改活动信息 | 45 | ///修改活动信息 |
| 47 | - _setCustomerActivity(int index) async { | ||
| 48 | - Map<String, String> params = { | ||
| 49 | - "id": couponProvider.couponList[index].id, | ||
| 50 | - "status": couponProvider.couponList[index].isOpenBool ? '1' : '0' | ||
| 51 | - }; | ||
| 52 | - bool isSuccess = await couponProvider.setCustomerActivity(context, params, | ||
| 53 | - isShowLoading: false); | ||
| 54 | - print(isSuccess); | ||
| 55 | - _couponNetworkData(tabController.index, isShowLoading: false); | ||
| 56 | - // if (isSuccess) { | ||
| 57 | - // couponProvider.notifyListeners(); | ||
| 58 | - // } else { | ||
| 59 | - // couponProvider.couponList[index].isOpenBool = | ||
| 60 | - // !couponProvider.couponList[index].isOpenBool; | ||
| 61 | - // couponProvider.notifyListeners(); | ||
| 62 | - // } | ||
| 63 | - } | 46 | + // _setCustomerActivity(int index) async { |
| 47 | + // Map<String, String> params = { | ||
| 48 | + // "id": couponProvider.couponList[index].id, | ||
| 49 | + // "status": couponProvider.couponList[index].isOpenBool ? '1' : '0' | ||
| 50 | + // }; | ||
| 51 | + // bool isSuccess = await couponProvider.setCustomerActivity(context, params, | ||
| 52 | + // isShowLoading: false); | ||
| 53 | + // print(isSuccess); | ||
| 54 | + // _couponNetworkData(tabController.index, isShowLoading: false); | ||
| 55 | + // // if (isSuccess) { | ||
| 56 | + // // couponProvider.notifyListeners(); | ||
| 57 | + // // } else { | ||
| 58 | + // // couponProvider.couponList[index].isOpenBool = | ||
| 59 | + // // !couponProvider.couponList[index].isOpenBool; | ||
| 60 | + // // couponProvider.notifyListeners(); | ||
| 61 | + // // } | ||
| 62 | + // } | ||
| 64 | 63 | ||
| 65 | @override | 64 | @override |
| 66 | void initState() { | 65 | void initState() { |
| @@ -68,28 +67,27 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | @@ -68,28 +67,27 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | ||
| 68 | super.initState(); | 67 | super.initState(); |
| 69 | tabController = TabController(length: 3, vsync: this); | 68 | tabController = TabController(length: 3, vsync: this); |
| 70 | tabController.addListener(() { | 69 | tabController.addListener(() { |
| 71 | - couponProvider.couponList = []; | ||
| 72 | - couponProvider.pageState = PageState.Loading; | ||
| 73 | - setState(() {}); | 70 | + // couponProvider.couponList = []; |
| 71 | + // couponProvider.pageState = PageState.Loading; | ||
| 72 | + // setState(() {}); | ||
| 74 | //点击tab时或滑动tab回调一次 | 73 | //点击tab时或滑动tab回调一次 |
| 75 | if (tabController.index.toDouble() == tabController.animation.value) { | 74 | if (tabController.index.toDouble() == tabController.animation.value) { |
| 76 | // couponProvider.notifyListeners(); | 75 | // couponProvider.notifyListeners(); |
| 77 | - _couponNetworkData(tabController.index); | 76 | + // _couponNetworkData(tabController.index); |
| 78 | // selectIndex = tabController.index; | 77 | // selectIndex = tabController.index; |
| 79 | // setState(() {}); | 78 | // setState(() {}); |
| 80 | } | 79 | } |
| 81 | }); | 80 | }); |
| 82 | WidgetsBinding.instance.addPostFrameCallback((_) { | 81 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 83 | - _couponNetworkData(0); | ||
| 84 | - }); | ||
| 85 | - bus.on("refresh_coupon_list_f", (arg) { | ||
| 86 | - _couponNetworkData(tabController.index); | 82 | + // _couponNetworkData(0); |
| 87 | }); | 83 | }); |
| 84 | + // bus.on("refresh_coupon_list_f", (arg) { | ||
| 85 | + // _couponNetworkData(tabController.index); | ||
| 86 | + // }); | ||
| 88 | } | 87 | } |
| 89 | 88 | ||
| 90 | @override | 89 | @override |
| 91 | void dispose() { | 90 | void dispose() { |
| 92 | - bus.off('changeStatusColor'); | ||
| 93 | bus.off("refresh_coupon_list_f"); | 91 | bus.off("refresh_coupon_list_f"); |
| 94 | super.dispose(); | 92 | super.dispose(); |
| 95 | } | 93 | } |
| @@ -99,7 +97,7 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | @@ -99,7 +97,7 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | ||
| 99 | couponProvider = Provider.of<CouponProvider>(context, listen: true); | 97 | couponProvider = Provider.of<CouponProvider>(context, listen: true); |
| 100 | return Scaffold( | 98 | return Scaffold( |
| 101 | backgroundColor: MyColours.color_f3f3f3, | 99 | backgroundColor: MyColours.color_f3f3f3, |
| 102 | - appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () { | 100 | + appBar: SystemAppBar('线上券', onTap: () { |
| 103 | if (widget.needRefrsh) { | 101 | if (widget.needRefrsh) { |
| 104 | EventBus().emit('refresh_coupon_invitation'); | 102 | EventBus().emit('refresh_coupon_invitation'); |
| 105 | } else { | 103 | } else { |
| @@ -107,8 +105,6 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | @@ -107,8 +105,6 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | ||
| 107 | } | 105 | } |
| 108 | 106 | ||
| 109 | Navigator.of(context).pop(); | 107 | Navigator.of(context).pop(); |
| 110 | - }, onTapRight: () { | ||
| 111 | - NavigatorUtil.goCouponHistoryPage(context); | ||
| 112 | }), | 108 | }), |
| 113 | body: WillPopScope( | 109 | body: WillPopScope( |
| 114 | onWillPop: () { | 110 | onWillPop: () { |
| @@ -155,162 +151,20 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | @@ -155,162 +151,20 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | ||
| 155 | )), | 151 | )), |
| 156 | VEmptyView(32), | 152 | VEmptyView(32), |
| 157 | Expanded( | 153 | Expanded( |
| 158 | - child: TabBarView(controller: tabController, children: [ | ||
| 159 | - Consumer<CouponProvider>(builder: (context, model, _) { | ||
| 160 | - if (model.pageState != PageState.Success) { | ||
| 161 | - return ExceptionPage( | ||
| 162 | - pageState: model.pageState, | ||
| 163 | - callback: () { | ||
| 164 | - // offset = 0; | ||
| 165 | - // getMessage(showLoading: true); | ||
| 166 | - _couponNetworkData(tabController.index); | ||
| 167 | - }, | ||
| 168 | - emptyMsg: "暂时没有列表信息哦", | ||
| 169 | - emptyImg: "empty_search", | ||
| 170 | - showMsg: "加载中,请稍后...", | ||
| 171 | - ); | ||
| 172 | - } else { | ||
| 173 | - return EasyRefresh.custom( | ||
| 174 | - controller: _controller, | ||
| 175 | - shrinkWrap: true, | ||
| 176 | - slivers: [ | ||
| 177 | - SliverList( | ||
| 178 | - delegate: SliverChildBuilderDelegate( | ||
| 179 | - (BuildContext context, int index) { | ||
| 180 | - return CouponItemF( | ||
| 181 | - from: 'quan', | ||
| 182 | - couponSonModel: | ||
| 183 | - couponProvider.couponList[index], | ||
| 184 | - showBtn: true, | ||
| 185 | - onPressedSwich: () { | ||
| 186 | - couponProvider.couponList[index].isOpenBool = | ||
| 187 | - !couponProvider | ||
| 188 | - .couponList[index].isOpenBool; | ||
| 189 | - _setCustomerActivity(index); | ||
| 190 | - }, | ||
| 191 | - onPressed: () { | ||
| 192 | - NavigatorUtil.goCouponDetailPage(context, | ||
| 193 | - couponProvider.couponList[index]); | ||
| 194 | - }, | ||
| 195 | - ); | ||
| 196 | - }, childCount: couponProvider.couponList.length), | ||
| 197 | - ) | ||
| 198 | - ], | ||
| 199 | - // onRefresh: () async { | ||
| 200 | - // // offset = 0; | ||
| 201 | - // // getMessage(showLoading: false); | ||
| 202 | - // }, | ||
| 203 | - // onLoad: () async { | ||
| 204 | - // // offset++; | ||
| 205 | - // // getMessage(showLoading: false); | ||
| 206 | - // }, | ||
| 207 | - ); | ||
| 208 | - } | ||
| 209 | - }), | ||
| 210 | - Consumer<CouponProvider>(builder: (context, model, _) { | ||
| 211 | - if (model.pageState != PageState.Success) { | ||
| 212 | - return ExceptionPage( | ||
| 213 | - pageState: model.pageState, | ||
| 214 | - callback: () { | ||
| 215 | - // offset = 0; | ||
| 216 | - // getMessage(showLoading: true); | ||
| 217 | - _couponNetworkData(tabController.index); | ||
| 218 | - }, | ||
| 219 | - emptyMsg: "暂时没有列表信息哦", | ||
| 220 | - emptyImg: "empty_search", | ||
| 221 | - showMsg: "加载中,请稍后...", | ||
| 222 | - ); | ||
| 223 | - } else { | ||
| 224 | - return EasyRefresh.custom( | ||
| 225 | - controller: _controller, | ||
| 226 | - shrinkWrap: true, | ||
| 227 | - slivers: [ | ||
| 228 | - SliverList( | ||
| 229 | - delegate: SliverChildBuilderDelegate( | ||
| 230 | - (BuildContext context, int index) { | ||
| 231 | - return CouponItemF( | ||
| 232 | - from: 'quan', | ||
| 233 | - couponSonModel: | ||
| 234 | - couponProvider.couponList[index], | ||
| 235 | - showBtn: true, | ||
| 236 | - onPressedSwich: () { | ||
| 237 | - couponProvider.couponList[index].isOpenBool = | ||
| 238 | - !couponProvider | ||
| 239 | - .couponList[index].isOpenBool; | ||
| 240 | - _setCustomerActivity(index); | ||
| 241 | - }, | ||
| 242 | - onPressed: () { | ||
| 243 | - NavigatorUtil.goCouponDetailPage(context, | ||
| 244 | - couponProvider.couponList[index]); | ||
| 245 | - }, | ||
| 246 | - ); | ||
| 247 | - }, childCount: couponProvider.couponList.length), | ||
| 248 | - ) | ||
| 249 | - ], | ||
| 250 | - // onRefresh: () async { | ||
| 251 | - // // offset = 0; | ||
| 252 | - // // getMessage(showLoading: false); | ||
| 253 | - // }, | ||
| 254 | - // onLoad: () async { | ||
| 255 | - // // offset++; | ||
| 256 | - // // getMessage(showLoading: false); | ||
| 257 | - // }, | ||
| 258 | - ); | ||
| 259 | - } | ||
| 260 | - }), | ||
| 261 | - Consumer<CouponProvider>(builder: (context, model, _) { | ||
| 262 | - if (model.pageState != PageState.Success) { | ||
| 263 | - return ExceptionPage( | ||
| 264 | - pageState: model.pageState, | ||
| 265 | - callback: () { | ||
| 266 | - // offset = 0; | ||
| 267 | - // getMessage(showLoading: true); | ||
| 268 | - _couponNetworkData(tabController.index); | ||
| 269 | - }, | ||
| 270 | - emptyMsg: "暂时没有列表信息哦", | ||
| 271 | - emptyImg: "empty_search", | ||
| 272 | - showMsg: "加载中,请稍后...", | ||
| 273 | - ); | ||
| 274 | - } else { | ||
| 275 | - return EasyRefresh.custom( | ||
| 276 | - controller: _controller, | ||
| 277 | - shrinkWrap: true, | ||
| 278 | - slivers: [ | ||
| 279 | - SliverList( | ||
| 280 | - delegate: SliverChildBuilderDelegate( | ||
| 281 | - (BuildContext context, int index) { | ||
| 282 | - return CouponItemF( | ||
| 283 | - from: 'quan', | ||
| 284 | - couponSonModel: | ||
| 285 | - couponProvider.couponList[index], | ||
| 286 | - showBtn: true, | ||
| 287 | - onPressedSwich: () { | ||
| 288 | - couponProvider.couponList[index].isOpenBool = | ||
| 289 | - !couponProvider | ||
| 290 | - .couponList[index].isOpenBool; | ||
| 291 | - _setCustomerActivity(index); | ||
| 292 | - }, | ||
| 293 | - onPressed: () { | ||
| 294 | - NavigatorUtil.goCouponDetailPage(context, | ||
| 295 | - couponProvider.couponList[index]); | ||
| 296 | - }, | ||
| 297 | - ); | ||
| 298 | - }, childCount: couponProvider.couponList.length), | ||
| 299 | - ) | ||
| 300 | - ], | ||
| 301 | - // onRefresh: () async { | ||
| 302 | - // // offset = 0; | ||
| 303 | - // // getMessage(showLoading: false); | ||
| 304 | - // }, | ||
| 305 | - // onLoad: () async { | ||
| 306 | - // // offset++; | ||
| 307 | - // // getMessage(showLoading: false); | ||
| 308 | - // }, | ||
| 309 | - ); | ||
| 310 | - } | ||
| 311 | - }), | ||
| 312 | - // MessageOnlineCheckPage() | ||
| 313 | - ]), | 154 | + child: TabBarView( |
| 155 | + controller: tabController, | ||
| 156 | + children: [ | ||
| 157 | + ChangeNotifierProvider<PersonnelProvider>( | ||
| 158 | + create: (_) => PersonnelProvider(), | ||
| 159 | + child: CouponSunPage(index: 0)), | ||
| 160 | + ChangeNotifierProvider<PersonnelProvider>( | ||
| 161 | + create: (_) => PersonnelProvider(), | ||
| 162 | + child: CouponSunPage(index: 1)), | ||
| 163 | + ChangeNotifierProvider<PersonnelProvider>( | ||
| 164 | + create: (_) => PersonnelProvider(), | ||
| 165 | + child: CouponSunPage(index: 2)), | ||
| 166 | + ], | ||
| 167 | + ), | ||
| 314 | ), | 168 | ), |
| 315 | Container( | 169 | Container( |
| 316 | height: ScreenUtil().setWidth(91 * 2), | 170 | height: ScreenUtil().setWidth(91 * 2), |
| @@ -351,9 +205,10 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | @@ -351,9 +205,10 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { | ||
| 351 | await NavigatorUtil.goCouponEditPage(context); | 205 | await NavigatorUtil.goCouponEditPage(context); |
| 352 | print(needRefresh); | 206 | print(needRefresh); |
| 353 | if (needRefresh != null && needRefresh) { | 207 | if (needRefresh != null && needRefresh) { |
| 208 | + bus.emit('refresh_coupon_list_f'); | ||
| 354 | //刷新页面数据 | 209 | //刷新页面数据 |
| 355 | // _controller.callRefresh(); | 210 | // _controller.callRefresh(); |
| 356 | - _couponNetworkData(tabController.index); | 211 | + // _couponNetworkData(tabController.index); |
| 357 | } | 212 | } |
| 358 | } | 213 | } |
| 359 | }, | 214 | }, |
lib/pages/coupon/coupon_sun_page.dart
0 → 100644
| 1 | +import 'package:flutter/material.dart'; | ||
| 2 | +import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 3 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 4 | +import 'package:one_key/constant/state.dart'; | ||
| 5 | +import 'package:one_key/models/personnel_manage_model.dart'; | ||
| 6 | +import 'package:one_key/pages/coupon/coupon_item_f.dart'; | ||
| 7 | +import 'package:one_key/provider/coupon_provider.dart'; | ||
| 8 | +import 'package:one_key/provider/personnel_provider.dart'; | ||
| 9 | +import 'package:one_key/provider/user_model.dart'; | ||
| 10 | +import 'package:one_key/res/colors.dart'; | ||
| 11 | +import 'package:one_key/route/navigator_util.dart'; | ||
| 12 | +import 'package:one_key/utils/event_bus.dart'; | ||
| 13 | +import 'package:one_key/widgets/page_exception.dart'; | ||
| 14 | +import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 15 | +import 'package:provider/provider.dart'; | ||
| 16 | + | ||
| 17 | +class CouponSunPage extends StatefulWidget { | ||
| 18 | + final int index; | ||
| 19 | + CouponSunPage({Key key, this.index}) : super(key: key); | ||
| 20 | + | ||
| 21 | + @override | ||
| 22 | + _CouponSunPageState createState() => _CouponSunPageState(); | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +class _CouponSunPageState extends State<CouponSunPage> { | ||
| 26 | + CouponProvider couponProvider; | ||
| 27 | + EasyRefreshController _controller = EasyRefreshController(); | ||
| 28 | + PersonnelProvider personnelProvider; | ||
| 29 | + List<PersonnelManageSunModel> authUserLists = []; | ||
| 30 | + | ||
| 31 | + @override | ||
| 32 | + void initState() { | ||
| 33 | + // TODO: implement initState | ||
| 34 | + super.initState(); | ||
| 35 | + | ||
| 36 | + WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 37 | + if (widget.index == 0) { | ||
| 38 | + couponProvider.pageState = PageState.Loading; | ||
| 39 | + } else if (widget.index == 1) { | ||
| 40 | + couponProvider.pageStateStore = PageState.Loading; | ||
| 41 | + } else if (widget.index == 2) { | ||
| 42 | + couponProvider.pageStateMine = PageState.Loading; | ||
| 43 | + } | ||
| 44 | + couponProvider.notifyListeners(); | ||
| 45 | + _couponNetworkData(widget.index, isShowLoading: false); | ||
| 46 | + | ||
| 47 | + bus.on("refresh_coupon_list_f", (arg) { | ||
| 48 | + _couponNetworkData(widget.index); | ||
| 49 | + }); | ||
| 50 | + }); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @override | ||
| 54 | + void dispose() { | ||
| 55 | + super.dispose(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + ///获取优惠券列表数据 | ||
| 59 | + _couponNetworkData(int index, {bool isShowLoading = true}) async { | ||
| 60 | + Map<String, String> params = { | ||
| 61 | + "uid": Provider.of<UserModel>(context, listen: false).user.openid, | ||
| 62 | + // 'is_time': '0' | ||
| 63 | + "is_type": index.toString() | ||
| 64 | + }; | ||
| 65 | + await couponProvider.getCustomerActivity(context, params, index, | ||
| 66 | + isShowLoading: isShowLoading); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + ///修改活动信息 | ||
| 70 | + _setCustomerActivity(int index) async { | ||
| 71 | + Map<String, String> params = { | ||
| 72 | + "id": couponProvider.couponList[index].id, | ||
| 73 | + "status": couponProvider.couponList[index].isOpenBool ? '1' : '0', | ||
| 74 | + }; | ||
| 75 | + bool isSuccess = await couponProvider.setCustomerActivity(context, params, | ||
| 76 | + isShowLoading: false); | ||
| 77 | + print(isSuccess); | ||
| 78 | + _couponNetworkData(widget.index, isShowLoading: false); | ||
| 79 | + // if (isSuccess) { | ||
| 80 | + // couponProvider.notifyListeners(); | ||
| 81 | + // } else { | ||
| 82 | + // couponProvider.couponList[index].isOpenBool = | ||
| 83 | + // !couponProvider.couponList[index].isOpenBool; | ||
| 84 | + // couponProvider.notifyListeners(); | ||
| 85 | + // } | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @override | ||
| 89 | + Widget build(BuildContext context) { | ||
| 90 | + couponProvider = Provider.of<CouponProvider>(context, listen: true); | ||
| 91 | + personnelProvider = Provider.of<PersonnelProvider>(context, listen: true); | ||
| 92 | + PageState pageState; | ||
| 93 | + if (widget.index == 0) { | ||
| 94 | + pageState = couponProvider.pageState; | ||
| 95 | + } else if (widget.index == 1) { | ||
| 96 | + pageState = couponProvider.pageStateStore; | ||
| 97 | + } else if (widget.index == 2) { | ||
| 98 | + pageState = couponProvider.pageStateMine; | ||
| 99 | + } | ||
| 100 | + return Container( | ||
| 101 | + child: Consumer<CouponProvider>(builder: (context, model, _) { | ||
| 102 | + if (pageState != PageState.Success) { | ||
| 103 | + return ExceptionPage( | ||
| 104 | + pageState: pageState, | ||
| 105 | + callback: () { | ||
| 106 | + // offset = 0; | ||
| 107 | + // getMessage(showLoading: true); | ||
| 108 | + _couponNetworkData(widget.index); | ||
| 109 | + }, | ||
| 110 | + emptyMsg: "暂时没有列表信息哦,", | ||
| 111 | + emptyImg: "empty_search", | ||
| 112 | + showMsg: "加载中,请稍后...", | ||
| 113 | + needEmpty: true, | ||
| 114 | + ); | ||
| 115 | + } else { | ||
| 116 | + return EasyRefresh.custom( | ||
| 117 | + controller: _controller, | ||
| 118 | + shrinkWrap: true, | ||
| 119 | + slivers: [ | ||
| 120 | + SliverList( | ||
| 121 | + delegate: SliverChildBuilderDelegate( | ||
| 122 | + (BuildContext context, int index) { | ||
| 123 | + return CouponItemF( | ||
| 124 | + from: 'quan', | ||
| 125 | + couponSonModel: couponProvider.couponList[index], | ||
| 126 | + showBtn: true, | ||
| 127 | + onPressedSwich: () { | ||
| 128 | + couponProvider.couponList[index].isOpenBool = | ||
| 129 | + !couponProvider.couponList[index].isOpenBool; | ||
| 130 | + _setCustomerActivity(index); | ||
| 131 | + }, | ||
| 132 | + onPressed: () { | ||
| 133 | + NavigatorUtil.goCouponDetailPage( | ||
| 134 | + context, couponProvider.couponList[index]); | ||
| 135 | + }, | ||
| 136 | + ); | ||
| 137 | + }, childCount: couponProvider.couponList.length), | ||
| 138 | + ), | ||
| 139 | + SliverList( | ||
| 140 | + delegate: SliverChildBuilderDelegate( | ||
| 141 | + (BuildContext context, int index) { | ||
| 142 | + return Column( | ||
| 143 | + children: [ | ||
| 144 | + InkWell( | ||
| 145 | + onTap: () { | ||
| 146 | + NavigatorUtil.goCouponHistoryPage(context); | ||
| 147 | + }, | ||
| 148 | + child: RichText( | ||
| 149 | + text: TextSpan( | ||
| 150 | + style: TextStyle( | ||
| 151 | + fontSize: ScreenUtil().setSp(28), | ||
| 152 | + ), | ||
| 153 | + children: [ | ||
| 154 | + TextSpan( | ||
| 155 | + text: '没有更多了,', | ||
| 156 | + style: TextStyle( | ||
| 157 | + color: MyColours.color_000000)), | ||
| 158 | + TextSpan( | ||
| 159 | + text: '查看过期优惠券', | ||
| 160 | + style: TextStyle( | ||
| 161 | + color: MyColours.color_438E93)), | ||
| 162 | + ]))), | ||
| 163 | + VEmptyView(80) | ||
| 164 | + ], | ||
| 165 | + ); | ||
| 166 | + }, childCount: 1), | ||
| 167 | + ) | ||
| 168 | + ], | ||
| 169 | + // onRefresh: () async { | ||
| 170 | + // // offset = 0; | ||
| 171 | + // // getMessage(showLoading: false); | ||
| 172 | + // }, | ||
| 173 | + // onLoad: () async { | ||
| 174 | + // // offset++; | ||
| 175 | + // // getMessage(showLoading: false); | ||
| 176 | + // }, | ||
| 177 | + ); | ||
| 178 | + } | ||
| 179 | + }), | ||
| 180 | + ); | ||
| 181 | + } | ||
| 182 | +} |
| @@ -764,9 +764,27 @@ class InvicationPageState extends State<InvicationPage> | @@ -764,9 +764,27 @@ class InvicationPageState extends State<InvicationPage> | ||
| 764 | if (couponProvider.couponListSelect.length > 0) { | 764 | if (couponProvider.couponListSelect.length > 0) { |
| 765 | // couponProvider.initCouponSelect(context); | 765 | // couponProvider.initCouponSelect(context); |
| 766 | couponsCan = []; | 766 | couponsCan = []; |
| 767 | + List<CouponSunModel> temp = []; | ||
| 767 | for (int i = 0; i < couponProvider.couponListSelect.length; i++) { | 768 | for (int i = 0; i < couponProvider.couponListSelect.length; i++) { |
| 768 | - couponsCan.add(couponProvider.couponListSelect[i].aname); | 769 | + if (couponProvider.couponListSelect[i].isOpenBool) { |
| 770 | +// 店铺优惠券 | ||
| 771 | + if (couponProvider.couponListSelect[i].isType == '1') { | ||
| 772 | + if (couponProvider.couponListSelect[i].uidList != null) { | ||
| 773 | + List<String> listuids = | ||
| 774 | + couponProvider.couponListSelect[i].uidList.split(','); | ||
| 775 | + if (listuids.contains( | ||
| 776 | + Provider.of<UserModel>(context, listen: false).user.openid)) | ||
| 777 | + couponsCan.add(couponProvider.couponListSelect[i].aname); | ||
| 778 | + temp.add(couponProvider.couponListSelect[i]); | ||
| 779 | + } | ||
| 780 | + } else { | ||
| 781 | + //我的优惠券 | ||
| 782 | + couponsCan.add(couponProvider.couponListSelect[i].aname); | ||
| 783 | + temp.add(couponProvider.couponListSelect[i]); | ||
| 784 | + } | ||
| 785 | + } | ||
| 769 | } | 786 | } |
| 787 | + couponProvider.couponListSelect = temp; | ||
| 770 | //获取绑定的优惠券 | 788 | //获取绑定的优惠券 |
| 771 | _getActivityByRid(); | 789 | _getActivityByRid(); |
| 772 | 790 | ||
| @@ -2119,14 +2137,29 @@ class InvicationPageState extends State<InvicationPage> | @@ -2119,14 +2137,29 @@ class InvicationPageState extends State<InvicationPage> | ||
| 2119 | HEmptyView(40), | 2137 | HEmptyView(40), |
| 2120 | InkWell( | 2138 | InkWell( |
| 2121 | onTap: () async { | 2139 | onTap: () async { |
| 2122 | - // NavigatorUtil.goMarketingRecordsDetailPage(context); | ||
| 2123 | - bool needRefresh = await NavigatorUtil.goCouponEditPage(context); | ||
| 2124 | - print(needRefresh); | ||
| 2125 | - if (needRefresh != null && needRefresh) { | ||
| 2126 | - //刷新页面数据 | ||
| 2127 | - // _controller.callRefresh(); | ||
| 2128 | - _couponNetworkData(); | 2140 | + UserModel userModel = |
| 2141 | + Provider.of<UserModel>(context, listen: false); | ||
| 2142 | + if (userModel.user.role_name == '管理员' || | ||
| 2143 | + userModel.user.role_name == '店长') { | ||
| 2144 | + NavigatorUtil.goCouponCreateSelectTypePage(context); | ||
| 2145 | + } else { | ||
| 2146 | + bool needRefresh = await NavigatorUtil.goCouponEditPage(context); | ||
| 2147 | + print(needRefresh); | ||
| 2148 | + if (needRefresh != null && needRefresh) { | ||
| 2149 | + _couponNetworkData(); | ||
| 2150 | + //刷新页面数据 | ||
| 2151 | + // _controller.callRefresh(); | ||
| 2152 | + // _couponNetworkData(tabController.index); | ||
| 2153 | + } | ||
| 2129 | } | 2154 | } |
| 2155 | + // NavigatorUtil.goMarketingRecordsDetailPage(context); | ||
| 2156 | + // bool needRefresh = await NavigatorUtil.goCouponEditPage(context); | ||
| 2157 | + // print(needRefresh); | ||
| 2158 | + // if (needRefresh != null && needRefresh) { | ||
| 2159 | + // //刷新页面数据 | ||
| 2160 | + // // _controller.callRefresh(); | ||
| 2161 | + // _couponNetworkData(); | ||
| 2162 | + // } | ||
| 2130 | }, | 2163 | }, |
| 2131 | child: Text('创建新优惠', | 2164 | child: Text('创建新优惠', |
| 2132 | style: TextStyle( | 2165 | style: TextStyle( |
| @@ -15,6 +15,8 @@ import 'package:provider/provider.dart'; | @@ -15,6 +15,8 @@ import 'package:provider/provider.dart'; | ||
| 15 | class CouponProvider with ChangeNotifier { | 15 | class CouponProvider with ChangeNotifier { |
| 16 | List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 | 16 | List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 |
| 17 | PageState pageState = PageState.Loading; | 17 | PageState pageState = PageState.Loading; |
| 18 | + PageState pageStateStore = PageState.Loading; | ||
| 19 | + PageState pageStateMine = PageState.Loading; | ||
| 18 | PageState pageStateHistory = PageState.Loading; | 20 | PageState pageStateHistory = PageState.Loading; |
| 19 | PageState pageStateSelect = PageState.Loading; | 21 | PageState pageStateSelect = PageState.Loading; |
| 20 | bool hasModify = false; | 22 | bool hasModify = false; |
| @@ -155,10 +157,18 @@ class CouponProvider with ChangeNotifier { | @@ -155,10 +157,18 @@ class CouponProvider with ChangeNotifier { | ||
| 155 | 157 | ||
| 156 | ///客户经理获取所创建活动列表 | 158 | ///客户经理获取所创建活动列表 |
| 157 | Future<List<CouponSunModel>> getCustomerActivity( | 159 | Future<List<CouponSunModel>> getCustomerActivity( |
| 158 | - BuildContext context, Map<String, String> params, | 160 | + BuildContext context, Map<String, String> params, int index, |
| 159 | {isShowLoading = true}) async { | 161 | {isShowLoading = true}) async { |
| 162 | + PageState state; | ||
| 163 | + if (index == 0) { | ||
| 164 | + state = pageState; | ||
| 165 | + } else if (index == 1) { | ||
| 166 | + state = pageStateStore; | ||
| 167 | + } else if (index == 2) { | ||
| 168 | + state = pageStateMine; | ||
| 169 | + } | ||
| 160 | if (isShowLoading) { | 170 | if (isShowLoading) { |
| 161 | - pageState = PageState.Loading; | 171 | + state = PageState.Loading; |
| 162 | notifyListeners(); | 172 | notifyListeners(); |
| 163 | } | 173 | } |
| 164 | BaseResp<dynamic> baseResp = await DioUtil() | 174 | BaseResp<dynamic> baseResp = await DioUtil() |
| @@ -166,17 +176,18 @@ class CouponProvider with ChangeNotifier { | @@ -166,17 +176,18 @@ class CouponProvider with ChangeNotifier { | ||
| 166 | data: params, showLoading: false) | 176 | data: params, showLoading: false) |
| 167 | .catchError((error) { | 177 | .catchError((error) { |
| 168 | print(error.toString()); | 178 | print(error.toString()); |
| 179 | + | ||
| 169 | if (error is MyError) { | 180 | if (error is MyError) { |
| 170 | if (isShowLoading) { | 181 | if (isShowLoading) { |
| 171 | switch (error.type) { | 182 | switch (error.type) { |
| 172 | case 1: | 183 | case 1: |
| 173 | - pageState = PageState.ConnectivityError; | 184 | + state = PageState.ConnectivityError; |
| 174 | break; | 185 | break; |
| 175 | case 2: | 186 | case 2: |
| 176 | - pageState = PageState.ConnectivityTimeOut; | 187 | + state = PageState.ConnectivityTimeOut; |
| 177 | break; | 188 | break; |
| 178 | default: | 189 | default: |
| 179 | - pageState = PageState.ConnectivityError; | 190 | + state = PageState.ConnectivityError; |
| 180 | break; | 191 | break; |
| 181 | } | 192 | } |
| 182 | } | 193 | } |
| @@ -185,24 +196,32 @@ class CouponProvider with ChangeNotifier { | @@ -185,24 +196,32 @@ class CouponProvider with ChangeNotifier { | ||
| 185 | }); | 196 | }); |
| 186 | if (baseResp.code == Constant.status_success) { | 197 | if (baseResp.code == Constant.status_success) { |
| 187 | if (baseResp.data.isEmpty) { | 198 | if (baseResp.data.isEmpty) { |
| 188 | - if (isShowLoading) { | ||
| 189 | - pageState = PageState.Empty; | ||
| 190 | - } | 199 | + // if (isShowLoading) { |
| 200 | + state = PageState.Empty; | ||
| 201 | + // } | ||
| 191 | } else { | 202 | } else { |
| 192 | - if (isShowLoading) { | ||
| 193 | - pageState = PageState.Success; | ||
| 194 | - } | 203 | + // if (isShowLoading) { |
| 204 | + state = PageState.Success; | ||
| 205 | + // } | ||
| 195 | } | 206 | } |
| 207 | + | ||
| 196 | couponList = CouponModel.fromJson(baseResp.responseData).data; | 208 | couponList = CouponModel.fromJson(baseResp.responseData).data; |
| 197 | - notifyListeners(); | ||
| 198 | } else { | 209 | } else { |
| 199 | if (isShowLoading) { | 210 | if (isShowLoading) { |
| 200 | - pageState = PageState.ConnectivityError; | 211 | + state = PageState.ConnectivityError; |
| 201 | } | 212 | } |
| 202 | if (baseResp != null) { | 213 | if (baseResp != null) { |
| 203 | Utils.showToast(baseResp.msg ?? ""); | 214 | Utils.showToast(baseResp.msg ?? ""); |
| 204 | } | 215 | } |
| 205 | } | 216 | } |
| 217 | + if (index == 0) { | ||
| 218 | + pageState = state; | ||
| 219 | + } else if (index == 1) { | ||
| 220 | + pageStateStore = state; | ||
| 221 | + } else if (index == 2) { | ||
| 222 | + pageStateMine = state; | ||
| 223 | + } | ||
| 224 | + notifyListeners(); | ||
| 206 | return couponList; | 225 | return couponList; |
| 207 | } | 226 | } |
| 208 | 227 |
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | import 'package:one_key/res/colors.dart'; | 3 | import 'package:one_key/res/colors.dart'; |
| 4 | +import 'package:one_key/route/navigator_util.dart'; | ||
| 4 | import 'package:one_key/utils/utils.dart'; | 5 | import 'package:one_key/utils/utils.dart'; |
| 5 | import 'package:one_key/widgets/v_empty_view.dart'; | 6 | import 'package:one_key/widgets/v_empty_view.dart'; |
| 6 | 7 | ||
| @@ -8,12 +9,14 @@ class EmptyPage extends StatefulWidget { | @@ -8,12 +9,14 @@ class EmptyPage extends StatefulWidget { | ||
| 8 | final String content; | 9 | final String content; |
| 9 | final String imgname; | 10 | final String imgname; |
| 10 | final Color bgcolor; | 11 | final Color bgcolor; |
| 12 | + final bool needEmpty; | ||
| 11 | 13 | ||
| 12 | const EmptyPage( | 14 | const EmptyPage( |
| 13 | {Key key, | 15 | {Key key, |
| 14 | this.content, | 16 | this.content, |
| 15 | this.imgname = "bg_error", | 17 | this.imgname = "bg_error", |
| 16 | - this.bgcolor = MyColours.color_ffffff}) | 18 | + this.bgcolor = MyColours.color_ffffff, |
| 19 | + this.needEmpty = false}) | ||
| 17 | : super(key: key); | 20 | : super(key: key); |
| 18 | 21 | ||
| 19 | @override | 22 | @override |
| @@ -46,14 +49,28 @@ class EmptyPageState extends State<EmptyPage> { | @@ -46,14 +49,28 @@ class EmptyPageState extends State<EmptyPage> { | ||
| 46 | height: ScreenUtil().setWidth(384), | 49 | height: ScreenUtil().setWidth(384), |
| 47 | ), | 50 | ), |
| 48 | VEmptyView(40), | 51 | VEmptyView(40), |
| 49 | - Text( | ||
| 50 | - widget.content ?? "数据为空", | ||
| 51 | - textAlign: TextAlign.center, | ||
| 52 | - strutStyle: StrutStyle(leading: ScreenUtil().setWidth(1)), | ||
| 53 | - style: TextStyle( | ||
| 54 | - fontSize: ScreenUtil().setSp(28), | ||
| 55 | - color: MyColours.color_353535), | ||
| 56 | - ) | 52 | + Row(mainAxisAlignment: MainAxisAlignment.center, children: [ |
| 53 | + Text( | ||
| 54 | + widget.content ?? "数据为空", | ||
| 55 | + textAlign: TextAlign.center, | ||
| 56 | + strutStyle: StrutStyle(leading: ScreenUtil().setWidth(1)), | ||
| 57 | + style: TextStyle( | ||
| 58 | + fontSize: ScreenUtil().setSp(28), | ||
| 59 | + color: MyColours.color_353535), | ||
| 60 | + ), | ||
| 61 | + widget.needEmpty | ||
| 62 | + ? InkWell( | ||
| 63 | + onTap: () { | ||
| 64 | + NavigatorUtil.goCouponHistoryPage(context); | ||
| 65 | + }, | ||
| 66 | + child: Text( | ||
| 67 | + '查看过期优惠券', | ||
| 68 | + style: TextStyle( | ||
| 69 | + fontSize: ScreenUtil().setSp(28), | ||
| 70 | + color: MyColours.color_438E93), | ||
| 71 | + )) | ||
| 72 | + : SizedBox() | ||
| 73 | + ]) | ||
| 57 | ], | 74 | ], |
| 58 | ), | 75 | ), |
| 59 | ), | 76 | ), |
| @@ -13,6 +13,7 @@ class ExceptionPage extends StatefulWidget { | @@ -13,6 +13,7 @@ class ExceptionPage extends StatefulWidget { | ||
| 13 | final String emptyImg; | 13 | final String emptyImg; |
| 14 | final String showMsg; | 14 | final String showMsg; |
| 15 | final Color defalutColor; | 15 | final Color defalutColor; |
| 16 | + final bool needEmpty; | ||
| 16 | 17 | ||
| 17 | const ExceptionPage( | 18 | const ExceptionPage( |
| 18 | {Key key, | 19 | {Key key, |
| @@ -21,7 +22,8 @@ class ExceptionPage extends StatefulWidget { | @@ -21,7 +22,8 @@ class ExceptionPage extends StatefulWidget { | ||
| 21 | this.emptyMsg = "数据为空", | 22 | this.emptyMsg = "数据为空", |
| 22 | this.emptyImg = 'bg_error', | 23 | this.emptyImg = 'bg_error', |
| 23 | this.showMsg = '', | 24 | this.showMsg = '', |
| 24 | - this.defalutColor = MyColours.color_ffffff}) | 25 | + this.defalutColor = MyColours.color_ffffff, |
| 26 | + this.needEmpty = false}) | ||
| 25 | : super(key: key); | 27 | : super(key: key); |
| 26 | 28 | ||
| 27 | @override | 29 | @override |
| @@ -60,6 +62,7 @@ class ExceptionPageState extends State<ExceptionPage> { | @@ -60,6 +62,7 @@ class ExceptionPageState extends State<ExceptionPage> { | ||
| 60 | page = EmptyPage( | 62 | page = EmptyPage( |
| 61 | content: widget.emptyMsg, | 63 | content: widget.emptyMsg, |
| 62 | imgname: widget.emptyImg, | 64 | imgname: widget.emptyImg, |
| 65 | + needEmpty: widget.needEmpty, | ||
| 63 | ); | 66 | ); |
| 64 | break; | 67 | break; |
| 65 | case PageState.First: | 68 | case PageState.First: |
-
Please register or login to post a comment