Commit 9dba4148d19201da8a42920cf74af88c6f8f237a

Authored by wdn127929
1 parent b7b51325

优惠券

import 'package:json_annotation/json_annotation.dart';
part 'coupon_model.g.dart';
@JsonSerializable()
class CouponModel extends Object {
@JsonKey(name: 'ret')
int ret;
@JsonKey(name: 'data')
List<CouponSunModel> data;
@JsonKey(name: 'msg')
String msg;
CouponModel(
this.ret,
this.data,
this.msg,
);
factory CouponModel.fromJson(Map<String, dynamic> srcJson) =>
_$CouponModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$CouponModelToJson(this);
}
@JsonSerializable()
class CouponSunModel extends Object {
@JsonKey(name: 'id')
String id;
@JsonKey(name: 'uid')
String uid;
@JsonKey(name: 'aname')
String aname;
@JsonKey(name: 'desc')
String desc;
@JsonKey(name: 'stime')
String stime;
@JsonKey(name: 'etime')
String etime;
@JsonKey(name: 'explain')
String explain;
@JsonKey(name: 'status')
String status;
@JsonKey(name: 'cdate')
String cdate;
@JsonKey(name: 'receive_num')
String receiveNum;
@JsonKey(name: 'use_num')
String useNum;
@JsonKey(name: 'is_open')
String isOpen;
@JsonKey(name: 'is_open')
bool isOpenBool = false;
bool isCheck = false;
CouponSunModel(
this.id,
this.uid,
this.aname,
this.desc,
this.stime,
this.etime,
this.explain,
this.status,
this.cdate,
this.receiveNum,
this.useNum,
this.isOpen,
this.isOpenBool);
factory CouponSunModel.fromJson(Map<String, dynamic> srcJson) =>
_$CouponSunModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$CouponSunModelToJson(this);
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'coupon_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CouponModel _$CouponModelFromJson(Map<String, dynamic> json) {
return CouponModel(
json['ret'] as int,
(json['data'] as List)
?.map((e) => e == null
? null
: CouponSunModel.fromJson(e as Map<String, dynamic>))
?.toList(),
json['msg'] as String);
}
Map<String, dynamic> _$CouponModelToJson(CouponModel instance) =>
<String, dynamic>{
'ret': instance.ret,
'data': instance.data,
'msg': instance.msg
};
CouponSunModel _$CouponSunModelFromJson(Map<String, dynamic> json) {
return CouponSunModel(
json['id'] as String,
json['uid'] as String,
json['aname'] as String,
json['desc'] as String,
json['stime'] as String,
json['etime'] as String,
json['explain'] as String,
json['status'] as String,
json['cdate'] as String,
json['receive_num'] as String,
json['use_num'] as String,
json['is_open'] as String,
json['status'] == "1" ? true : false,
);
}
Map<String, dynamic> _$CouponSunModelToJson(CouponSunModel instance) =>
<String, dynamic>{
'id': instance.id,
'uid': instance.uid,
'aname': instance.aname,
'desc': instance.desc,
'stime': instance.stime,
'etime': instance.etime,
'explain': instance.explain,
'status': instance.status,
'cdate': instance.cdate,
'receiveNum': instance.receiveNum,
'useNum': instance.useNum,
'isOpen': instance.isOpen,
'isOpenBool': instance.isOpenBool
};
... ...
... ... @@ -179,7 +179,7 @@ class DioUtil {
bool showLoading = true}) async {
bool connectivity = await Utils.checkConnectiviy();
if (!connectivity) {
// Utils.showToast("网络错误,请稍后重试");
Utils.showToast("网络错误,请稍后重试");
throw MyError(type: 1);
}
if (showLoading) Loading.showLoading(context);
... ...
... ... @@ -71,5 +71,15 @@ class HttpUrl {
"?service=App.Customer.UpdateOrderInfo"; // 商家确认账单
static const String new_get_reserve_list =
"?service=App.Reserve.NewGetReserveList"; //商家预订本列表【2019-11-26】
static const String create_customer_activity =
"?service=App.Activity.CreateCustomerActivity"; //客户经理创建活动
static const String get_customer_activity =
"?service=App.Activity.CustomerActivityList"; //获取所创建活动的列表
static const String set_customer_activity =
"?service=App.Activity.SetCustomerActivity"; //修改所创建活动的列表
static const String set_activity_as_reserve =
"?service=App.Activity.SetActivityAsReserve"; //设置预定绑定活动ID
static const String get_activity_by_rid =
"?service=App.Activity.GetActivityByRid"; //获取预定绑定活动
}
... ...
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.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';
import 'package:provider/provider.dart';
/**
* 新建券
*/
class CouponDetailPage extends StatefulWidget {
final CouponSunModel couponSunModel;
CouponDetailPage({Key key, this.couponSunModel}) : super(key: key);
@override
_CouponDetailPageState createState() => _CouponDetailPageState();
}
class _CouponDetailPageState extends State<CouponDetailPage> {
ScrollController controller = ScrollController();
final heightCell = ScreenUtil().setWidth(80);
CouponProvider couponProvider;
@override
void initState() {
super.initState();
}
///输入框
Widget _item(String title, String subTitle) {
return Container(
constraints: BoxConstraints(minHeight: heightCell),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: Text(
title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(30)),
),
),
HEmptyView(60),
Expanded(
child: Text(
subTitle,
maxLines: 20,
textAlign: TextAlign.right,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(26),
),
))
],
),
);
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
appBar: SystemAppBar(
'券详情',
onTap: () {
Navigator.pop(context);
},
),
body: Column(children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
physics: BouncingScrollPhysics(),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Column(
children: [
VEmptyView(20),
_item('券名称', widget.couponSunModel.aname),
VEmptyView(5),
_item('券要求', widget.couponSunModel.desc),
VEmptyView(5),
_item(
'有效期从',
Utils.getDateStrFromJiekou(
widget.couponSunModel.stime)),
VEmptyView(5),
_item(
'有效期至',
Utils.getDateStrFromJiekou(
widget.couponSunModel.etime)),
widget.couponSunModel.explain != null ||
widget.couponSunModel.explain != ''
? VEmptyView(5)
: Container(),
widget.couponSunModel.explain != null &&
widget.couponSunModel.explain != ''
? _item('券说明', widget.couponSunModel.explain)
: Container(),
VEmptyView(5),
_item('券状态',
widget.couponSunModel.status == '1' ? '启用' : '停用')
],
))),
)
]),
);
}
}
... ...
... ... @@ -3,14 +3,18 @@ import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.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';
import 'package:provider/provider.dart';
/**
* 新建券
... ... @@ -36,6 +40,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
FocusNode _nameFocusNode = FocusNode();
FocusNode _requireFocusNode = FocusNode();
bool showDateSelWidget = false;
CouponProvider couponProvider;
@override
void initState() {
... ... @@ -66,6 +71,32 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
});
}
//创建新券 客户经理创建活动
_createNewCoupon() async {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
"aname": _couponNameEditControl.text.trim(),
"desc": _couponRequireEditControl.text.trim(),
"stime": fromDate == '点击选择'
? ""
: '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',
"etime": endDate == '点击选择'
? ''
: '${DateUtil.getDateMsByTimeStr(endDate) / 1000}',
"explain": _couponExplainEditControl.text,
"is_open": swichState ? "1" : "0",
"status": swichState ? "1" : "0"
};
bool isSuccess =
await couponProvider.createCustomerActivity(context, params);
if (isSuccess) {
//成功之后跳回前一个页面
// bus.emit('refresh_coupon_list');
Navigator.pop(context, true);
}
}
///输入框
Widget _textfield(String title, String hintText) {
return Container(
... ... @@ -284,6 +315,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
key: scaffoldKey,
appBar: SystemAppBar(
... ... @@ -338,10 +370,6 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
Utils.showToast('请选择有效期结束时间');
return;
}
if (_couponExplainEditControl.text.trim().length == 0) {
Utils.showToast('请填写券说明');
return;
}
if (DateUtil.getDateTime(endDate)
.compareTo(DateUtil.getDateTime(fromDate)) <
0) {
... ... @@ -355,9 +383,7 @@ class _CouponEidtPageState extends State<CouponEidtPage> {
// endDate
// _couponExplainEditControl.text
// swichState
//成功之后跳回前一个页面
Navigator.pop(context, true);
_createNewCoupon();
},
text: '保存',
fontSize: 34,
... ...
... ... @@ -3,6 +3,7 @@ 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/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
... ... @@ -21,12 +22,14 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
EasyRefreshController _controller = EasyRefreshController();
CouponProvider couponProvider;
///获取优惠券列表数据
_couponNetworkData() {
return Future.delayed(Duration(seconds: 1), () {
couponProvider.pageStateHistory = PageState.Success;
couponProvider.notifyListeners();
});
///获取优惠券历史列表数据
_couponNetworkData({bool isShowLoading = true}) async {
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
'is_time': '1'
};
await couponProvider.getCustomerHistoryActivity(context, params,
isShowLoading: isShowLoading);
}
@override
... ... @@ -69,25 +72,25 @@ class _CouponHistoryPageState extends State<CouponHistoryPage> {
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItem(
index: index,
couponProvider: couponProvider,
from: 'history',
couponSonModel: couponProvider.couponListHistory[index],
onPressed: () {
couponProvider.swichStateData[index] =
!couponProvider.swichStateData[index];
couponProvider.notifyListeners();
// couponProvider.couponListHistory[index] =
// !couponProvider.couponListHistory[index];
// couponProvider.notifyListeners();
},
);
}, childCount: couponProvider.swichStateData.length),
}, childCount: couponProvider.couponListHistory.length),
)
],
onRefresh: () async {
// offset = 0;
// getMessage(showLoading: false);
},
onLoad: () async {
// offset++;
// getMessage(showLoading: false);
},
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
},
... ...
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class CouponItem extends StatefulWidget {
final int index;
final String from;
final VoidCallback onPressed;
final CouponProvider couponProvider;
final VoidCallback onPressedSwich;
final CouponSunModel couponSonModel;
final bool showBtn;
CouponItem(
{Key key,
this.index,
this.from,
this.onPressed,
this.couponProvider,
this.onPressedSwich,
this.couponSonModel,
this.showBtn = false})
: super(key: key);
... ... @@ -26,101 +31,141 @@ class CouponItem extends StatefulWidget {
class _CouponItemState extends State<CouponItem> {
@override
Widget build(BuildContext context) {
bool switchState = widget.couponProvider.swichStateData[widget.index];
return Stack(
children: [
Container(
// width: ScreenUtil().setWidth(610),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30),
vertical: ScreenUtil().setWidth(12)),
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
color: switchState ? MyColours.app_main : MyColours.color_E0E0E0,
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'九折券',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(50),
fontWeight: FontWeight.bold),
CouponSunModel sunModel = widget.couponSonModel;
bool notSelect = false;
if (widget.from == 'history') {
notSelect = false;
} else {
notSelect = sunModel.isOpenBool;
}
return InkWell(
onTap: widget.onPressed,
child: Stack(
children: [
Container(
// width: ScreenUtil().setWidth(610),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30),
vertical: ScreenUtil().setWidth(12)),
padding: EdgeInsets.all(ScreenUtil().setWidth(30)),
decoration: BoxDecoration(
color: notSelect ? MyColours.app_main : MyColours.color_E0E0E0,
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: ScreenUtil().setWidth(360),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
constraints: BoxConstraints(
maxWidth: ScreenUtil().setWidth(190)),
child: Text(
sunModel.aname,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(34),
fontWeight: FontWeight.bold),
),
),
Expanded(
flex: 1,
child: Container(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(6)),
child: Text('( ${sunModel.desc} )',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22),
fontWeight: FontWeight.bold)),
))
],
),
Text('(无门槛)',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22),
fontWeight: FontWeight.bold))
],
),
VEmptyView(20),
Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
child: Text('说明:大哈就快费复大家发哈接电话费哈就快递费快回复解答快回复',
maxLines: 30,
overflow: TextOverflow.ellipsis,
softWrap: false,
style: TextStyle(
color: switchState
? MyColours.app_main
: MyColours.color_e5e5e5,
fontSize: ScreenUtil().setSp(22))),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
),
Container(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(20)),
child: Text('有效期:2021.01.01 00:00:00 至 2021.01.31 23:59:59',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
),
],
),
ObjectUtil.isNotEmpty(sunModel.explain)
? Container(
margin: EdgeInsets.only(top: ScreenUtil().setWidth(30)),
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
width: double.infinity,
child: Text('说明:${sunModel.explain}',
maxLines: 30,
overflow: TextOverflow.ellipsis,
softWrap: false,
style: TextStyle(
color: notSelect
? MyColours.app_main
: MyColours.color_e5e5e5,
fontSize: ScreenUtil().setSp(22))),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10))),
)
: Container(),
(ObjectUtil.isNotEmpty(sunModel.stime) &&
sunModel.stime != '0') ||
(ObjectUtil.isNotEmpty(sunModel.etime) &&
sunModel.etime != '0')
? Container(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(20)),
child: Text(
'有效期:${ObjectUtil.isNotEmpty(sunModel.stime) ? Utils.getDateStrFromJiekou(sunModel.stime) : '--'} 至 ${ObjectUtil.isNotEmpty(sunModel.etime) ? Utils.getDateStrFromJiekou(sunModel.etime) : '--'}',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
)
: Container(),
],
),
),
),
Positioned(
top: ScreenUtil().setWidth(40),
right: ScreenUtil().setWidth(40),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
Positioned(
top: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(60),
child: InkWell(
onTap: widget.onPressedSwich,
child: Row(
children: [
Text('被领取:99张',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
Text('已使用:9张',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('被领取:${sunModel.receiveNum}张',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
VEmptyView(5),
Text('已使用:${sunModel.useNum}张',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(22))),
],
),
HEmptyView(20),
widget.showBtn
? RoundButton(
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(50),
radius: ScreenUtil().setWidth(10),
text: notSelect ? '停用' : '启用',
textColor: MyColours.color_666666,
gradientStart: Colors.white,
gradientEnd: Colors.white,
onPressed: widget.onPressedSwich,
)
: Container()
],
),
HEmptyView(20),
widget.showBtn
? RoundButton(
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(50),
radius: ScreenUtil().setWidth(10),
text: switchState ? '停用' : '启用',
textColor: MyColours.color_666666,
gradientStart: Colors.white,
gradientEnd: Colors.white,
onPressed: widget.onPressed,
)
: Container()
],
),
)
],
),
)
],
),
);
}
}
... ...
... ... @@ -4,6 +4,8 @@ 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/provider/coupon_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/utils/navigator_util.dart';
import 'package:one_key/widgets/page_exception.dart';
... ... @@ -28,11 +30,32 @@ class _CouponPageState extends State<CouponPage> {
CouponProvider couponProvider;
///获取优惠券列表数据
_couponNetworkData() {
return Future.delayed(Duration(seconds: 1), () {
couponProvider.pageState = PageState.Success;
couponProvider.notifyListeners();
});
_couponNetworkData({bool isShowLoading = true}) async {
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
// 'is_time': '0'
};
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(isShowLoading: false);
// if (isSuccess) {
// couponProvider.notifyListeners();
// } else {
// couponProvider.couponList[index].isOpenBool =
// !couponProvider.couponList[index].isOpenBool;
// couponProvider.notifyListeners();
// }
}
@override
... ... @@ -42,6 +65,16 @@ class _CouponPageState extends State<CouponPage> {
WidgetsBinding.instance.addPostFrameCallback((_) {
_couponNetworkData();
});
// bus.on("refresh_coupon_list", (arg) {
// _couponNetworkData();
// });
}
@override
void dispose() {
EventBus().emit('changeStatusColor');
// bus.off("refresh_coupon_list");
super.dispose();
}
@override
... ... @@ -64,6 +97,7 @@ class _CouponPageState extends State<CouponPage> {
callback: () {
// offset = 0;
// getMessage(showLoading: true);
_couponNetworkData();
},
emptyMsg: "暂时没有列表信息哦",
emptyImg: "empty_search",
... ... @@ -81,33 +115,46 @@ class _CouponPageState extends State<CouponPage> {
padding:
EdgeInsets.all(ScreenUtil().setWidth(20)),
child: Text(
'使用说明:回家啊喝点酒啊喝酒啊电话噶记得发快递费哈咖啡和大号发客服哈空腹喝酒啊快递费哈快递费哈看警方还会发卡号发快回复'));
'使用说明:需在结账前出示优惠券二维码,店内工作人员微信扫码核销。超过有效期的券,会自动作废并移出列表。优惠券不可找零、兑现。',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(28),
),
strutStyle: StrutStyle(
forceStrutHeight: true,
height: 1,
leading: 0.3),
));
}, childCount: 1),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return CouponItem(
index: index,
couponProvider: couponProvider,
from: 'quan',
couponSonModel: couponProvider.couponList[index],
showBtn: true,
onPressedSwich: () {
couponProvider.couponList[index].isOpenBool =
!couponProvider.couponList[index].isOpenBool;
_setCustomerActivity(index);
},
onPressed: () {
couponProvider.swichStateData[index] =
!couponProvider.swichStateData[index];
couponProvider.notifyListeners();
NavigatorUtil.goCouponDetailPage(
context, couponProvider.couponList[index]);
},
);
}, childCount: couponProvider.swichStateData.length),
}, childCount: couponProvider.couponList.length),
)
],
onRefresh: () async {
// offset = 0;
// getMessage(showLoading: false);
},
onLoad: () async {
// offset++;
// getMessage(showLoading: false);
},
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
},
... ... @@ -123,7 +170,8 @@ class _CouponPageState extends State<CouponPage> {
print(needRefresh);
if (needRefresh != null && needRefresh) {
//刷新页面数据
_controller.callRefresh();
// _controller.callRefresh();
_couponNetworkData();
}
},
text: '创建新券',
... ...
... ... @@ -4,6 +4,7 @@ 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/provider/coupon_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/utils/navigator_util.dart';
... ... @@ -16,7 +17,9 @@ import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
class CouponSelectPage extends StatefulWidget {
CouponSelectPage({Key key}) : super(key: key);
final String rid;
final bool hasModify;
CouponSelectPage({Key key, this.rid, this.hasModify}) : super(key: key);
@override
_CouponSelectPageState createState() => _CouponSelectPageState();
... ... @@ -26,12 +29,17 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
EasyRefreshController _controller = EasyRefreshController();
CouponProvider couponProvider;
///获取优惠券列表数据
_couponNetworkData() {
return Future.delayed(Duration(seconds: 1), () {
couponProvider.pageStateSelect = PageState.Success;
couponProvider.notifyListeners();
});
///获取优惠券列表数据(status == 1)
_couponNetworkData({bool isShowLoading = true}) async {
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
};
if (!widget.hasModify) {
params['status'] = '1';
}
await couponProvider.getCustomerSelectActivity(context, params,
isShowLoading: isShowLoading);
}
@override
... ... @@ -39,11 +47,21 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// if (!couponProvider.hasModify) {
_couponNetworkData();
// } else {
// couponProvider.pageStateSelect = PageState.Success;
// // couponProvider.notifyListeners();
// }
});
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
... ... @@ -53,7 +71,12 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
Navigator.pop(context);
Utils.changeStatusColor(color: Colors.transparent);
},
rightImgName: couponProvider.checkValue ? '取消全选' : '全选',
rightImgName: !widget.hasModify &&
couponProvider.pageStateSelect == PageState.Success
? couponProvider.checkValue
? '取消全选'
: '全选'
: '',
onTapRight: () {
if (couponProvider.checkValue) {
couponProvider.cancelAll();
... ... @@ -88,9 +111,11 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
(BuildContext context, int index) {
return InkWell(
onTap: () {
couponProvider.listData[index]['checked'] =
!couponProvider.listData[index]['checked'];
if (couponProvider.listData[index]['checked']) {
couponProvider.couponListSelect[index].isCheck =
!couponProvider
.couponListSelect[index].isCheck;
if (couponProvider
.couponListSelect[index].isCheck) {
couponProvider.addData(index);
} else {
couponProvider.cancelData(index);
... ... @@ -100,24 +125,30 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
child: Row(
children: [
HEmptyView(30),
Checkbox(
value: couponProvider.listData[index]
['checked'],
checkColor: MyColours.color_ffffff,
activeColor: MyColours.app_main,
onChanged: (bool value) {
couponProvider.listData[index]['checked'] =
!couponProvider.listData[index]
['checked'];
if (couponProvider.listData[index]
['checked']) {
couponProvider.addData(index);
} else {
couponProvider.cancelData(index);
}
couponProvider.getCheckValue();
},
),
!widget.hasModify
? Checkbox(
value: couponProvider
.couponListSelect[index].isCheck,
checkColor: MyColours.color_ffffff,
activeColor: MyColours.app_main,
onChanged: (bool value) {
//改这里 ******8
couponProvider.couponListSelect[index]
.isCheck =
!couponProvider
.couponListSelect[index]
.isCheck;
if (couponProvider
.couponListSelect[index]
.isCheck) {
couponProvider.addData(index);
} else {
couponProvider.cancelData(index);
}
couponProvider.getCheckValue();
},
)
: Container(),
// Image.asset(
// couponProvider.listData[index]['checked']
// ? 'assets/select.png'
... ... @@ -125,54 +156,47 @@ class _CouponSelectPageState extends State<CouponSelectPage> {
// width: ScreenUtil().setWidth(44)),
Expanded(
child: CouponItem(
index: index,
couponProvider: couponProvider,
onPressed: () {
couponProvider.listData[index]['checked'] =
!couponProvider.listData[index]
['checked'];
if (couponProvider.listData[index]
['checked']) {
couponProvider.addData(index);
} else {
couponProvider.cancelData(index);
}
couponProvider.getCheckValue();
},
from: 'select',
couponSonModel:
couponProvider.couponListSelect[index],
onPressed: () {},
))
],
),
);
}, childCount: couponProvider.listData.length),
}, childCount: couponProvider.couponListSelect.length),
)
],
onRefresh: () async {
// offset = 0;
// getMessage(showLoading: false);
},
onLoad: () async {
// offset++;
// getMessage(showLoading: false);
},
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // getMessage(showLoading: false);
// },
);
}
},
)),
VEmptyView(20),
Padding(
padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () {
Navigator.pop(context);
},
text: '已选${couponProvider.coupons.length}个 确定',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(80),
width: double.infinity,
radius: ScreenUtil().setWidth(10),
))
!widget.hasModify &&
couponProvider.pageStateSelect == PageState.Success
? Padding(
padding: EdgeInsets.fromLTRB(ScreenUtil().setWidth(40), 0,
ScreenUtil().setWidth(40), ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () async {
Navigator.pop(context);
},
text: '已选${couponProvider.coupons.length}个 确定',
fontSize: 34,
isBold: false,
height: ScreenUtil().setWidth(80),
width: double.infinity,
radius: ScreenUtil().setWidth(10),
))
: Container()
],
),
onWillPop: () async {
... ...
... ... @@ -31,12 +31,16 @@ class InvicationPageState extends State<InvicationPage> {
DateTime dateTime;
String dateTimeStr = "";
ScrollController controller = ScrollController();
final double couponHeight = 180.0;
double couponHeight = 180.0;
CouponProvider couponProvider;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getActivityByRid();
});
Utils.changeStatusColor(color: Colors.transparent);
dateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(widget.ddate) * 1000);
... ... @@ -45,9 +49,51 @@ class InvicationPageState extends State<InvicationPage> {
"${dateTime.year}/${Utils.addZeroNumber(dateTime.month)}/${Utils.addZeroNumber(dateTime.day)} 星期${Utils.formatWeekDayNum(dateTime.weekday)} ${widget.ddateStr}";
}
_getActivityByRid() async {
Map<String, String> params = {
"rid": widget.rid,
};
await couponProvider.getActivityByRid(context, params, isShowLoading: true);
//flase默认5个 true 不默认5个
if (!couponProvider.hasModify) {
//没有绑定的券,默认给5个,获取优惠券列表
_couponNetworkData(isShowLoading: true);
}
}
///消费券默认5张
_couponNetworkData({bool isShowLoading = true}) async {
Map<String, String> params = {
"uid": Provider.of<UserModel>(context, listen: false).user.openid,
'status': '1'
};
await couponProvider.getCustomerSelectActivity(context, params,
isShowLoading: isShowLoading);
//此人已经新建好券
if (couponProvider.couponListSelect.length > 0) {
couponProvider.initCouponSelect(context);
if (couponProvider.coupons.length == 0) {
setState(() {
couponHeight = 0;
});
} else {
setState(() {
couponHeight = 180.0;
});
}
} else {
//没有新建的优惠券
setState(() {
couponHeight = 0;
});
}
}
@override
void dispose() {
Utils.changeStatusColor();
couponProvider.clearSelect();
super.dispose();
}
... ... @@ -239,8 +285,34 @@ class InvicationPageState extends State<InvicationPage> {
),
Expanded(
child: GestureDetector(
onTap: () {
Utils.goShareInvicationToWeChat(widget.rid);
onTap: () async {
if (!couponProvider.hasModify &&
couponProvider.coupons.length > 0) {
Map<String, String> params = {
"rid": widget.rid,
"aid": Utils.listToStringEnglish(
couponProvider.coupons)
};
bool isSuc = await couponProvider
.setActivityAsReserve(context, params);
if (isSuc) {
couponProvider.hasModify = true;
bool isSuccess =
await Utils.goShareInvicationToWeChat(
widget.rid);
print(isSuccess);
// couponProvider.couponsShow = [];
// couponProvider.couponsShow
// .addAll(couponProvider.coupons);
// couponProvider.coupons = [];
// couponProvider.notifyListeners();
}
} else {
bool isSuccess =
await Utils.goShareInvicationToWeChat(
widget.rid);
print(isSuccess);
}
},
child: Container(
width: double.infinity,
... ... @@ -288,32 +360,38 @@ class InvicationPageState extends State<InvicationPage> {
left: ScreenUtil().setWidth(180),
bottom: ScreenUtil().setWidth(130),
right: ScreenUtil().setWidth(180),
child: GestureDetector(
onTap: () {
NavigatorUtil.goCouponSelectPage(context);
},
behavior: HitTestBehavior.opaque,
child: Center(
child: Container(
// width: ScreenUtil().setWidth(400),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(20)),
// height: ScreenUtil().setWidth(100),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(20))),
child: Text(
'共赠送${couponProvider.coupons.length}张优惠券\n点击查看',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
child: couponProvider.hasModify ||
couponProvider.coupons.length > 0 ||
couponProvider.couponListSelect.length > 0
? GestureDetector(
onTap: () async {
NavigatorUtil.goCouponSelectPage(context,
rid: widget.rid,
hasModify: couponProvider.hasModify);
},
behavior: HitTestBehavior.opaque,
child: Center(
child: Container(
// width: ScreenUtil().setWidth(400),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(20)),
// height: ScreenUtil().setWidth(100),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(20))),
child: Text(
'共赠送${couponProvider.coupons.length}张优惠券\n点击查看',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: ScreenUtil().setSp(28),
),
),
),
),
),
),
),
),
)
: Container(),
)
],
))));
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class CouponProvider with ChangeNotifier {
List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用
PageState pageState = PageState.Loading;
PageState pageStateHistory = PageState.Loading;
PageState pageStateSelect = PageState.Loading;
bool hasModify = false;
bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true
List<Map<String, dynamic>> listData = []; //优惠券页面数据
List coupons = []; //选中的优惠券id集合
// List<Map<String, dynamic>> listData = []; //优惠券页面数据
List<String> coupons = []; //选中的优惠券id集合
// List<String> couponsShow = []; //邀请函显示数量 选中的优惠券id集合
List<CouponSunModel> couponListHistory = []; //优惠券历史列表
List<CouponSunModel> couponList = []; //优惠券列表
List<CouponSunModel> couponListSelect = []; //优惠券选择列表
CouponProvider() {
for (int i = 0; i < 20; i++) {
swichStateData.add(true);
listData.add({'checked': true, 'id': '${i}'});
}
// for (int i = 0; i < 20; i++) {
// swichStateData.add(true);
// listData.add({'checked': true, 'id': '${i}'});
// }
}
//全选按钮执行“全选”
addAll() async {
//把数据状态全部改成true,即选中状态
coupons = [];
for (var i = 0; i < listData.length; i++) {
listData[i]['checked'] = true;
coupons.add(listData[i]['id']);
for (var i = 0; i < couponListSelect.length; i++) {
couponListSelect[i].isCheck = true;
coupons.add(couponListSelect[i].id);
}
checkValue = true;
notifyListeners();
}
///清楚选择
clearSelect() {
coupons = [];
// couponsShow = [];
}
//默认选择前5个
initCouponSelect(BuildContext context) {
coupons = [];
// couponsShow = [];
for (var i = 0; i < couponListSelect.length; i++) {
if (i < 5) {
couponListSelect[i].isCheck = true;
coupons.add(couponListSelect[i].id);
}
}
// couponsShow.addAll(coupons);
// coupons = [];
notifyListeners();
}
//全选按钮执行“全不选”
cancelAll() async {
//把数据状态全部改成false,即不选中状态
for (var i = 0; i < listData.length; i++) {
listData[i]['checked'] = false;
for (var i = 0; i < couponListSelect.length; i++) {
couponListSelect[i].isCheck = false;
}
coupons = [];
checkValue = false;
... ... @@ -43,22 +79,22 @@ class CouponProvider with ChangeNotifier {
//选中
addData(int index) {
listData[index]['checked'] = true;
coupons.add(listData[index]['id']);
couponListSelect[index].isCheck = true;
coupons.add(couponListSelect[index].id);
notifyListeners();
}
//未选中
cancelData(int index) {
listData[index]['checked'] = false;
coupons.removeWhere((element) => element == listData[index]['id']);
couponListSelect[index].isCheck = false;
coupons.removeWhere((element) => element == couponListSelect[index].id);
notifyListeners();
}
//获取全选按钮的状态 true or false
getCheckValue() {
bool temp = listData.any((value) {
return value['checked'] == false;
bool temp = couponListSelect.any((value) {
return value.isCheck == false;
});
if (temp == true) {
checkValue = false;
... ... @@ -67,4 +103,292 @@ class CouponProvider with ChangeNotifier {
}
notifyListeners();
}
///客户经理创建活动
Future<dynamic> createCustomerActivity(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.create_customer_activity,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
}
// notifyListeners();
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
// pageState = PageState.ConnectivityError;
return false;
} else {
// pageState = PageState.Success;
return true;
}
// notifyListeners();
// return NotebookDetail.fromJson(baseResp.data);
} else {
// pageState = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///客户经理获取所创建活动列表
Future<List<CouponSunModel>> getCustomerActivity(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
if (isShowLoading) {
pageState = PageState.Loading;
notifyListeners();
}
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_customer_activity,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
}
couponList = CouponModel.fromJson(baseResp.responseData).data;
notifyListeners();
} else {
pageState = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
return couponList;
}
///客户经理获取所创建活动列表
Future<List<CouponSunModel>> getCustomerHistoryActivity(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
if (isShowLoading) {
pageStateHistory = PageState.Loading;
notifyListeners();
}
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_customer_activity,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateHistory = PageState.ConnectivityError;
break;
case 2:
pageStateHistory = PageState.ConnectivityTimeOut;
break;
default:
pageStateHistory = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageStateHistory = PageState.Empty;
} else {
pageStateHistory = PageState.Success;
}
couponListHistory = CouponModel.fromJson(baseResp.responseData).data;
notifyListeners();
} else {
pageStateHistory = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
return couponListHistory;
}
///客户经理获取所创建活动列表(选择优惠券)
Future<List<CouponSunModel>> getCustomerSelectActivity(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
if (isShowLoading) {
pageStateSelect = PageState.Loading;
notifyListeners();
}
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_customer_activity,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateSelect = PageState.ConnectivityError;
break;
case 2:
pageStateSelect = PageState.ConnectivityTimeOut;
break;
default:
pageStateSelect = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageStateSelect = PageState.Empty;
} else {
pageStateSelect = PageState.Success;
}
couponListSelect = CouponModel.fromJson(baseResp.responseData).data;
if (hasModify) {
//已经绑定
List<CouponSunModel> temp = [];
for (int i = 0; i < couponListSelect.length; i++) {
for (int j = 0; j < coupons.length; j++) {
if (couponListSelect[i].id == coupons[j]) {
temp.add(couponListSelect[i]);
}
}
}
couponListSelect = temp;
} else {
for (int i = 0; i < couponListSelect.length; i++) {
for (int j = 0; j < coupons.length; j++) {
if (couponListSelect[i].id == coupons[j]) {
couponListSelect[i].isCheck = true;
}
}
}
}
getCheckValue();
notifyListeners();
} else {
pageStateSelect = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
return couponListSelect;
}
///客户经理修改活动
Future<dynamic> setCustomerActivity(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_customer_activity,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.data.toString()) == 1) {
return true;
} else {
// Utils.showToast(baseResp.msg ?? "修改失败");
return false;
}
} else {
if (baseResp != null) {
// Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///设置预定绑定活动ID
Future<dynamic> setActivityAsReserve(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_activity_as_reserve,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data != null) {
// coupons = baseResp.data['aid'].split('');
return true;
} else {
// Utils.showToast(baseResp.msg ?? "修改失败");
return false;
}
} else {
if (baseResp != null) {
// Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///获取预定绑定活动
Future<bool> getActivityByRid(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_activity_by_rid,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data == null) {
hasModify = false;
} else {
couponListSelect = CouponModel.fromJson(baseResp.responseData).data;
for (int i = 0; i < couponListSelect.length; i++) {
coupons.add(couponListSelect[i].id);
// couponsShow.add(couponTemp[i].id);
}
hasModify = true;
notifyListeners();
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
}
... ...
... ... @@ -46,7 +46,7 @@ class NotebookDetailModel extends ChangeNotifier {
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageState = PageState.ConnectivityError;
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
}
... ...
... ... @@ -47,7 +47,7 @@ class OrderFoodProvider extends ChangeNotifier {
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageState = PageState.ConnectivityError;
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
createdOrderSunModel =
... ...
... ... @@ -2,9 +2,11 @@ import 'dart:convert';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/table_list.dart';
import 'package:one_key/pages/coupon/coupon_detail_page.dart';
import 'package:one_key/pages/coupon/coupon_edit_page.dart';
import 'package:one_key/pages/coupon/coupon_history_page.dart';
import 'package:one_key/pages/coupon/coupon_page.dart';
... ... @@ -244,7 +246,16 @@ var handleCouponEditPageHandler = new Handler(
///选择优惠券
var handleCouponSelectPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
// String rid = params["rid"].first;
// bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return CouponSelectPage();
String rid = params["rid"].first;
bool hasModify = FluroConvertUtils.string2bool(params["hasModify"].first);
return CouponSelectPage(rid: rid,hasModify:hasModify);
});
///优惠券详情页
var handleCouponDetailPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
CouponSunModel couponSunModel = CouponSunModel.fromJson(json.decode(
FluroConvertUtils.fluroCnParamsDecode(params["couponSunModel"].first)));
return CouponDetailPage(couponSunModel: couponSunModel);
});
... ...
... ... @@ -26,6 +26,7 @@ class Routes {
static String coupon_history = "/coupon_history"; //优惠券历史列表页
static String coupon_edit = "/coupon_edit"; //创建优惠券
static String coupon_select = "/coupon_select"; //优惠券选择
static String coupon_detail = "/coupon_detail"; //优惠券详情页
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -55,8 +56,7 @@ class Routes {
router.define(coupon, handler: handleCouponPageHandler);
router.define(coupon_history, handler: handleCouponHistoryPageHandler);
router.define(coupon_edit, handler: handleCouponEditPageHandler);
router.define(coupon_select, handler: handleCouponSelectPageHandler);
router.define(coupon_select, handler: handleCouponSelectPageHandler);
router.define(coupon_detail, handler: handleCouponDetailPageHandler);
}
}
... ...
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/table_list.dart';
... ... @@ -171,7 +172,18 @@ class NavigatorUtil {
/// 选择优惠券
static Future<dynamic> goCouponSelectPage(BuildContext context,
{String rid, bool hasModify, replace = false}) {
return _navigateTo(
context, "${Routes.coupon_select}?rid=${rid}&hasModify=${hasModify}",
replace: replace);
}
/// 优惠券详情页
static Future<dynamic> goCouponDetailPage(
BuildContext context, CouponSunModel couponSunModel,
{replace = false}) {
return _navigateTo(context, "${Routes.coupon_select}", replace: replace);
return _navigateTo(context,
"${Routes.coupon_detail}?couponSunModel=${FluroConvertUtils.object2string(couponSunModel)}",
replace: replace);
}
}
... ...
... ... @@ -22,6 +22,12 @@ import '../app.dart';
typedef BookTimeSetCallback = void Function(bool needChange);
class Utils {
static getDateStrFromJiekou(String ms) {
return DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(int.parse(ms) * 1000),
format: DateFormats.full);
}
static setBarStatus(bool isDarkIcon,
{Color color: Colors.transparent}) async {
if (Platform.isAndroid) {
... ... @@ -181,7 +187,7 @@ class Utils {
}
//分享邀请函
static goShareInvicationToWeChat(String rid) {
static goShareInvicationToWeChat(String rid) async {
String _webPageUrl = "http://colorcun.com/";
String _thumbnail =
"https://qn.colorcun.com/reserve/images/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201911151148572.jpg";
... ... @@ -196,7 +202,8 @@ class Utils {
path: _path,
description: _description,
thumbnail: WeChatImage.network(_thumbnail));
shareToWeChat(model);
bool isSuccess = await shareToWeChat(model);
return isSuccess;
}
//检查网络连接
... ... @@ -227,6 +234,21 @@ class Utils {
return result.toString();
}
static String listToStringEnglish(List<String> list) {
if (list == null) {
return null;
}
String result;
list.forEach((string) {
if (result == null) {
result = string;
} else {
result = '$result,$string';
}
});
return result.toString();
}
/// 获取日期 今天 明天 后天等等
static int getDdate(List dateList) {
String ymyStr = ""; //年月日
... ...