|
...
|
...
|
@@ -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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
...
|
...
|
|