Commit 074babfde822afc68683b420f4347ac5640e91b3

Authored by wdn127929
1 parent 5cb88650

营销中心--充值优惠UI okok

971 Bytes

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
... ... @@ -13,6 +14,11 @@ 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 'package:barcode_scan2/barcode_scan2.dart';
import '../../utils/dialog_util.dart';
import '../../utils/misc.dart';
/**
* 优惠券列表
... ... @@ -59,12 +65,27 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
// // !couponProvider.couponList[index].isOpenBool;
// // couponProvider.notifyListeners();
// // }
// }
// }'
ScanResult scanResult;
var _aspectTolerance = 0.5;
// var _numberOfCameras = 0;
var _selectedCamera = -1;
var _autoEnableFlash = false;
static final _possibleFormats = BarcodeFormat.values.toList()
..removeWhere((e) => e == BarcodeFormat.unknown);
List<BarcodeFormat> selectedFormats = [..._possibleFormats];
@override
void initState() {
// TODO: implement initState
super.initState();
// Future.delayed(Duration.zero, () async {
// // _numberOfCameras = await BarcodeScanner.numberOfCameras;
// setState(() {});
// });
tabController = TabController(length: 3, vsync: this);
tabController.addListener(() {
// couponProvider.couponList = [];
... ... @@ -92,20 +113,62 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
super.dispose();
}
Future<void> _scan() async {
try {
final result = await BarcodeScanner.scan(
options: ScanOptions(
strings: {'cancel': '退出', 'flash_on': '开闪光灯', 'flash_off': '关闪光灯'},
restrictFormat: selectedFormats,
useCamera: _selectedCamera,
autoEnableFlash: _autoEnableFlash, //true打开闪光灯, false关闭闪光灯
android: AndroidOptions(
aspectTolerance: 0.5, useAutoFocus: true), //(默认已配)添加Android自动对焦
),
);
// result.rawContent
setState(() => scanResult = result);
print(result);
} on PlatformException catch (e) {
setState(() {
scanResult = ScanResult(
type: ResultType.Error,
rawContent: e.code == BarcodeScanner.cameraAccessDenied
? 'The user did not grant the camera permission!'
: 'Unknown error: $e',
);
if (e.code == BarcodeScanner.cameraAccessDenied) {
DialogUtil.openAlertDialog(
context, '未获得相机权限', "请在手机的权限管理里,将相机权限开启", '去设置', 340.0,
onTap: () {
openSetting();
Navigator.pop(context, '');
});
}
});
}
}
@override
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_f3f3f3,
appBar: SystemAppBar('线上券', onTap: () {
if (widget.needRefrsh) {
EventBus().emit('refresh_coupon_invitation');
} else {
EventBus().emit('changeStatusColor');
}
appBar: SystemAppBar(
'线上券',
onTap: () {
if (widget.needRefrsh) {
EventBus().emit('refresh_coupon_invitation');
} else {
EventBus().emit('changeStatusColor');
}
Navigator.of(context).pop();
}),
Navigator.of(context).pop();
},
rightImgName: 'scan.png',
onTapRight: () {
_scan();
},
),
body: WillPopScope(
onWillPop: () {
if (widget.needRefrsh) {
... ...
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_picker/Picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/models/filter_btn_model.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import '../../../../res/colors.dart';
import '../../../../utils/dialog_util.dart';
import '../../../../utils/screen_util.dart';
import '../../../../utils/utils.dart';
import '../../../../widgets/h_empty_view.dart';
import '../../../../widgets/round_button.dart';
import '../../../../widgets/v_empty_view.dart';
/**
*
* 优惠券详情
*/
class RechargeDetailPage extends StatefulWidget {
RechargeDetailPage({Key key}) : super(key: key);
@override
_RechargeDetailPageState createState() => _RechargeDetailPageState();
}
class _RechargeDetailPageState extends State<RechargeDetailPage> {
TextEditingController nameC = TextEditingController();
TextEditingController priceminC = TextEditingController();
TextEditingController givePriceC = TextEditingController(); //赠送金额
TextEditingController giveScoreC = TextEditingController(); //积分
TextEditingController remarkC = TextEditingController(); //备注
FocusNode nameF = FocusNode();
FocusNode priceminF = FocusNode();
FocusNode givePricF = FocusNode();
FocusNode giveScoreF = FocusNode();
FocusNode remarkF = FocusNode();
bool fixdate = true;
bool weekly = false;
bool birthday = false;
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool showDateSelWidget = false;
String fromDate = '点击设置开始日期'; //有效期开始时间
String endDate = '点击设置结束日期'; //有效期结束时间
List<FilterBtnModel> weekData = [];
String weekShow = '点击设置可用日期';
bool canUse = false;
List<String> coupons = [];
List<String> selectIDs = [];
bool givePriceSwich = false;
bool giveScoreSwich = false;
bool giveCouponsSwich = false;
@override
void initState() {
super.initState();
_initWeekData();
nameF.addListener(() {
if (nameF.hasFocus) {
//有焦点
if (showDateSelWidget) {
Navigator.pop(context);
showDateSelWidget = false;
}
} else {
//失去焦点
// _editingController.text = '';
}
});
priceminF.addListener(() {
if (priceminF.hasFocus) {
//有焦点
if (showDateSelWidget) {
Navigator.pop(context);
showDateSelWidget = false;
}
} else {
//失去焦点
// _editingController.text = '';
}
});
givePricF.addListener(() {
if (givePricF.hasFocus) {
//有焦点
if (showDateSelWidget) {
Navigator.pop(context);
showDateSelWidget = false;
}
} else {
//失去焦点
// _editingController.text = '';
}
});
giveScoreF.addListener(() {
if (giveScoreF.hasFocus) {
//有焦点
if (showDateSelWidget) {
Navigator.pop(context);
showDateSelWidget = false;
}
} else {
//失去焦点
// _editingController.text = '';
}
});
remarkF.addListener(() {
if (remarkF.hasFocus) {
//有焦点
if (showDateSelWidget) {
Navigator.pop(context);
showDateSelWidget = false;
}
} else {
//失去焦点
// _editingController.text = '';
}
});
}
_initWeekData() {
FilterBtnModel filterBtnModel = FilterBtnModel();
filterBtnModel.select = false;
filterBtnModel.title = '周日';
weekData.add(filterBtnModel);
for (int i = 1; i < 7; i++) {
FilterBtnModel filterBtnModel = FilterBtnModel();
filterBtnModel.select = false;
filterBtnModel.title = '周${Utils.formatWeekDayNum(i)}';
weekData.add(filterBtnModel);
}
}
///输入框
Widget _text(
String title,
String hintText,
) {
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
child: Text(
title,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
),
Spacer(),
Text(
hintText,
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32),
),
),
HEmptyView(32)
],
),
);
}
///时间选择
Widget _select(String title, String hintText, GestureTapCallback onTap) {
return InkWell(
onTap: onTap,
child: Container(
padding: EdgeInsets.only(left: ScreenUtil().setWidth(32)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// height: ScreenUtil().setWidth(40),
// color: Colors.red,
child: Text(
title,
style: TextStyle(
color: title == '点击设置可用日期'
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
),
HEmptyView(20),
Spacer(),
Text(hintText,
style: TextStyle(
color: hintText == '点击设置开始日期' || hintText == '点击设置结束日期'
? MyColours.color_999999
: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
)),
HEmptyView(20),
Image.asset(
Utils.getImgPath('arrow_right_new'),
width: ScreenUtil().setWidth(18),
),
HEmptyView(32),
],
),
),
);
}
///券说明
Widget _explain(String title, String hintText,
TextEditingController controller, FocusNode node) {
return Container(
// height: ScreenUtil().setWidth(380),
// padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(
title,
textAlign: TextAlign.left,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
)),
VEmptyView(26),
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_E7E7E7,
// ),
Padding(
padding: EdgeInsets.only(left: w(20)),
child: Text(
'beihaisehfisehfasfhaise',
// maxLengthEnforced: true,
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_999999), //输入文本的样式
)),
],
),
);
}
_itemRadioWidget(bool select, String title, {GestureTapCallback onTap}) {
return InkWell(
onTap: onTap,
child: Row(children: [
Image.asset(
Utils.getImgPath(
select ? 'plan_dish_select' : 'plan_dish_unselect'),
width: w(20),
),
HEmptyView(6),
Text(
title,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
]));
}
///是否立即启用
Widget _canUse(String title, bool swich, GestureTapCallback onTap) {
return InkWell(
onTap: onTap,
child: Container(
// padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
// margin: EdgeInsets.only(right: ScreenUtil().setWidth(32)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// height: ScreenUtil().setWidth(40),
// color: Colors.red,
child: Text(
'是否启用',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
),
Spacer(),
Container(
// height: ScreenUtil().setWidth(40),
// color: Colors.red,
child: Text(
'启用/禁用',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32)),
),
),
HEmptyView(20)
// Image.asset(
// swich
// ? Utils.getImgPath('swich_on')
// : Utils.getImgPath('swich_off'),
// width: ScreenUtil().setWidth(44 * 2),
// )
],
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar('充值优惠详情'),
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(left: w(32)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
VEmptyView(24),
_text(
'活动名称',
'活动名称',
),
VEmptyView(24),
MyDivider(
double.infinity,
w(1),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_text(
'充值满',
'充值金额门槛',
),
VEmptyView(24),
MyDivider(
double.infinity,
w(1),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
Container(
alignment: Alignment.centerLeft,
child: Text(
'优惠活动',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
),
VEmptyView(26),
Padding(
padding: EdgeInsets.only(left: w(20)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'赠送1000元余额',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32)),
),
VEmptyView(20),
Text(
'赠送1000积分',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32)),
),
VEmptyView(20),
Text(
'赠送优惠券',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32)),
),
Padding(
padding: EdgeInsets.only(
left: w(45),
right: w(8),
),
child: Wrap(
spacing: w(9),
runSpacing: w(9),
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: coupons.map((e) {
return Text(
e,
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32)),
);
}).toList())),
VEmptyView(20),
],
),
),
MyDivider(
double.infinity,
w(1),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
Container(
alignment: Alignment.centerLeft,
child: Text(
'有效期',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
),
VEmptyView(24),
Padding(
padding: EdgeInsets.only(left: w(20)),
child: Text(
'2021.2.2-2022.3.4/周日、周一、周二/会员生日当天',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32)),
)),
VEmptyView(24),
MyDivider(
double.infinity,
w(1),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_explain('备注', '请输入备注信息', remarkC, remarkF),
VEmptyView(24),
_canUse('立即启用', canUse, () {
setState(() {
canUse = !canUse;
});
})
],
)),
)),
// Container(
// height: ScreenUtil().setWidth(91 * 2),
// width: double.infinity,
// padding: EdgeInsets.only(
// top: ScreenUtil().setWidth(16 * 2),
// bottom: ScreenUtil().setWidth(35 * 2),
// left: ScreenUtil().setWidth(45 * 2),
// right: ScreenUtil().setWidth(45 * 2),
// ),
// decoration: BoxDecoration(
// color: MyColours.color_ffffff,
// boxShadow: [
// BoxShadow(
// spreadRadius: ScreenUtil().setWidth(2),
// color: Color.fromRGBO(0, 0, 0, 0.1),
// offset: Offset(0, ScreenUtil().setWidth(-2)),
// blurRadius: ScreenUtil().setWidth(8))
// ],
// borderRadius: BorderRadius.all(
// Radius.circular(ScreenUtil().setWidth(16)),
// ),
// ),
// child: RoundButton(
// text: '保存',
// height: ScreenUtil().setWidth(80),
// radius: ScreenUtil().setWidth(14),
// isBold: false,
// fontSize: 28,
// onPressed: () async {
// // "stime": fromDate == '点击选择'
// // ? ""
// // : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',
// // "etime": endDate == '点击选择'
// // ? ''
// // : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}',
// // UserModel userModel =
// // Provider.of<UserModel>(context, listen: false);
// // if (userModel.user.role_name == '管理员' ||
// // userModel.user.role_name == '店长') {
// // NavigatorUtil.goRechargeDetailPage(context);
// // } else {
// // bool needRefresh =
// // await NavigatorUtil.goCouponEditPage(context);
// // print(needRefresh);
// // if (needRefresh != null && needRefresh) {
// // bus.emit('refresh_coupon_list_f');
// // //刷新页面数据
// // // _controller.callRefresh();
// // // _couponNetworkData(tabController.index);
// // }
// // }
// },
// ),
// )
],
),
);
}
}
... ...
... ... @@ -57,6 +57,10 @@ class _RechargeEditPageState extends State<RechargeEditPage> {
List<String> selectIDs = [];
bool givePriceSwich = false;
bool giveScoreSwich = false;
bool giveCouponsSwich = false;
@override
void initState() {
super.initState();
... ... @@ -414,226 +418,266 @@ class _RechargeEditPageState extends State<RechargeEditPage> {
),
),
VEmptyView(26),
Padding(
padding: EdgeInsets.only(
left: w(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Row(
children: [
Image.asset(
Utils.getImgPath(
true ? 'f_select' : 'f_select_not'),
width: w(20),
InkWell(
onTap: () {
setState(() {
givePriceSwich = !givePriceSwich;
});
},
child: Padding(
padding: EdgeInsets.only(
left: w(16),
right: w(8),
),
HEmptyView(16),
Text(
'赠送',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
child: Image.asset(
Utils.getImgPath(givePriceSwich
? 'f_select'
: 'f_select_not'),
width: w(20),
),
HEmptyView(16),
Container(
width: w(140),
height: w(28),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
width: w(1),
color: MyColours.color_DBDBDB)),
child: TextField(
controller: givePriceC,
focusNode: givePricF,
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
),
),
Text(
'赠送',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
HEmptyView(16),
Container(
width: w(140),
height: w(28),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
width: w(1),
color: MyColours.color_DBDBDB)),
child: TextField(
controller: givePriceC,
focusNode: givePricF,
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
),
// focusNode: title == '券名称' ? _nameFocusNode : _requireFocusNode,
decoration: InputDecoration(
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32),
),
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
contentPadding: EdgeInsets.zero,
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType:
TextInputType.numberWithOptions(),
),
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
),
HEmptyView(16),
Text(
'元余额',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
// focusNode: title == '券名称' ? _nameFocusNode : _requireFocusNode,
decoration: InputDecoration(
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32),
),
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
contentPadding: EdgeInsets.zero,
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
),
],
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.numberWithOptions(),
),
),
VEmptyView(20),
Row(
children: [
Image.asset(
Utils.getImgPath(
true ? 'f_select' : 'f_select_not'),
width: w(20),
HEmptyView(16),
Text(
'元余额',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
],
),
VEmptyView(20),
Row(
children: [
InkWell(
onTap: () {
setState(() {
giveScoreSwich = !giveScoreSwich;
});
},
child: Padding(
padding: EdgeInsets.only(
left: w(16),
right: w(8),
),
HEmptyView(16),
Text(
'赠送',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
child: Image.asset(
Utils.getImgPath(giveScoreSwich
? 'f_select'
: 'f_select_not'),
width: w(20),
),
HEmptyView(16),
Container(
width: w(140),
height: w(28),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
width: w(1),
color: MyColours.color_DBDBDB)),
child: TextField(
controller: giveScoreC,
focusNode: giveScoreF,
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
),
),
Text(
'赠送',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
HEmptyView(16),
Container(
width: w(140),
height: w(28),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
width: w(1),
color: MyColours.color_DBDBDB)),
child: TextField(
controller: giveScoreC,
focusNode: giveScoreF,
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
),
// focusNode: title == '券名称' ? _nameFocusNode : _requireFocusNode,
decoration: InputDecoration(
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32),
),
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
contentPadding: EdgeInsets.zero,
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
),
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context).requestFocus(
FocusNode()); //点击空白处隐藏键盘
},
keyboardType:
TextInputType.numberWithOptions(),
),
// //光标颜色
// cursorColor:
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32),
),
HEmptyView(16),
Text(
'积分',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
// focusNode: title == '券名称' ? _nameFocusNode : _requireFocusNode,
decoration: InputDecoration(
isCollapsed:
true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide: BorderSide.none),
hintText: '',
hintStyle: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(32),
),
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
contentPadding: EdgeInsets.zero,
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide.none,
),
),
],
onChanged: (value) {},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(FocusNode()); //点击空白处隐藏键盘
},
keyboardType: TextInputType.numberWithOptions(),
),
),
VEmptyView(20),
Row(
children: [
Image.asset(
Utils.getImgPath(
true ? 'f_select' : 'f_select_not'),
width: w(20),
HEmptyView(16),
Text(
'积分',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
],
),
VEmptyView(20),
Row(
children: [
InkWell(
onTap: () {
setState(() {
giveCouponsSwich = !giveCouponsSwich;
});
},
child: Padding(
padding: EdgeInsets.only(
left: w(16),
right: w(8),
),
HEmptyView(16),
Text(
'赠送优惠券',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
child: Image.asset(
Utils.getImgPath(giveCouponsSwich
? 'f_select'
: 'f_select_not'),
width: w(20),
),
HEmptyView(60),
InkWell(
onTap: () async {
Map object = await NavigatorUtil
.goRechargeSelectStoreCouponPage(
context, selectIDs.join(','));
print(object);
if (object != null &&
object['couponsid'] != null) {
List<CouponSunModel> data =
object['couponsdata'];
//
selectIDs = object['couponsid'];
coupons = [];
data.forEach((element) {
if (element.isCheck) {
coupons.add(element.aname);
}
});
setState(() {});
}
},
child: Text(
'选择优惠券',
style: TextStyle(
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(32)),
)),
],
),
),
Text(
'赠送优惠券',
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
),
VEmptyView(20),
Wrap(
spacing: w(9),
runSpacing: w(9),
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: coupons.map((e) {
return Text(
e,
HEmptyView(60),
if (giveCouponsSwich)
InkWell(
onTap: () async {
Map object = await NavigatorUtil
.goRechargeSelectStoreCouponPage(
context, selectIDs.join(','));
print(object);
if (object != null &&
object['couponsid'] != null) {
List<CouponSunModel> data =
object['couponsdata'];
//
selectIDs = object['couponsid'];
coupons = [];
data.forEach((element) {
if (element.isCheck) {
coupons.add(element.aname);
}
});
setState(() {});
}
},
child: Text(
'选择优惠券',
style: TextStyle(
color: MyColours.color_515151,
color: MyColours.color_438E93,
fontSize: ScreenUtil().setSp(32)),
);
}).toList()),
VEmptyView(20),
)),
],
)),
),
if (giveCouponsSwich) VEmptyView(20),
if (giveCouponsSwich)
Padding(
padding: EdgeInsets.only(
left: w(45),
right: w(8),
),
child: Wrap(
spacing: w(9),
runSpacing: w(9),
alignment: WrapAlignment.start,
runAlignment: WrapAlignment.start,
children: coupons.map((e) {
return Text(
e,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(32)),
);
}).toList())),
VEmptyView(20),
],
),
MyDivider(
double.infinity,
w(1),
... ...
... ... @@ -3,11 +3,13 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/pages/my/marketing_center/recharge/recharge_item.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:provider/provider.dart';
import '../../../../constant/state.dart';
import '../../../../provider/marketing_center_provider.dart';
import '../../../../provider/user_model.dart';
import '../../../../route/navigator_util.dart';
import '../../../../utils/screen_util.dart';
import '../../../../widgets/page_exception.dart';
... ... @@ -33,6 +35,11 @@ class _RechargeHomePageState extends State<RechargeHomePage> {
Widget build(BuildContext context) {
marketingCenterProvider =
Provider.of<MarketingCenterProvider>(context, listen: true);
bool showBtn = Provider.of<UserModel>(context, listen: false)
.user
.role_name ==
'管理员' ||
Provider.of<UserModel>(context, listen: false).user.role_name == '店长';
return Scaffold(
backgroundColor: MyColours.color_f3f3f3,
appBar: SystemAppBar(
... ... @@ -73,16 +80,22 @@ class _RechargeHomePageState extends State<RechargeHomePage> {
return RechargeItem(
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]);
// },
showBtn: showBtn,
onPressedDel: () {
// couponProvider.couponList[index].isOpenBool =
// !couponProvider.couponList[index].isOpenBool;
// _setCustomerActivity(index);
},
onPressedUse: () {},
onPressed: () {
if (showBtn) {
//跳进编辑页
NavigatorUtil.goRechargeEditPage(context);
} else {
//查看页
NavigatorUtil.goRechargeDetailPage(context);
}
},
);
}, childCount: 100),
),
... ... @@ -128,54 +141,59 @@ class _RechargeHomePageState extends State<RechargeHomePage> {
}
}),
)),
Container(
height: ScreenUtil().setWidth(91 * 2),
width: double.infinity,
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(16 * 2),
bottom: ScreenUtil().setWidth(35 * 2),
left: ScreenUtil().setWidth(45 * 2),
right: ScreenUtil().setWidth(45 * 2),
),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
spreadRadius: ScreenUtil().setWidth(2),
color: Color.fromRGBO(0, 0, 0, 0.1),
offset: Offset(0, ScreenUtil().setWidth(-2)),
blurRadius: ScreenUtil().setWidth(8))
],
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(16)),
if (Provider.of<UserModel>(context, listen: false).user.role_name ==
'管理员' ||
Provider.of<UserModel>(context, listen: false).user.role_name ==
'店长')
Container(
height: ScreenUtil().setWidth(91 * 2),
width: double.infinity,
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(16 * 2),
bottom: ScreenUtil().setWidth(35 * 2),
left: ScreenUtil().setWidth(45 * 2),
right: ScreenUtil().setWidth(45 * 2),
),
),
child: RoundButton(
text: '新建优惠',
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(14),
isBold: false,
fontSize: 28,
onPressed: () async {
// UserModel userModel =
// Provider.of<UserModel>(context, listen: false);
// if (userModel.user.role_name == '管理员' ||
// userModel.user.role_name == '店长') {
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
spreadRadius: ScreenUtil().setWidth(2),
color: Color.fromRGBO(0, 0, 0, 0.1),
offset: Offset(0, ScreenUtil().setWidth(-2)),
blurRadius: ScreenUtil().setWidth(8))
],
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(16)),
),
),
child: RoundButton(
text: '新建优惠',
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(14),
isBold: false,
fontSize: 28,
onPressed: () async {
// UserModel userModel =
// Provider.of<UserModel>(context, listen: false);
// if (userModel.user.role_name == '管理员' ||
// userModel.user.role_name == '店长') {
NavigatorUtil.goRechargeEditPage(context);
// } else {
// bool needRefresh =
// await NavigatorUtil.goCouponEditPage(context);
// print(needRefresh);
// if (needRefresh != null && needRefresh) {
// bus.emit('refresh_coupon_list_f');
// //刷新页面数据
// // _controller.callRefresh();
// // _couponNetworkData(tabController.index);
// }
// }
},
),
)
// } else {
// Utils.showToast('您还没有相关权限');
// // bool needRefresh =
// // await NavigatorUtil.goCouponEditPage(context);
// // print(needRefresh);
// // if (needRefresh != null && needRefresh) {
// // bus.emit('refresh_coupon_list_f');
// // //刷新页面数据
// // // _controller.callRefresh();
// // // _couponNetworkData(tabController.index);
// // }
// }
},
),
)
],
),
),
... ...
... ... @@ -10,24 +10,27 @@ 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';
import '../../../../provider/user_model.dart';
import '../../../../utils/screen_util.dart';
class RechargeItem extends StatefulWidget {
final String from;
final VoidCallback onPressed;
final VoidCallback onPressedSwich;
final VoidCallback onPressedDel;
final VoidCallback onPressedUse;
final CouponSunModel couponSonModel;
final bool showBtn;
final bool showCheck;
RechargeItem(
{Key key,
this.from,
this.onPressed,
this.onPressedSwich,
this.couponSonModel,
this.showBtn = false,
this.showCheck = false})
: super(key: key);
RechargeItem({
Key key,
this.from,
this.onPressed,
this.onPressedDel,
this.onPressedUse,
this.couponSonModel,
this.showBtn = false,
this.showCheck = false,
}) : super(key: key);
@override
_RechargeItemState createState() => _RechargeItemState();
... ... @@ -108,15 +111,12 @@ class _RechargeItemState extends State<RechargeItem> {
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
),
InkWell(
onTap: widget.onPressedSwich,
child: Text('更新时间:2022-12-18',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(20))),
),
Text('更新时间:2022-12-18',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(20))),
],
),
),
... ... @@ -136,7 +136,7 @@ class _RechargeItemState extends State<RechargeItem> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_999999,
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(20),
)),
),
... ... @@ -148,7 +148,7 @@ class _RechargeItemState extends State<RechargeItem> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_999999,
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(20),
)),
),
... ... @@ -160,7 +160,7 @@ class _RechargeItemState extends State<RechargeItem> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: MyColours.color_999999,
color: MyColours.color_999999,
fontSize: ScreenUtil().setSp(20),
)),
),
... ... @@ -182,44 +182,46 @@ class _RechargeItemState extends State<RechargeItem> {
// : Container()
// :
),
MySeparator(width: w(4), color: MyColours.color_BFC4D4),
VEmptyView(15),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
RoundButton(
width: widget.from == 'history'
? ScreenUtil().setWidth(50 * 2)
: ScreenUtil().setWidth(50 * 2),
height: ScreenUtil().setWidth(20 * 2),
radius: ScreenUtil().setWidth(10),
text: '删除',
fontSize: 24,
textColor: MyColours.color_E34D59,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_E34D59,
onPressed: widget.onPressedSwich,
),
HEmptyView(34),
RoundButton(
width: ScreenUtil().setWidth(50 * 2),
height: ScreenUtil().setWidth(20 * 2),
radius: ScreenUtil().setWidth(10),
text: '禁用',
if (widget.showBtn)
MySeparator(width: w(4), color: MyColours.color_BFC4D4),
if (widget.showBtn) VEmptyView(15),
if (widget.showBtn)
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
RoundButton(
width: widget.from == 'history'
? ScreenUtil().setWidth(50 * 2)
: ScreenUtil().setWidth(50 * 2),
height: ScreenUtil().setWidth(20 * 2),
radius: ScreenUtil().setWidth(10),
text: '删除',
fontSize: 24,
textColor: MyColours.color_E34D59,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_E34D59,
onPressed: widget.onPressedDel,
),
HEmptyView(34),
RoundButton(
width: ScreenUtil().setWidth(50 * 2),
height: ScreenUtil().setWidth(20 * 2),
radius: ScreenUtil().setWidth(10),
text: '禁用',
///启用
fontSize: 24,
textColor: MyColours.color_438E93,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
onPressed: widget.onPressedSwich,
),
HEmptyView(38),
],
),
VEmptyView(15)
///启用
fontSize: 24,
textColor: MyColours.color_438E93,
gradientStart: MyColours.color_ffffff,
gradientEnd: MyColours.color_ffffff,
borderColor: MyColours.color_438E93,
onPressed: widget.onPressedUse,
),
HEmptyView(38),
],
),
if (widget.showBtn) VEmptyView(15)
],
),
));
... ...
... ... @@ -1571,4 +1571,13 @@ class NavigatorUtil {
"${Routes.recharge_select_store_coupon_page}?selectIDs=$selectIDs",
replace: replace);
}
///充值优惠详情页
static Future<dynamic> goRechargeDetailPage(
BuildContext context, {
replace = false,
}) {
return _navigateTo(context, "${Routes.recharge_detail_page}",
replace: replace);
}
}
... ...
... ... @@ -189,6 +189,7 @@ import '../pages/my/marketing_center/book_notification/marking_coupon_select_pag
import '../pages/my/marketing_center/book_notification/marking_preview_page.dart';
import '../pages/my/marketing_center/book_notification/store_introduce_page.dart';
import '../pages/my/marketing_center/marketing_center_home_page.dart';
import '../pages/my/marketing_center/recharge/recharge_detail_page.dart';
import '../pages/my/marketing_center/recharge/recharge_edit_page.dart';
import '../pages/my/marketing_center/recharge/recharge_home_page.dart';
import '../pages/my/marketing_center/recharge/recharge_select_store_coupon_page.dart';
... ... @@ -2526,3 +2527,19 @@ var rechargeSelectStoreCouponPageHandle = new Handler(
create: (_) => CouponProvider(),
child: RechargeSelectStoreCouponPage(selectList: selectList)));
});
///充值优惠详情页
var rechargeDetailPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// OutWineRecordSunModel outWineRecordSunModel = OutWineRecordSunModel.fromJson(
// json.decode(
// FluroConvertUtils.fluroCnParamsDecode(params["detail"].first)));
// String selectIDs = params["selectIDs"].first;
// List<String> selectList = [];
// if (selectIDs.length > 0) {
// selectList = selectIDs.split(',');
// }
return ChangeNotifierProvider<MarketingCenterProvider>(
create: (_) => MarketingCenterProvider(), child: RechargeDetailPage());
});
... ...
... ... @@ -229,6 +229,10 @@ class Routes {
static String recharge_edit_page = "/recharge_edit_page"; //充值优惠详情编辑页
static String recharge_select_store_coupon_page =
"/recharge_select_store_coupon_page"; //充值优惠选择店铺可核销优惠券
static String recharge_detail_page =
"/recharge_detail_page"; //充值优惠详情页
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -443,5 +447,9 @@ class Routes {
router.define(recharge_select_store_coupon_page,
handler: rechargeSelectStoreCouponPageHandle);
router.define(recharge_detail_page,
handler: rechargeDetailPageHandle);
}
}
... ...
... ... @@ -84,7 +84,7 @@ class SystemAppBar extends StatelessWidget implements PreferredSizeWidget {
? Image.asset(
Utils.getImgPath(
rightImgName.replaceAll('.png', '')),
width: ScreenUtil().setWidth(48))
width: ScreenUtil().setWidth(40))
: Container(
// color: Colors.red,
alignment: Alignment.center,
... ...
... ... @@ -78,6 +78,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
barcode_scan2:
dependency: "direct main"
description:
name: barcode_scan2
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.2.4"
boolean_selector:
dependency: transitive
description:
... ... @@ -1001,6 +1008,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.2.1"
protobuf:
dependency: transitive
description:
name: protobuf
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
provider:
dependency: "direct main"
description:
... ...
... ... @@ -186,6 +186,9 @@ dependencies:
image: ^4.0.15
image_cropper: ^3.0.1
pin_code_fields: ^7.4.0
# 二维码扫描
barcode_scan2: ^4.2.4
# qr_code_scanner: ^1.0.1
#表格多选组建
... ...