|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_picker/flutter_picker.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
import 'package:one_key/constant/state.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/route/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';
|
|
|
|
|
|
|
|
import '../../utils/screen_util.dart';
|
|
|
|
import '../../widgets/page_exception.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新建券
|
|
|
|
*/
|
|
|
|
|
|
|
|
class CouponVerificationDetailPage extends StatefulWidget {
|
|
|
|
final CouponSunModel couponSunModel;
|
|
|
|
final String idstr;
|
|
|
|
CouponVerificationDetailPage({Key key, this.couponSunModel, this.idstr})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_CouponVerificationDetailPageState createState() =>
|
|
|
|
_CouponVerificationDetailPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CouponVerificationDetailPageState
|
|
|
|
extends State<CouponVerificationDetailPage> {
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
final heightCell = ScreenUtil().setWidth(80);
|
|
|
|
CouponProvider couponProvider;
|
|
|
|
PageState pageState = PageState.Loading;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// if (widget.idstr != null && widget.idstr != 'null') {
|
|
|
|
_getActivityById();
|
|
|
|
// } else {
|
|
|
|
// couponProvider.couponSunModel = widget.couponSunModel;
|
|
|
|
// pageState = PageState.Success;
|
|
|
|
// setState(() {});
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_getActivityById() async {
|
|
|
|
pageState = PageState.Loading;
|
|
|
|
bool success = await couponProvider
|
|
|
|
.getActivityById(context, {'id': widget.idstr}, isShowLoading: false);
|
|
|
|
if (success) {
|
|
|
|
pageState = PageState.Success;
|
|
|
|
} else {
|
|
|
|
pageState = PageState.ConnectivityError;
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
///时间选择
|
|
|
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
Spacer(),
|
|
|
|
Text(hintText,
|
|
|
|
style: TextStyle(
|
|
|
|
color: hintText == '点击选择'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('arrow_right_new'),
|
|
|
|
width: ScreenUtil().setWidth(20),
|
|
|
|
),
|
|
|
|
HEmptyView(32),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///输入框
|
|
|
|
Widget _item(String title, String subTitle) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(60),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
subTitle,
|
|
|
|
maxLines: 20,
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.4),
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///输入框
|
|
|
|
Widget _textShow(String title, String subtitle) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(15),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.9),
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Text(
|
|
|
|
subtitle,
|
|
|
|
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color.fromRGBO(0, 0, 0, 0.4),
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
///是否立即启用
|
|
|
|
Widget _canUse(String title, bool swich) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
// height: ScreenUtil().setWidth(40),
|
|
|
|
// color: Colors.red,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Image.asset(
|
|
|
|
swich
|
|
|
|
? Utils.getImgPath('swich_on')
|
|
|
|
: Utils.getImgPath('swich_off'),
|
|
|
|
width: ScreenUtil().setWidth(44 * 2),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
couponProvider = Provider.of<CouponProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'优惠券详情',
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
rightImgName: couponProvider.couponSunModel.isType == '1' &&
|
|
|
|
couponProvider.couponSunModel.isExamine == '1' &&
|
|
|
|
couponProvider.couponSunModel.status == '1'
|
|
|
|
? 'share.png'
|
|
|
|
: null,
|
|
|
|
onTapRight: () {
|
|
|
|
if (couponProvider.couponSunModel.isType == '1' &&
|
|
|
|
couponProvider.couponSunModel.isExamine == '1' &&
|
|
|
|
couponProvider.couponSunModel.status == '1') {
|
|
|
|
//店铺可核销券
|
|
|
|
Utils.goShareBuyCouponToWeChat(
|
|
|
|
context,
|
|
|
|
widget.idstr,
|
|
|
|
couponProvider.couponSunModel.use,
|
|
|
|
couponProvider.couponSunModel);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: Consumer<CouponProvider>(builder: (context, model, _) {
|
|
|
|
if (pageState != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: pageState,
|
|
|
|
callback: () {
|
|
|
|
_getActivityById();
|
|
|
|
},
|
|
|
|
emptyMsg: "暂时没有数据哦,",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Column(children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: controller,
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(32)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(56),
|
|
|
|
_item(
|
|
|
|
'券类型',
|
|
|
|
couponProvider.couponSunModel.isType == '1'
|
|
|
|
? '店铺优惠券'
|
|
|
|
: '我的优惠券'),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_item('券编码', 'NO.01774420230223150306'),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_item('券名称', couponProvider.couponSunModel.aname),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
|
|
|
|
VEmptyView(24),
|
|
|
|
if (couponProvider.couponSunModel.use != null)
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
// _item(
|
|
|
|
// '券用途',
|
|
|
|
// couponProvider.couponSunModel.use.isCash
|
|
|
|
// ? '代金券'
|
|
|
|
// : couponProvider
|
|
|
|
// .couponSunModel.use.isDiscount
|
|
|
|
// ? '折扣券'
|
|
|
|
// : couponProvider
|
|
|
|
// .couponSunModel.use.isDish
|
|
|
|
// ? '菜品券'
|
|
|
|
// : ''),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
// VEmptyView(24),
|
|
|
|
// _item(
|
|
|
|
// couponProvider.couponSunModel.use.isCash
|
|
|
|
// ? '金额'
|
|
|
|
// : couponProvider
|
|
|
|
// .couponSunModel.use.isDiscount
|
|
|
|
// ? '折扣率'
|
|
|
|
// : couponProvider
|
|
|
|
// .couponSunModel.use.isDish
|
|
|
|
// ? '菜品'
|
|
|
|
// : '',
|
|
|
|
// couponProvider.couponSunModel.use.isCash
|
|
|
|
// ? '${couponProvider.couponSunModel.use.cash}元'
|
|
|
|
// : couponProvider
|
|
|
|
// .couponSunModel.use.isDiscount
|
|
|
|
// ? '${couponProvider.couponSunModel.use.discount}折'
|
|
|
|
// : couponProvider
|
|
|
|
// .couponSunModel.use.isDish
|
|
|
|
// ? couponProvider
|
|
|
|
// .couponSunModel.use.dish
|
|
|
|
// : ''),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
// VEmptyView(24),
|
|
|
|
_item(
|
|
|
|
'销售价',
|
|
|
|
'${couponProvider.couponSunModel.price}元' ??
|
|
|
|
''),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
_item('券要求', couponProvider.couponSunModel.desc),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_item(
|
|
|
|
'有效期从',
|
|
|
|
Utils.getDateStrFromJiekou(
|
|
|
|
couponProvider.couponSunModel.stime)),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_item(
|
|
|
|
'有效期至',
|
|
|
|
Utils.getDateStrFromJiekou(
|
|
|
|
couponProvider.couponSunModel.etime)),
|
|
|
|
|
|
|
|
Column(children: [
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_item(
|
|
|
|
'使用限制',
|
|
|
|
couponProvider.couponSunModel.expDate.isNone
|
|
|
|
? '无'
|
|
|
|
: couponProvider
|
|
|
|
.couponSunModel.expDate.isBirthday
|
|
|
|
? '会员生日当天'
|
|
|
|
: couponProvider
|
|
|
|
.couponSunModel.expDate.isWeek
|
|
|
|
? '每周指定日期餐段可用'
|
|
|
|
: ''),
|
|
|
|
if (couponProvider.couponSunModel.expDate.isWeek)
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
child: Text(
|
|
|
|
couponProvider
|
|
|
|
.couponSunModel.expDate.weekShow,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style: TextStyle(
|
|
|
|
height: 1.5,
|
|
|
|
fontSize: font(16),
|
|
|
|
color: MyColours.color_999999),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
if (couponProvider.couponSunModel.expDate.isWeek)
|
|
|
|
VEmptyView(24),
|
|
|
|
]),
|
|
|
|
|
|
|
|
// couponProvider.couponSunModel.isType == '1'
|
|
|
|
// ? Column(
|
|
|
|
// crossAxisAlignment:
|
|
|
|
// CrossAxisAlignment.start,
|
|
|
|
// children: [
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
// VEmptyView(24),
|
|
|
|
// _item('创建人',
|
|
|
|
// couponProvider.couponSunModel.uid),
|
|
|
|
// ],
|
|
|
|
// )
|
|
|
|
// : SizedBox(),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_item('核销日期', '2023-05-05'),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
_item('核销人', '核销人'),
|
|
|
|
// _select(
|
|
|
|
// '谁可以发放',
|
|
|
|
// '查看',
|
|
|
|
// () async {
|
|
|
|
// await NavigatorUtil
|
|
|
|
// .goCouponToPersonnalPage(
|
|
|
|
// context,
|
|
|
|
// couponProvider
|
|
|
|
// .couponSunModel.uidList,
|
|
|
|
// onlyShow: true);
|
|
|
|
// },
|
|
|
|
// )
|
|
|
|
],
|
|
|
|
),
|
|
|
|
couponProvider.couponSunModel.explain != null &&
|
|
|
|
couponProvider.couponSunModel.explain != ''
|
|
|
|
? Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
)
|
|
|
|
: SizedBox(),
|
|
|
|
couponProvider.couponSunModel.explain != null &&
|
|
|
|
couponProvider.couponSunModel.explain != ''
|
|
|
|
? VEmptyView(24)
|
|
|
|
: SizedBox(),
|
|
|
|
couponProvider.couponSunModel.explain != null &&
|
|
|
|
couponProvider.couponSunModel.explain != ''
|
|
|
|
? _item('券说明', '')
|
|
|
|
: SizedBox(),
|
|
|
|
Container(
|
|
|
|
height: ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
),
|
|
|
|
VEmptyView(24),
|
|
|
|
if (couponProvider.couponSunModel.explain != null &&
|
|
|
|
couponProvider.couponSunModel.explain != '')
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
couponProvider.couponSunModel.explain,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style: TextStyle(
|
|
|
|
// height: 1.5,
|
|
|
|
fontSize: font(16),
|
|
|
|
color: MyColours.color_999999),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (couponProvider.couponSunModel.explain != null &&
|
|
|
|
couponProvider.couponSunModel.explain != '')
|
|
|
|
VEmptyView(24),
|
|
|
|
// Container(
|
|
|
|
// height: ScreenUtil().setWidth(2),
|
|
|
|
// color: MyColours.color_E7E7E7,
|
|
|
|
// ),
|
|
|
|
VEmptyView(24),
|
|
|
|
_canUse(
|
|
|
|
'立即启用',
|
|
|
|
couponProvider.couponSunModel.status == '1'
|
|
|
|
? true
|
|
|
|
: false)
|
|
|
|
],
|
|
|
|
))),
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|