Commit e1c1b79120be89aad068c7868fa56ff92ab77f50

Authored by wdn127929
1 parent c59ff6b9

优惠券OK

... ... @@ -60,11 +60,14 @@ class CouponSunModel extends Object {
@JsonKey(name: 'use_num')
String useNum;
@JsonKey(name: 'nickname')
String nickname;
@JsonKey(name: 'uid_list')
String uidList;
@JsonKey(name: 'is_examine')
String isExamine;
@JsonKey(name: 'is_type')
@JsonKey(name: 'is_type')
String isType;
@JsonKey(name: 'is_open')
... ... @@ -88,6 +91,7 @@ class CouponSunModel extends Object {
this.cdate,
this.receiveNum,
this.useNum,
this.nickname,
this.uidList,
this.isExamine,
this.isType,
... ...
... ... @@ -37,6 +37,7 @@ CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) {
json['cdate'] as String,
json['receive_num'] as String,
json['use_num'] as String,
json['nickname'] as String,
json['uid_list'] as String,
json['is_examine'] as String,
json['is_type'] as String,
... ... @@ -58,6 +59,7 @@ Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) =>
'cdate': instance.cdate,
'receiveNum': instance.receiveNum,
'useNum': instance.useNum,
'nickname': instance.nickname,
'uid_list': instance.uidList,
'is_examine': instance.isExamine,
'is_type': instance.isType,
... ...
... ... @@ -74,7 +74,8 @@ class HttpUrl {
static const String create_customer_activity =
"?service=App.Activity.CreateCustomerActivity"; //客户经理创建活动
static const String get_customer_activity =
"?service=App.Activity.CustomerActivityList"; //获取所创建活动的列表
"?service=App.Activity.NewCustomerActivityList"; //获取所创建活动的列表
static const String set_customer_activity =
"?service=App.Activity.SetCustomerActivity"; //修改所创建活动的列表
static const String set_activity_as_reserve =
... ...
... ... @@ -180,11 +180,12 @@ class _CouponCreateSelectTypePageState
isMine: selectF);
print(needRefresh);
if (needRefresh != null && needRefresh) {
Navigator.pop(context);
//刷新页面数据
// _controller.callRefresh();
// _couponNetworkData();
bus.emit('refresh_coupon_list_f');
}
},
)
... ...
... ... @@ -102,6 +102,8 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
if (isSuccess) {
//成功之后跳回前一个页面
// bus.emit('refresh_coupon_list');
EventBus().emit('refresh_coupon_invitation');
bus.emit('refresh_coupon_list_f');
Navigator.pop(context, true);
}
}
... ... @@ -375,178 +377,185 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
onTap: () {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
},
child: Column(children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
physics: BouncingScrollPhysics(),
child: Padding(
padding: EdgeInsets.only(left: ScreenUtil().setWidth(32)),
child: Column(
children: [
VEmptyView(56),
_item('券类型', widget.isMine ? '我的优惠券' : '店铺优惠券'),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
widget.isMine
? SizedBox()
: _canUse('是否核销', swichHexiao, () {
setState(() {
swichHexiao = !swichHexiao;
});
}),
widget.isMine
? SizedBox()
: Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
widget.isMine ? SizedBox() : VEmptyView(24),
_textfield('券名称', '例:9折券/200元代金券/菜品券'),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_textfield('券要求', '例:无门槛/满2000元'),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_select('有效期从', fromDate, () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
//弹出时间选择器
// showPickerDateTime(context);
showDateSelWidget = true;
DialogUtil.showPickerDateTime24(
context,
scaffoldKey,
(value) {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
setState(() {
print(value);
fromDate = DateUtil.formatDateStr(value,
format: DateFormats.full);
child: Container(
color: MyColours.color_ffffff,
child: Column(children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
physics: BouncingScrollPhysics(),
child: Padding(
padding:
EdgeInsets.only(left: ScreenUtil().setWidth(32)),
child: Column(
children: [
VEmptyView(56),
_item('券类型', widget.isMine ? '我的优惠券' : '店铺优惠券'),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
widget.isMine
? SizedBox()
: _canUse('是否核销', swichHexiao, () {
setState(() {
swichHexiao = !swichHexiao;
});
}),
widget.isMine
? SizedBox()
: Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
widget.isMine ? SizedBox() : VEmptyView(24),
_textfield('券名称', '例:9折券/200元代金券/菜品券'),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_textfield('券要求', '例:无门槛/满2000元'),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_select('有效期从', fromDate, () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
//弹出时间选择器
// showPickerDateTime(context);
showDateSelWidget = true;
DialogUtil.showPickerDateTime24(
context,
scaffoldKey,
(value) {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
setState(() {
print(value);
fromDate = DateUtil.formatDateStr(
value,
format: DateFormats.full);
});
}
showDateSelWidget = false;
},
dateTime: DateUtil.getDateTime(fromDate),
onCancel: () {
showDateSelWidget = false;
});
}
showDateSelWidget = false;
},
dateTime: DateUtil.getDateTime(fromDate),
onCancel: () {
showDateSelWidget = false;
});
}),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_select('有效期至', endDate, () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
//弹出时间选择器
// showPickerDateTime(context);
showDateSelWidget = true;
DialogUtil.showPickerDateTime24(
context,
scaffoldKey,
(value) {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
setState(() {
print(value);
endDate = DateUtil.formatDateStr(value,
format: DateFormats.full);
}),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_select('有效期至', endDate, () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
//弹出时间选择器
// showPickerDateTime(context);
showDateSelWidget = true;
DialogUtil.showPickerDateTime24(
context,
scaffoldKey,
(value) {
// {'text': picker.adapter.text, 'select': selecteds}
if (value != null) {
setState(() {
print(value);
endDate = DateUtil.formatDateStr(
value,
format: DateFormats.full);
});
}
showDateSelWidget = false;
},
dateTime: DateUtil.getDateTime(endDate),
onCancel: () {
showDateSelWidget = false;
});
}
showDateSelWidget = false;
},
dateTime: DateUtil.getDateTime(endDate),
onCancel: () {
showDateSelWidget = false;
}),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
widget.isMine
? SizedBox()
: _select('谁可以发放', '编辑', () async {
Map temp = await NavigatorUtil
.goCouponToPersonnalPage(
context, uids);
if (temp != null &&
temp['object'] != null) {
uids = temp['object'];
}
}),
widget.isMine
? SizedBox()
: Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
widget.isMine ? SizedBox() : VEmptyView(24),
_explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'),
VEmptyView(20),
_canUse('立即启用', swichState, () {
setState(() {
swichState = !swichState;
});
}),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
widget.isMine
? SizedBox()
: _select('谁可以发放', '编辑', () async {
Map temp = await NavigatorUtil
.goCouponToPersonnalPage(context, uids);
if (temp != null && temp['object'] != null) {
uids = temp['object'];
}
}),
widget.isMine
? SizedBox()
: Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
widget.isMine ? SizedBox() : VEmptyView(24),
_explain('券说明', '例:可用包间,停车免费,不与店内其他活动共享等'),
VEmptyView(20),
_canUse('立即启用', swichState, () {
setState(() {
swichState = !swichState;
});
}),
VEmptyView(30),
],
))),
),
VEmptyView(20),
RoundButton(
onPressed: () {
if (_couponNameEditControl.text.trim().length == 0) {
Utils.showToast('请填写券名称');
return;
}
if (_couponRequireEditControl.text.trim().length == 0) {
Utils.showToast('请填写券要求');
return;
}
if (fromDate == '点击选择') {
Utils.showToast('请选择有效期起始时间');
return;
}
if (endDate == '点击选择') {
Utils.showToast('请选择有效期结束时间');
return;
}
if (DateUtil.getDateTime(endDate)
.compareTo(DateUtil.getDateTime(fromDate)) <
0) {
Utils.showToast('有效期结束时间不能早于起始时间');
return;
}
// ***参数***
// _couponNameEditControl.text
// _couponRequireEditControl.text
// fromDate
// endDate
// _couponExplainEditControl.text
// swichState
_createNewCoupon();
},
text: '立即创建',
fontSize: 24,
isBold: false,
height: ScreenUtil().setWidth(37 * 2),
width: ScreenUtil().setWidth(130 * 2),
radius: ScreenUtil().setWidth(22),
),
VEmptyView(32)
])),
}),
VEmptyView(30),
],
))),
),
VEmptyView(20),
RoundButton(
onPressed: () {
if (_couponNameEditControl.text.trim().length == 0) {
Utils.showToast('请填写券名称');
return;
}
if (_couponRequireEditControl.text.trim().length == 0) {
Utils.showToast('请填写券要求');
return;
}
if (fromDate == '点击选择') {
Utils.showToast('请选择有效期起始时间');
return;
}
if (endDate == '点击选择') {
Utils.showToast('请选择有效期结束时间');
return;
}
if (DateUtil.getDateTime(endDate)
.compareTo(DateUtil.getDateTime(fromDate)) <
0) {
Utils.showToast('有效期结束时间不能早于起始时间');
return;
}
// ***参数***
// _couponNameEditControl.text
// _couponRequireEditControl.text
// fromDate
// endDate
// _couponExplainEditControl.text
// swichState
_createNewCoupon();
},
text: '立即创建',
fontSize: 24,
isBold: false,
height: ScreenUtil().setWidth(37 * 2),
width: ScreenUtil().setWidth(130 * 2),
radius: ScreenUtil().setWidth(22),
),
VEmptyView(32)
]))),
);
}
}
... ...
... ... @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/coupon/coupon_item.dart';
import 'package:one_key/pages/coupon/coupon_item_f.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
... ... @@ -49,7 +50,7 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
return Scaffold(
backgroundColor: MyColours.color_fefefe,
appBar: SystemAppBar(
' 历史券',
'过期优惠券',
onTap: () {
Navigator.of(context).pop();
},
... ... @@ -80,13 +81,27 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItem(
// return CouponItem(
// from: 'history',
// couponSonModel: couponProvider.couponListHistory[index],
// onPressed: () {
// // couponProvider.couponListHistory[index] =
// // !couponProvider.couponListHistory[index];
// // couponProvider.notifyListeners();
// },
// );
return CouponItemF(
from: 'history',
couponSonModel: couponProvider.couponListHistory[index],
showBtn: true,
onPressedSwich: () {
// couponProvider.couponList[index].isOpenBool =
// !couponProvider.couponList[index].isOpenBool;
// _setCustomerActivity(index);
},
onPressed: () {
// couponProvider.couponListHistory[index] =
// !couponProvider.couponListHistory[index];
// couponProvider.notifyListeners();
// NavigatorUtil.goCouponDetailPage(
// context, couponProvider.couponList[index]);
},
);
}, childCount: couponProvider.couponListHistory.length),
... ...
... ... @@ -87,11 +87,13 @@ class _CouponItemFState extends State<CouponItemF> {
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(24)),
decoration: BoxDecoration(
color: notSelect
? sunModel.isType == '1'
? MyColours.color_438E93
: MyColours.color_ED7B2F
: MyColours.color_999999,
color: widget.from == 'history'
? MyColours.color_BFC4D4
: notSelect
? sunModel.isType == '1'
? MyColours.color_438E93
: MyColours.color_ED7B2F
: MyColours.color_999999,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(ScreenUtil().setWidth(16)),
topRight:
... ... @@ -115,7 +117,7 @@ class _CouponItemFState extends State<CouponItemF> {
sunModel.isType == '1'
? sunModel.isExamine == '1'
? '被领取:${sunModel.receiveNum}张 已核销:${sunModel.useNum}张'
: '创建人:${sunModel.uid} 被领取:${sunModel.receiveNum}张'
: '创建人:${sunModel.nickname ?? sunModel.uid} 被领取:${sunModel.receiveNum}张'
: '被领取:${sunModel.receiveNum}张',
maxLines: 1,
overflow: TextOverflow.ellipsis,
... ... @@ -146,9 +148,11 @@ class _CouponItemFState extends State<CouponItemF> {
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: notSelect
? MyColours.color_515151
: MyColours.color_999999,
color: widget.from == 'history'
? MyColours.color_BFC4D4
: notSelect
? MyColours.color_515151
: MyColours.color_999999,
fontSize: ScreenUtil().setSp(36),
fontWeight: FontWeight.bold),
),
... ... @@ -160,9 +164,11 @@ class _CouponItemFState extends State<CouponItemF> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: notSelect
? MyColours.color_515151
: MyColours.color_999999,
color: widget.from == 'history'
? MyColours.color_BFC4D4
: notSelect
? MyColours.color_515151
: MyColours.color_999999,
fontSize: ScreenUtil().setSp(20),
)),
),
... ... @@ -175,7 +181,9 @@ class _CouponItemFState extends State<CouponItemF> {
child: Text(
'使用时间:${ObjectUtil.isNotEmpty(sunModel.stime) ? Utils.getDateStrFromJiekou(sunModel.stime) : '--'} 至 ${ObjectUtil.isNotEmpty(sunModel.etime) ? Utils.getDateStrFromJiekou(sunModel.etime) : '--'}',
style: TextStyle(
color: MyColours.color_999999,
color: widget.from == 'history'
? MyColours.color_BFC4D4
: MyColours.color_999999,
fontSize: ScreenUtil().setSp(20))),
)
: Container(),
... ... @@ -196,7 +204,9 @@ class _CouponItemFState extends State<CouponItemF> {
// : Container()
// :
),
const MySeparator(width: 3, color: MyColours.color_f3f3f3),
ObjectUtil.isNotEmpty(sunModel.explain)
? const MySeparator(width: 3, color: MyColours.color_f3f3f3)
: SizedBox(),
ObjectUtil.isNotEmpty(sunModel.explain)
? InkWell(
onTap: () {
... ... @@ -210,9 +220,11 @@ class _CouponItemFState extends State<CouponItemF> {
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: notSelect
color: widget.from == 'history'
? MyColours.color_ffffff
: MyColours.color_FAFAFA,
: notSelect
? MyColours.color_ffffff
: MyColours.color_FAFAFA,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(
ScreenUtil().setWidth(20)),
... ... @@ -233,7 +245,9 @@ class _CouponItemFState extends State<CouponItemF> {
child: Text('说明:${sunModel.explain}',
maxLines: 5,
style: TextStyle(
color: MyColours.color_999999,
color: widget.from == 'history'
? MyColours.color_BFC4D4
: MyColours.color_999999,
fontSize:
ScreenUtil().setSp(20))),
)
... ... @@ -251,7 +265,9 @@ class _CouponItemFState extends State<CouponItemF> {
overflow: TextOverflow.fade,
softWrap: false,
style: TextStyle(
color: MyColours.color_999999,
color: widget.from == 'history'
? MyColours.color_BFC4D4
: MyColours.color_999999,
fontSize:
ScreenUtil().setSp(20))),
),
... ... @@ -283,19 +299,29 @@ class _CouponItemFState extends State<CouponItemF> {
top: ScreenUtil().setWidth(37 * 2),
child: widget.showBtn
? RoundButton(
width: ScreenUtil().setWidth(32 * 2),
width: widget.from == 'history'
? ScreenUtil().setWidth(44 * 2)
: ScreenUtil().setWidth(32 * 2),
height: ScreenUtil().setWidth(21 * 2),
radius: ScreenUtil().setWidth(10),
text: notSelect ? '停用' : '启用',
text: widget.from == 'history'
? '已过期'
: notSelect
? '停用'
: '启用',
fontSize: 24,
textColor: notSelect
? MyColours.color_438E93
: MyColours.color_999999,
textColor: widget.from == 'history'
? MyColours.color_BFC4D4
: notSelect
? MyColours.color_438E93
: MyColours.color_999999,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: notSelect
? MyColours.color_438E93
: MyColours.color_999999,
borderColor: widget.from == 'history'
? MyColours.color_BFC4D4
: notSelect
? MyColours.color_438E93
: MyColours.color_999999,
onPressed: widget.onPressedSwich,
)
: Container())
... ...
... ... @@ -2,14 +2,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/pages/coupon/coupon_item.dart';
import 'package:one_key/pages/coupon/coupon_item_f.dart';
import 'package:one_key/pages/coupon/coupon_sun_page.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/personnel_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
... ... @@ -32,35 +31,35 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
CouponProvider couponProvider;
TabController tabController;
///获取优惠券列表数据
_couponNetworkData(int index, {bool isShowLoading = true}) async {
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
// 'is_time': '0'
"is_type": index.toString()
};
await couponProvider.getCustomerActivity(context, params,
isShowLoading: isShowLoading);
}
// ///获取优惠券列表数据
// _couponNetworkData(int index, {bool isShowLoading = true}) async {
// Map<String, String> params = {
// "uid": Provider.of<UserModel>(context, listen: false).user.openid,
// // 'is_time': '0'
// "is_type": index.toString()
// };
// await couponProvider.getCustomerActivity(context, params,
// isShowLoading: isShowLoading);
// }
///修改活动信息
_setCustomerActivity(int index) async {
Map<String, String> params = {
"id": couponProvider.couponList[index].id,
"status": couponProvider.couponList[index].isOpenBool ? '1' : '0'
};
bool isSuccess = await couponProvider.setCustomerActivity(context, params,
isShowLoading: false);
print(isSuccess);
_couponNetworkData(tabController.index, isShowLoading: false);
// if (isSuccess) {
// couponProvider.notifyListeners();
// } else {
// couponProvider.couponList[index].isOpenBool =
// !couponProvider.couponList[index].isOpenBool;
// couponProvider.notifyListeners();
// }
}
// _setCustomerActivity(int index) async {
// Map<String, String> params = {
// "id": couponProvider.couponList[index].id,
// "status": couponProvider.couponList[index].isOpenBool ? '1' : '0'
// };
// bool isSuccess = await couponProvider.setCustomerActivity(context, params,
// isShowLoading: false);
// print(isSuccess);
// _couponNetworkData(tabController.index, isShowLoading: false);
// // if (isSuccess) {
// // couponProvider.notifyListeners();
// // } else {
// // couponProvider.couponList[index].isOpenBool =
// // !couponProvider.couponList[index].isOpenBool;
// // couponProvider.notifyListeners();
// // }
// }
@override
void initState() {
... ... @@ -68,28 +67,27 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
super.initState();
tabController = TabController(length: 3, vsync: this);
tabController.addListener(() {
couponProvider.couponList = [];
couponProvider.pageState = PageState.Loading;
setState(() {});
// couponProvider.couponList = [];
// couponProvider.pageState = PageState.Loading;
// setState(() {});
//点击tab时或滑动tab回调一次
if (tabController.index.toDouble() == tabController.animation.value) {
// couponProvider.notifyListeners();
_couponNetworkData(tabController.index);
// _couponNetworkData(tabController.index);
// selectIndex = tabController.index;
// setState(() {});
}
});
WidgetsBinding.instance.addPostFrameCallback((_) {
_couponNetworkData(0);
});
bus.on("refresh_coupon_list_f", (arg) {
_couponNetworkData(tabController.index);
// _couponNetworkData(0);
});
// bus.on("refresh_coupon_list_f", (arg) {
// _couponNetworkData(tabController.index);
// });
}
@override
void dispose() {
bus.off('changeStatusColor');
bus.off("refresh_coupon_list_f");
super.dispose();
}
... ... @@ -99,7 +97,7 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_f3f3f3,
appBar: SystemAppBar('线上券', rightImgName: '历史券', onTap: () {
appBar: SystemAppBar('线上券', onTap: () {
if (widget.needRefrsh) {
EventBus().emit('refresh_coupon_invitation');
} else {
... ... @@ -107,8 +105,6 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
}
Navigator.of(context).pop();
}, onTapRight: () {
NavigatorUtil.goCouponHistoryPage(context);
}),
body: WillPopScope(
onWillPop: () {
... ... @@ -155,162 +151,20 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
)),
VEmptyView(32),
Expanded(
child: TabBarView(controller: tabController, children: [
Consumer<CouponProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
_couponNetworkData(tabController.index);
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItemF(
from: 'quan',
couponSonModel:
couponProvider.couponList[index],
showBtn: true,
onPressedSwich: () {
couponProvider.couponList[index].isOpenBool =
!couponProvider
.couponList[index].isOpenBool;
_setCustomerActivity(index);
},
onPressed: () {
NavigatorUtil.goCouponDetailPage(context,
couponProvider.couponList[index]);
},
);
}, childCount: couponProvider.couponList.length),
)
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
}),
Consumer<CouponProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
_couponNetworkData(tabController.index);
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItemF(
from: 'quan',
couponSonModel:
couponProvider.couponList[index],
showBtn: true,
onPressedSwich: () {
couponProvider.couponList[index].isOpenBool =
!couponProvider
.couponList[index].isOpenBool;
_setCustomerActivity(index);
},
onPressed: () {
NavigatorUtil.goCouponDetailPage(context,
couponProvider.couponList[index]);
},
);
}, childCount: couponProvider.couponList.length),
)
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
}),
Consumer<CouponProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
_couponNetworkData(tabController.index);
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItemF(
from: 'quan',
couponSonModel:
couponProvider.couponList[index],
showBtn: true,
onPressedSwich: () {
couponProvider.couponList[index].isOpenBool =
!couponProvider
.couponList[index].isOpenBool;
_setCustomerActivity(index);
},
onPressed: () {
NavigatorUtil.goCouponDetailPage(context,
couponProvider.couponList[index]);
},
);
}, childCount: couponProvider.couponList.length),
)
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
}),
// MessageOnlineCheckPage()
]),
child: TabBarView(
controller: tabController,
children: [
ChangeNotifierProvider<PersonnelProvider>(
create: (_) => PersonnelProvider(),
child: CouponSunPage(index: 0)),
ChangeNotifierProvider<PersonnelProvider>(
create: (_) => PersonnelProvider(),
child: CouponSunPage(index: 1)),
ChangeNotifierProvider<PersonnelProvider>(
create: (_) => PersonnelProvider(),
child: CouponSunPage(index: 2)),
],
),
),
Container(
height: ScreenUtil().setWidth(91 * 2),
... ... @@ -351,9 +205,10 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
await NavigatorUtil.goCouponEditPage(context);
print(needRefresh);
if (needRefresh != null && needRefresh) {
bus.emit('refresh_coupon_list_f');
//刷新页面数据
// _controller.callRefresh();
_couponNetworkData(tabController.index);
// _couponNetworkData(tabController.index);
}
}
},
... ...
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/personnel_manage_model.dart';
import 'package:one_key/pages/coupon/coupon_item_f.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/personnel_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
class CouponSunPage extends StatefulWidget {
final int index;
CouponSunPage({Key key, this.index}) : super(key: key);
@override
_CouponSunPageState createState() => _CouponSunPageState();
}
class _CouponSunPageState extends State<CouponSunPage> {
CouponProvider couponProvider;
EasyRefreshController _controller = EasyRefreshController();
PersonnelProvider personnelProvider;
List<PersonnelManageSunModel> authUserLists = [];
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.index == 0) {
couponProvider.pageState = PageState.Loading;
} else if (widget.index == 1) {
couponProvider.pageStateStore = PageState.Loading;
} else if (widget.index == 2) {
couponProvider.pageStateMine = PageState.Loading;
}
couponProvider.notifyListeners();
_couponNetworkData(widget.index, isShowLoading: false);
bus.on("refresh_coupon_list_f", (arg) {
_couponNetworkData(widget.index);
});
});
}
@override
void dispose() {
super.dispose();
}
///获取优惠券列表数据
_couponNetworkData(int index, {bool isShowLoading = true}) async {
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
// 'is_time': '0'
"is_type": index.toString()
};
await couponProvider.getCustomerActivity(context, params, index,
isShowLoading: isShowLoading);
}
///修改活动信息
_setCustomerActivity(int index) async {
Map<String, String> params = {
"id": couponProvider.couponList[index].id,
"status": couponProvider.couponList[index].isOpenBool ? '1' : '0',
};
bool isSuccess = await couponProvider.setCustomerActivity(context, params,
isShowLoading: false);
print(isSuccess);
_couponNetworkData(widget.index, isShowLoading: false);
// if (isSuccess) {
// couponProvider.notifyListeners();
// } else {
// couponProvider.couponList[index].isOpenBool =
// !couponProvider.couponList[index].isOpenBool;
// couponProvider.notifyListeners();
// }
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
personnelProvider = Provider.of<PersonnelProvider>(context, listen: true);
PageState pageState;
if (widget.index == 0) {
pageState = couponProvider.pageState;
} else if (widget.index == 1) {
pageState = couponProvider.pageStateStore;
} else if (widget.index == 2) {
pageState = couponProvider.pageStateMine;
}
return Container(
child: Consumer<CouponProvider>(builder: (context, model, _) {
if (pageState != PageState.Success) {
return ExceptionPage(
pageState: pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
_couponNetworkData(widget.index);
},
emptyMsg: "暂时没有列表信息哦,",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
needEmpty: true,
);
} else {
return EasyRefresh.custom(
controller: _controller,
shrinkWrap: true,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItemF(
from: 'quan',
couponSonModel: couponProvider.couponList[index],
showBtn: true,
onPressedSwich: () {
couponProvider.couponList[index].isOpenBool =
!couponProvider.couponList[index].isOpenBool;
_setCustomerActivity(index);
},
onPressed: () {
NavigatorUtil.goCouponDetailPage(
context, couponProvider.couponList[index]);
},
);
}, childCount: couponProvider.couponList.length),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Column(
children: [
InkWell(
onTap: () {
NavigatorUtil.goCouponHistoryPage(context);
},
child: RichText(
text: TextSpan(
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
),
children: [
TextSpan(
text: '没有更多了,',
style: TextStyle(
color: MyColours.color_000000)),
TextSpan(
text: '查看过期优惠券',
style: TextStyle(
color: MyColours.color_438E93)),
]))),
VEmptyView(80)
],
);
}, childCount: 1),
)
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
}),
);
}
}
... ...
... ... @@ -764,9 +764,27 @@ class InvicationPageState extends State<InvicationPage>
if (couponProvider.couponListSelect.length > 0) {
// couponProvider.initCouponSelect(context);
couponsCan = [];
List<CouponSunModel> temp = [];
for (int i = 0; i < couponProvider.couponListSelect.length; i++) {
couponsCan.add(couponProvider.couponListSelect[i].aname);
if (couponProvider.couponListSelect[i].isOpenBool) {
// 店铺优惠券
if (couponProvider.couponListSelect[i].isType == '1') {
if (couponProvider.couponListSelect[i].uidList != null) {
List<String> listuids =
couponProvider.couponListSelect[i].uidList.split(',');
if (listuids.contains(
Provider.of<UserModel>(context, listen: false).user.openid))
couponsCan.add(couponProvider.couponListSelect[i].aname);
temp.add(couponProvider.couponListSelect[i]);
}
} else {
//我的优惠券
couponsCan.add(couponProvider.couponListSelect[i].aname);
temp.add(couponProvider.couponListSelect[i]);
}
}
}
couponProvider.couponListSelect = temp;
//获取绑定的优惠券
_getActivityByRid();
... ... @@ -2119,14 +2137,29 @@ class InvicationPageState extends State<InvicationPage>
HEmptyView(40),
InkWell(
onTap: () async {
// NavigatorUtil.goMarketingRecordsDetailPage(context);
bool needRefresh = await NavigatorUtil.goCouponEditPage(context);
print(needRefresh);
if (needRefresh != null && needRefresh) {
//刷新页面数据
// _controller.callRefresh();
_couponNetworkData();
UserModel userModel =
Provider.of<UserModel>(context, listen: false);
if (userModel.user.role_name == '管理员' ||
userModel.user.role_name == '店长') {
NavigatorUtil.goCouponCreateSelectTypePage(context);
} else {
bool needRefresh = await NavigatorUtil.goCouponEditPage(context);
print(needRefresh);
if (needRefresh != null && needRefresh) {
_couponNetworkData();
//刷新页面数据
// _controller.callRefresh();
// _couponNetworkData(tabController.index);
}
}
// NavigatorUtil.goMarketingRecordsDetailPage(context);
// bool needRefresh = await NavigatorUtil.goCouponEditPage(context);
// print(needRefresh);
// if (needRefresh != null && needRefresh) {
// //刷新页面数据
// // _controller.callRefresh();
// _couponNetworkData();
// }
},
child: Text('创建新优惠',
style: TextStyle(
... ...
... ... @@ -15,6 +15,8 @@ import 'package:provider/provider.dart';
class CouponProvider with ChangeNotifier {
List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用
PageState pageState = PageState.Loading;
PageState pageStateStore = PageState.Loading;
PageState pageStateMine = PageState.Loading;
PageState pageStateHistory = PageState.Loading;
PageState pageStateSelect = PageState.Loading;
bool hasModify = false;
... ... @@ -155,10 +157,18 @@ class CouponProvider with ChangeNotifier {
///客户经理获取所创建活动列表
Future<List<CouponSunModel>> getCustomerActivity(
BuildContext context, Map<String, String> params,
BuildContext context, Map<String, String> params, int index,
{isShowLoading = true}) async {
PageState state;
if (index == 0) {
state = pageState;
} else if (index == 1) {
state = pageStateStore;
} else if (index == 2) {
state = pageStateMine;
}
if (isShowLoading) {
pageState = PageState.Loading;
state = PageState.Loading;
notifyListeners();
}
BaseResp<dynamic> baseResp = await DioUtil()
... ... @@ -166,17 +176,18 @@ class CouponProvider with ChangeNotifier {
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
if (isShowLoading) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
state = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
state = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
state = PageState.ConnectivityError;
break;
}
}
... ... @@ -185,24 +196,32 @@ class CouponProvider with ChangeNotifier {
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
if (isShowLoading) {
pageState = PageState.Empty;
}
// if (isShowLoading) {
state = PageState.Empty;
// }
} else {
if (isShowLoading) {
pageState = PageState.Success;
}
// if (isShowLoading) {
state = PageState.Success;
// }
}
couponList = CouponModel.fromJson(baseResp.responseData).data;
notifyListeners();
} else {
if (isShowLoading) {
pageState = PageState.ConnectivityError;
state = PageState.ConnectivityError;
}
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
if (index == 0) {
pageState = state;
} else if (index == 1) {
pageStateStore = state;
} else if (index == 2) {
pageStateMine = state;
}
notifyListeners();
return couponList;
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/v_empty_view.dart';
... ... @@ -8,12 +9,14 @@ class EmptyPage extends StatefulWidget {
final String content;
final String imgname;
final Color bgcolor;
final bool needEmpty;
const EmptyPage(
{Key key,
this.content,
this.imgname = "bg_error",
this.bgcolor = MyColours.color_ffffff})
this.bgcolor = MyColours.color_ffffff,
this.needEmpty = false})
: super(key: key);
@override
... ... @@ -46,14 +49,28 @@ class EmptyPageState extends State<EmptyPage> {
height: ScreenUtil().setWidth(384),
),
VEmptyView(40),
Text(
widget.content ?? "数据为空",
textAlign: TextAlign.center,
strutStyle: StrutStyle(leading: ScreenUtil().setWidth(1)),
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_353535),
)
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Text(
widget.content ?? "数据为空",
textAlign: TextAlign.center,
strutStyle: StrutStyle(leading: ScreenUtil().setWidth(1)),
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_353535),
),
widget.needEmpty
? InkWell(
onTap: () {
NavigatorUtil.goCouponHistoryPage(context);
},
child: Text(
'查看过期优惠券',
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
color: MyColours.color_438E93),
))
: SizedBox()
])
],
),
),
... ...
... ... @@ -13,6 +13,7 @@ class ExceptionPage extends StatefulWidget {
final String emptyImg;
final String showMsg;
final Color defalutColor;
final bool needEmpty;
const ExceptionPage(
{Key key,
... ... @@ -21,7 +22,8 @@ class ExceptionPage extends StatefulWidget {
this.emptyMsg = "数据为空",
this.emptyImg = 'bg_error',
this.showMsg = '',
this.defalutColor = MyColours.color_ffffff})
this.defalutColor = MyColours.color_ffffff,
this.needEmpty = false})
: super(key: key);
@override
... ... @@ -60,6 +62,7 @@ class ExceptionPageState extends State<ExceptionPage> {
page = EmptyPage(
content: widget.emptyMsg,
imgname: widget.emptyImg,
needEmpty: widget.needEmpty,
);
break;
case PageState.First:
... ...