Commit 8423d9b0e16ba8ad0e0b52170cd96f8cf4a9a854

Authored by wdn127929
1 parent 56d95d22

浏览图片、更多桌位查看

... ... @@ -25,6 +25,7 @@ import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/input_done_view.dart';
import 'package:one_key/widgets/page_exception.dart';
... ... @@ -57,7 +58,8 @@ class InvicationPage extends StatefulWidget {
}
}
class InvicationPageState extends State<InvicationPage> {
class InvicationPageState extends State<InvicationPage>
with WidgetsBindingObserver {
User user;
DateTime dateTime;
String dateTimeStr = "";
... ... @@ -84,7 +86,7 @@ class InvicationPageState extends State<InvicationPage> {
int couponSelectIndex = 0;
NotebookDetail detailEntity;
String tableInfo; //桌位信息
List<Map<String, String>> tableInfo = []; //桌位信息
String ddate;
String ddateStr;
String phoneWidget;
... ... @@ -103,10 +105,12 @@ class InvicationPageState extends State<InvicationPage> {
String oldSex;
bool needBack = false;
bool needBlack = false;
bool needHistory = false;
String youhui = '选择优惠';
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
personNumList = Utils.getPersonNumList();
... ... @@ -114,7 +118,7 @@ class InvicationPageState extends State<InvicationPage> {
if (_nameNode.hasFocus) {
showOverlay(context);
} else {
if (!needBack && !needBlack) {
if (!needBack && !needBlack && !needHistory && !_phoneNode.hasFocus) {
_showConfirmWidget();
}
removeOverlay();
... ... @@ -125,7 +129,7 @@ class InvicationPageState extends State<InvicationPage> {
if (_phoneNode.hasFocus) {
showOverlay(context);
} else {
if (!needBack && !needBlack) {
if (!needBack && !needBlack && !needHistory && !_nameNode.hasFocus) {
_showConfirmWidget();
}
... ... @@ -137,8 +141,9 @@ class InvicationPageState extends State<InvicationPage> {
couponProvider.sendSMS = false;
await _couponNetworkData(isShowLoading: false);
await _getCustomerActivityBaseinfo();
await _getTablesPhoto();
await _getReserveDetail(showCicle: false);
await _getTablesPhoto();
});
bus.on("refresh_coupon_invitation", (args) {
_couponNetworkData(isShowLoading: false);
... ... @@ -157,11 +162,23 @@ class InvicationPageState extends State<InvicationPage> {
couponProvider.clearSelect();
bus.off("refresh_coupon_invitation");
bus.off("refresh_invitaion_info");
WidgetsBinding.instance.removeObserver(this); //销毁观察者
super.dispose();
}
_showConfirmWidget({needBack = false, needSex = false}) {
@override
void didChangeMetrics() {
super.didChangeMetrics();
print(MediaQuery.of(context).viewInsets.bottom);
if (MediaQuery.of(context).viewInsets.bottom > 0) {
removeOverlay();
}
}
_showConfirmWidget(
{needBack = false, needSex = false, needHistory = false, int index}) {
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
String phone = '';
String name = '';
... ... @@ -172,14 +189,16 @@ class InvicationPageState extends State<InvicationPage> {
if (nameStr != null && nameStr.trim().length > 0) {
name = nameStr;
}
if (oldName != name || oldPhone != phone || needSex) {
if (oldName != name || oldPhone != phone || needSex || needHistory) {
DialogUtil.cupertinoAlertDialog(context,
title: "客户信息",
content: "客户信息已修改,是否确定修改",
lTitle: "取消",
rTitle: "确定修改", lCallback: () {
print("取消");
showPhoneHistory = false;
if (needBack) {
needBack = false;
Navigator.of(context).pop();
} else {
if (needSex) {
... ... @@ -192,10 +211,17 @@ class InvicationPageState extends State<InvicationPage> {
}
}
}
needSex = false;
}
if (needHistory) {
needHistory = false;
}
if (needBlack) {
needBlack = false;
}
if (_baseIndoProvider.phoneController.text.trim().length > 0) {
_baseIndoProvider.phoneController.text = oldPhone;
showPhoneHistory = false;
}
if (nameStr != null && nameStr.trim().length > 0) {
nameStr = oldName;
... ... @@ -210,13 +236,41 @@ class InvicationPageState extends State<InvicationPage> {
setState(() {});
}
}, rCallback: () {
showPhoneHistory = false;
if (needBack) {
needBack = false;
Navigator.of(context).pop();
}
if (needSex) {
needSex = false;
}
if (needHistory) {
setState(() {
showPhoneHistory = false;
_baseIndoProvider.phoneController.text =
_baseIndoProvider.userHistorys[index].phone != null
? _baseIndoProvider.userHistorys[index].phone
: '';
// _homeEnterModel.nameController.text =
// _homeEnterModel
// .userHistorys[index].rname +
// _nameSuffix();
_addNameSuffix(
_baseIndoProvider.userHistorys[index].rname, _nameSuffix());
nameStr = _baseIndoProvider.userHistorys[index].rname;
_phoneNode.unfocus();
_baseIndoProvider.userHistorys.clear();
});
needHistory = false;
}
if (needBlack) {
needBlack = false;
}
_updateReserve();
});
} else {
if (needBack) {
needBack = false;
Navigator.of(context).pop();
}
}
... ... @@ -505,6 +559,10 @@ class InvicationPageState extends State<InvicationPage> {
_nameStr += '${detailEntity.tables[i].name},';
_tid += '${detailEntity.tables[i].id},';
regionName += '${detailEntity.tables[i].rname},';
tableInfo.add({
'name': detailEntity.tables[i].name,
'tid': detailEntity.tables[i].id
});
}
if (_tid.endsWith(',')) {
_tid = _tid.substring(0, _tid.length - 1);
... ... @@ -517,7 +575,8 @@ class InvicationPageState extends State<InvicationPage> {
}
tid = _tid;
tableInfo = _nameStr;
// tableInfo = _nameStr;
ddate = detailEntity.ddate;
ddateStr = detailEntity.ddateStr;
phoneWidget = detailEntity.phone;
... ... @@ -766,26 +825,27 @@ class InvicationPageState extends State<InvicationPage> {
///浏览照片
///
void onTapDown(BuildContext context, TapDownDetails details, GlobalKey key) {
void onTapDown(BuildContext context, TapDownDetails details, GlobalKey key,
String tableid) {
final RenderBox box = context.findRenderObject();
final Offset localOffset = box.globalToLocal(details.globalPosition);
final RenderBox containerBox = key.currentContext.findRenderObject();
final Offset containerOffset = containerBox.localToGlobal(localOffset);
final onTap = containerBox.paintBounds.contains(containerOffset);
if (onTap) {
_seePhoto();
_seePhoto(tableid);
}
}
_seePhoto() {
_seePhoto(tableid) {
// List<String> temp = [];
if (_baseIndoProvider.photoList.length > 0) {
if (_baseIndoProvider.photoList[tableid].length > 0) {
// for (int i = 0; i < _baseIndoProvider.photoList.length; i++) {
// temp.add(_baseIndoProvider.photoList[i].image);
// }
///没有上传完成的不可以点击
_showPhotoView(context, 0, _baseIndoProvider.photoList);
_showPhotoView(context, 0, _baseIndoProvider.photoList[tableid]);
}
}
... ... @@ -967,38 +1027,181 @@ class InvicationPageState extends State<InvicationPage> {
);
}
_tableListWidget(CustomCallBack callback) {
// List<Map<String, String>> temp = []; //桌位信息
// temp.addAll(tableInfo);
// temp.removeAt(0);
// temp.removeAt(0);
List<Widget> lists = tableInfo.map((item) {
final GlobalKey key = new GlobalKey();
return GestureDetector(
onTapDown: (TapDownDetails details) => onTapDown(
context,
details,
key,
item['tid'],
),
child: Container(
child: Stack(
alignment: Alignment.bottomCenter,
overflow: Overflow.visible,
children: [
Container(
margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(18)),
constraints:
BoxConstraints(minWidth: ScreenUtil().setWidth(160)),
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(20),
ScreenUtil().setWidth(20),
ScreenUtil().setWidth(20),
ScreenUtil().setWidth(18 * 2)),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(13 * 2))),
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(4))),
child: Text(
item['name'],
textAlign: TextAlign.center,
style: TextStyle(
// letterSpacing: ScreenUtil()
// .setWidth(2.13 * 2),
color: MyColours.color_333333,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
),
),
Positioned(
key: key,
bottom: 0,
child: RoundButton(
onPressed: () {
_seePhoto(item['tid']);
},
text: '浏览照片',
width: ScreenUtil().setWidth(60 * 2),
height: ScreenUtil().setWidth(18 * 2),
fontSize: 22,
textColor: _baseIndoProvider.photoList.isNotEmpty &&
_baseIndoProvider.photoList[item['tid']].length > 0
? MyColours.color_ffffff
: MyColours.color_ffffff,
isBold: false,
gradientStart: _baseIndoProvider.photoList.isNotEmpty &&
_baseIndoProvider.photoList[item['tid']].length > 0
? MyColours.color_199095
: Color.fromRGBO(154, 154, 154, 1),
gradientEnd: _baseIndoProvider.photoList.isNotEmpty &&
_baseIndoProvider.photoList[item['tid']].length > 0
? MyColours.color_199095
: Color.fromRGBO(154, 154, 154, 1),
))
],
)));
}).toList();
return lists;
}
Future _openTablesDialog(BuildContext context, {CustomCallBack onTap}) async {
final action = await showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return Center(
child: Container(
height: ScreenUtil().setWidth(500),
width: ScreenUtil.screenWidthDp - ScreenUtil().setWidth(80),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
child: Column(children: [
Expanded(
child: ListView(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(40)),
shrinkWrap: true,
children: [
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
runAlignment: WrapAlignment.spaceAround,
alignment: WrapAlignment.center,
children: _tableListWidget((v) {}),
spacing: ScreenUtil().setWidth(20),
runSpacing: ScreenUtil().setWidth(20),
// alignment: WrapAlignment.start,
// runAlignment: WrapAlignment.end,
),
],
)),
MyDivider(double.infinity, ScreenUtil().setWidth(2)),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: double.infinity,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(40)),
child: Text('确定',
style: TextStyle(
color: Color.fromRGBO(42, 96, 244, 1),
fontSize: ScreenUtil().setSp(30))),
),
)
])),
),
);
},
);
}
//构建常用备注
List<Widget> _buildAlwayItems() {
List<String> tableInfoList = tableInfo.split(",");
// List<String> tableInfoList = tableInfo.split(",");
//
List<Widget> tables = [];
for (int i = 0; i < tableInfoList.length; i++) {
for (int i = 0; i < tableInfo.length; i++) {
if (i == 2) {
tables.add(Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(10),
right: ScreenUtil().setWidth(10),
top: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
// border: Border.all(
// color: MyColours.color_E0E0E0,
// width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Text(
'等${tableInfoList.length}个桌位',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095,
),
)));
tables.add(InkWell(
onTap: () {
_openTablesDialog(context);
},
child: Container(
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(10),
right: ScreenUtil().setWidth(10),
top: ScreenUtil().setWidth(10)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
// border: Border.all(
// color: MyColours.color_E0E0E0,
// width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10))),
child: Text(
'等${tableInfo.length}个桌位',
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_199095,
),
))));
return tables;
} else {
final GlobalKey key = new GlobalKey();
tables.add(
GestureDetector(
onTapDown: (TapDownDetails details) =>
onTapDown(context, details, key),
onTapDown: (TapDownDetails details) => onTapDown(
context,
details,
key,
tableInfo[i]['tid'],
),
child: Container(
child: Stack(
alignment: Alignment.bottomCenter,
... ... @@ -1020,7 +1223,7 @@ class InvicationPageState extends State<InvicationPage> {
color: MyColours.color_199095,
width: ScreenUtil().setWidth(4))),
child: Text(
tableInfoList[i],
tableInfo[i]['name'],
textAlign: TextAlign.center,
style: TextStyle(
// letterSpacing: ScreenUtil()
... ... @@ -1035,20 +1238,29 @@ class InvicationPageState extends State<InvicationPage> {
bottom: 0,
child: RoundButton(
onPressed: () {
_seePhoto();
_seePhoto(tableInfo[i]['tid']);
},
text: '浏览照片',
width: ScreenUtil().setWidth(60 * 2),
height: ScreenUtil().setWidth(18 * 2),
fontSize: 22,
textColor: _baseIndoProvider.photoList.length > 0
textColor: _baseIndoProvider.photoList.isNotEmpty &&
_baseIndoProvider
.photoList[tableInfo[i]['tid']].length >
0
? MyColours.color_ffffff
: MyColours.color_ffffff,
isBold: false,
gradientStart: _baseIndoProvider.photoList.length > 0
gradientStart: _baseIndoProvider.photoList.isNotEmpty &&
_baseIndoProvider
.photoList[tableInfo[i]['tid']].length >
0
? MyColours.color_199095
: Color.fromRGBO(154, 154, 154, 1),
gradientEnd: _baseIndoProvider.photoList.length > 0
gradientEnd: _baseIndoProvider.photoList.isNotEmpty &&
_baseIndoProvider
.photoList[tableInfo[i]['tid']].length >
0
? MyColours.color_199095
: Color.fromRGBO(154, 154, 154, 1),
))
... ... @@ -1503,33 +1715,10 @@ class InvicationPageState extends State<InvicationPage> {
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
setState(() {
showPhoneHistory = false;
_baseIndoProvider
.phoneController
.text = _baseIndoProvider
.userHistorys[index]
.phone !=
null
? _baseIndoProvider
.userHistorys[index]
.phone
: '';
// _homeEnterModel.nameController.text =
// _homeEnterModel
// .userHistorys[index].rname +
// _nameSuffix();
_addNameSuffix(
_baseIndoProvider
.userHistorys[index]
.rname,
_nameSuffix());
nameStr = _baseIndoProvider
.userHistorys[index].rname;
_phoneNode.unfocus();
_baseIndoProvider.userHistorys
.clear();
});
needHistory = true;
_showConfirmWidget(
needHistory: true,
index: index);
},
child: Container(
width: double.infinity,
... ... @@ -2009,14 +2198,14 @@ class InvicationPageState extends State<InvicationPage> {
// }
Utils.showToast('请输入客户手机号');
} else if (!Utils.phoneRegExp(reserverPhone)) {
Utils.showToast('手机号错误,请修改正确');
Utils.showToast('手机号格式错误,请修改正确');
//跳转到录入联系人页面
String temp = await NavigatorUtil.goEditReserverPage(
context, widget.rid, name, sex,
needBtn: true);
if (temp != null) {
reserverPhone = temp;
}
// String temp = await NavigatorUtil.goEditReserverPage(
// context, widget.rid, name, sex,
// needBtn: true);
// if (temp != null) {
// reserverPhone = temp;
// }
} else {
if (!couponProvider.sendSMS) {
/*
... ... @@ -2131,88 +2320,90 @@ class InvicationPageState extends State<InvicationPage> {
needBlack = true;
_showConfirmWidget();
},
child: Column(
children: [
Container(
width: double.infinity,
// color: backgroundColor,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(30)),
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
left: 0,
child: GestureDetector(
onTap: () {
needBack = true;
_showConfirmWidget(needBack: true);
},
behavior: HitTestBehavior.opaque,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setHeight(15)),
child: Image.asset(
"assets/icon_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setHeight(31),
child: Container(
color: MyColours.color_ffffff,
child: Column(
children: [
Container(
width: double.infinity,
// color: backgroundColor,
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(30)),
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
left: 0,
child: GestureDetector(
onTap: () {
needBack = true;
_showConfirmWidget(needBack: true);
},
behavior: HitTestBehavior.opaque,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setHeight(15)),
child: Image.asset(
"assets/icon_back.png",
width: ScreenUtil().setWidth(20),
height: ScreenUtil().setHeight(31),
),
),
),
),
),
),
Center(
child: Image.asset(
"assets/yd_logo.png",
width: ScreenUtil().setWidth(103 * 2),
// height: ScreenUtil().setHeight(21 * 2),
))
],
)),
Expanded(child:
Consumer<BaseIndoProvider>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () async {
model.pageState = PageState.Loading;
await _couponNetworkData(isShowLoading: false);
await _getCustomerActivityBaseinfo();
await _getTablesPhoto();
await _getReserveDetail(showCicle: false);
model.notifyListeners();
},
emptyMsg: "稍后加载",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
Center(
child: Image.asset(
"assets/yd_logo.png",
width: ScreenUtil().setWidth(103 * 2),
// height: ScreenUtil().setHeight(21 * 2),
))
],
)),
Expanded(child: Consumer<BaseIndoProvider>(
builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () async {
model.pageState = PageState.Loading;
await _couponNetworkData(isShowLoading: false);
await _getCustomerActivityBaseinfo();
await _getTablesPhoto();
await _getReserveDetail(showCicle: false);
model.notifyListeners();
},
emptyMsg: "稍后加载",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Column(
children: [
VEmptyView(40),
_managerWidget(),
VEmptyView(50),
_orderInfoWidget(),
VEmptyView(30),
_couponWidget(),
VEmptyView(20),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
VEmptyView(40),
_managerWidget(),
VEmptyView(50),
_orderInfoWidget(),
VEmptyView(30),
_couponWidget(),
VEmptyView(20),
],
))),
_btnWidget(),
],
))),
_btnWidget(),
],
),
);
}
})),
],
),
),
);
}
})),
],
)),
// body: Stack(
// children: [
... ...
... ... @@ -15,7 +15,7 @@ import 'package:provider/provider.dart';
class BaseIndoProvider with ChangeNotifier {
BaseInfoSunModel baseInfoSunModel; //客户经理基础信息
List<String> photoList = []; //商家图片信息
Map<String, List<String>> photoList = {}; //商家图片信息
PageState pageState = PageState.Loading;
... ... @@ -185,9 +185,24 @@ class BaseIndoProvider with ChangeNotifier {
} else {
List<TablePhotoSunModel> tablePhotoList =
TablePhotoModel.fromJson(baseResp.responseData).data;
for (int i = 0; i < tablePhotoList.length; i++) {
photoList.add(tablePhotoList[i].url);
String tid = params['tableids'];
List<String> tids = tid.split(',');
Map<String, List<String>> photos = {};
for (String tid in tids) {
photos[tid] = [];
}
for (String tid in tids) {
for (TablePhotoSunModel item in tablePhotoList) {
if (tid == item.tableid) {
List<String> list = photos.putIfAbsent(tid, () => []);
list.add(item.url);
photos[tid] = list;
}
}
}
print(photos);
photoList = photos;
// photoList.add(tablePhotoList[i].url);
notifyListeners();
}
} else {
... ...
... ... @@ -457,15 +457,17 @@ class CouponProvider with ChangeNotifier {
} else {
List<CouponSunModel> coupon =
CouponModel.fromJson(baseResp.responseData).data;
hasModify = false;
for (int i = 0; i < couponListSelect.length; i++) {
// coupons.add(couponListSelect[i].id);
// couponsShow.add(couponTemp[i].id);
if (coupon[0].id == couponListSelect[i].id) {
index = i;
hasModify = true;
}
}
hasModify = true;
notifyListeners();
}
} else {
... ...