Commit cda8c356eeac6b4f497f52698d92c7c054260036

Authored by gaiyaguang
2 parents 886d2d9f 55689d71

v1.4.1

397933a8f93ced880f583fe557299f5c
\ No newline at end of file
196f9f292c7f47fcf809595ac8fc6ce8
\ No newline at end of file
... ...
... ... @@ -146,4 +146,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa
COCOAPODS: 1.9.1
COCOAPODS: 1.9.3
... ...
import 'package:json_annotation/json_annotation.dart';
part 'sms_info.g.dart';
@JsonSerializable()
class SmsInfo extends Object {
@JsonKey(name: 'ret')
int ret;
@JsonKey(name: 'data')
SmsInfoData data;
@JsonKey(name: 'msg')
String msg;
SmsInfo(
this.ret,
this.data,
this.msg,
);
factory SmsInfo.fromJson(Map<String, dynamic> srcJson) =>
_$sms_infoFromJson(srcJson);
Map<String, dynamic> toJson() => _$sms_infoToJson(this);
}
@JsonSerializable()
class SmsInfoData extends Object {
@JsonKey(name: 'last_num')
String lastNum;
@JsonKey(name: 'meals')
List<Meals> meals;
SmsInfoData(
this.lastNum,
this.meals,
);
factory SmsInfoData.fromJson(Map<String, dynamic> srcJson) =>
_$DataFromJson(srcJson);
Map<String, dynamic> toJson() => _$DataToJson(this);
}
@JsonSerializable()
class Meals extends Object {
@JsonKey(name: 'id')
String id;
@JsonKey(name: 'package_name')
String packageName;
@JsonKey(name: 'total')
String total;
@JsonKey(name: 'price_ave')
String priceAve;
@JsonKey(name: 'price_old')
String priceOld;
@JsonKey(name: 'price')
String price;
@JsonKey(name: 'discount')
String discount;
Meals(
this.id,
this.packageName,
this.total,
this.priceAve,
this.priceOld,
this.price,
this.discount,
);
factory Meals.fromJson(Map<String, dynamic> srcJson) =>
_$MealsFromJson(srcJson);
Map<String, dynamic> toJson() => _$MealsToJson(this);
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'sms_info.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
SmsInfo _$sms_infoFromJson(Map<String, dynamic> json) {
return SmsInfo(
json['ret'] as int,
json['data'] == null
? null
: SmsInfoData.fromJson(json['data'] as Map<String, dynamic>),
json['msg'] as String);
}
Map<String, dynamic> _$sms_infoToJson(SmsInfo instance) => <String, dynamic>{
'ret': instance.ret,
'data': instance.data,
'msg': instance.msg
};
SmsInfoData _$DataFromJson(Map<String, dynamic> json) {
return SmsInfoData(
json['last_num'] as String,
(json['meals'] as List)
?.map((e) =>
e == null ? null : Meals.fromJson(e as Map<String, dynamic>))
?.toList());
}
Map<String, dynamic> _$DataToJson(SmsInfoData instance) =>
<String, dynamic>{'last_num': instance.lastNum, 'meals': instance.meals};
Meals _$MealsFromJson(Map<String, dynamic> json) {
return Meals(
json['id'] as String,
json['package_name'] as String,
json['total'] as String,
json['price_ave'] as String,
json['price_old'] as String,
json['price'] as String,
json['discount'] as String);
}
Map<String, dynamic> _$MealsToJson(Meals instance) => <String, dynamic>{
'id': instance.id,
'package_name': instance.packageName,
'total': instance.total,
'price_ave': instance.priceAve,
'price_old': instance.priceOld,
'price': instance.price,
'discount': instance.discount
};
... ...
... ... @@ -37,4 +37,5 @@ class HttpUrl {
"?service=Android.Customer.SetReserveInfo"; //更改在线预订
static const String set_switch_status =
"?service=App.Reserve.SetSwitchStatus"; //启用/停用桌位
static const String sms_info = "?service=App.SendSMS.SmsInfo"; //短信余量查询及套餐查询接口
}
... ...
... ... @@ -55,9 +55,9 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
String formatPhone = ""; //格式客户号码
bool isRefused=false;//是否已拒绝
bool isPause=false;//是否暂停预订
StateSetter refuseDialogState;//决绝弹框setState
bool isRefused = false; //是否已拒绝
bool isPause = false; //是否暂停预订
StateSetter refuseDialogState; //决绝弹框setState
@override
void initState() {
... ... @@ -91,7 +91,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
}
}
});
if (detailEntity.status != "0"&&!isPause) {
if (detailEntity.status != "0" && !isPause) {
//已处理
Future.delayed(Duration(milliseconds: 200), () {
NavigatorUtil.goNotebookDetailPage(context, detailEntity.id,
... ... @@ -118,140 +118,195 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
//拒绝订单弹框
_showRefuseDialog2() {
Widget dialogContent=StatefulBuilder(
builder: (context,setState){
refuseDialogState=setState;
Container container=Container(
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: [
Positioned(
right: 0,
top: ScreenUtil().setWidth(6),
child: GestureDetector(
child: Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(21)),
child: Image.asset("assets/close.png",width: ScreenUtil().setWidth(28),height: ScreenUtil().setWidth(28),),
),
onTap: (){
Navigator.of(context).pop();
},
),
),
Offstage(
offstage: isRefused,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
VEmptyView(40),
Text("拒绝订单",style: TextStyle(fontSize: ScreenUtil().setSp(32),color: MyColours.color_353535,fontWeight: FontWeight.bold),),
VEmptyView(60),
Text("确定要拒绝订单吗?一旦拒绝无法恢复。",style: TextStyle(fontSize: ScreenUtil().setSp(32),color: MyColours.color_353535),),
VEmptyView(80),
GestureDetector(
onTap: (){
setReserveStatus("6",ac: "1");
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
color: MyColours.color_199095,
child: Text("拒绝并暂停预订",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_ffffff),),
),
),
VEmptyView(20),
GestureDetector(
onTap: (){
Navigator.of(context).pop();
setReserveStatus("6");
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border.all(color: MyColours.color_199095,width: ScreenUtil().setWidth(2))
),
child: Text("直接拒绝",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_199095),),
),
),
VEmptyView(20),
GestureDetector(
onTap: () async {
Navigator.of(context).pop();
Map temp = await NavigatorUtil.goSelectTablePage(
context,
widget.rid,
int.parse(detailEntity.ddate) * 1000,
detailEntity.ddate_solt);
if (temp != null && temp['tid'] != null) {
setReserveStatus("5", tid: temp['tid']);
}
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
color: MyColours.color_ffffff,
child: Text("去安排包间",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_199095),),
),
),
VEmptyView(44),
],
),
),
Offstage(
offstage: !isRefused,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
VEmptyView(98),
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset("assets/icon_refuse_book.png",width: ScreenUtil().setWidth(56),height: ScreenUtil().setWidth(56),),
HEmptyView(10),
Text("订单已拒绝",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_353535),)
],
),
Offstage(
offstage: !isPause,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
VEmptyView(20),
Text("并已将${detailEntity.ddateMd}的${detailEntity.demandStr}置满",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_353535),),
],
),
),
VEmptyView(120),
Text("如果有包间空出来或其他包间也满了,你可以:",style: TextStyle(fontSize: ScreenUtil().setSp(26),color: MyColours.color_353535),),
VEmptyView(20),
GestureDetector(
onTap: (){
Utils.goMiniProgramZm(context);
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
color: MyColours.color_199095,
child: Text("去管理包间",style: TextStyle(fontSize: ScreenUtil().setSp(34),color: MyColours.color_ffffff),),
),
),
VEmptyView(60)
],
),
)
],
),
);
return container;
},
);
Widget dialogContent = StatefulBuilder(
builder: (context, setState) {
refuseDialogState = setState;
Container container = Container(
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: [
Positioned(
right: 0,
top: ScreenUtil().setWidth(6),
child: GestureDetector(
child: Container(
padding: EdgeInsets.all(ScreenUtil().setWidth(21)),
child: Image.asset(
"assets/close.png",
width: ScreenUtil().setWidth(28),
height: ScreenUtil().setWidth(28),
),
),
onTap: () {
Navigator.of(context).pop();
},
),
),
Offstage(
offstage: isRefused,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
VEmptyView(40),
Text(
"拒绝订单",
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_353535,
fontWeight: FontWeight.bold),
),
VEmptyView(60),
Text(
"确定要拒绝订单吗?一旦拒绝无法恢复。",
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_353535),
),
VEmptyView(80),
GestureDetector(
onTap: () {
setReserveStatus("6", ac: "1");
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
color: MyColours.color_199095,
child: Text(
"拒绝并暂停预订",
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_ffffff),
),
),
),
VEmptyView(20),
GestureDetector(
onTap: () {
Navigator.of(context).pop();
setReserveStatus("6");
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2))),
child: Text(
"直接拒绝",
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_199095),
),
),
),
VEmptyView(20),
GestureDetector(
onTap: () async {
Navigator.of(context).pop();
Map temp = await NavigatorUtil.goSelectTablePage(
context,
widget.rid,
int.parse(detailEntity.ddate) * 1000,
detailEntity.ddate_solt);
if (temp != null && temp['tid'] != null) {
setReserveStatus("5", tid: temp['tid']);
}
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
color: MyColours.color_ffffff,
child: Text(
"去安排包间",
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_199095),
),
),
),
VEmptyView(44),
],
),
),
Offstage(
offstage: !isRefused,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
VEmptyView(98),
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/icon_refuse_book.png",
width: ScreenUtil().setWidth(56),
height: ScreenUtil().setWidth(56),
),
HEmptyView(10),
Text(
"订单已拒绝",
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_353535),
)
],
),
Offstage(
offstage: !isPause,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
VEmptyView(20),
Text(
"并已将${detailEntity.ddateMd}的${detailEntity.demandStr}置满",
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_353535),
),
],
),
),
VEmptyView(120),
Text(
"如果有包间空出来或其他包间也满了,你可以:",
style: TextStyle(
fontSize: ScreenUtil().setSp(26),
color: MyColours.color_353535),
),
VEmptyView(20),
GestureDetector(
onTap: () {
Utils.goMiniProgramZm(context, "roomtype/roomtype");
},
child: Container(
width: ScreenUtil().setWidth(336),
height: ScreenUtil().setWidth(80),
alignment: Alignment.center,
color: MyColours.color_199095,
child: Text(
"去管理包间",
style: TextStyle(
fontSize: ScreenUtil().setSp(34),
color: MyColours.color_ffffff),
),
),
),
VEmptyView(60)
],
),
)
],
),
);
return container;
},
);
Widget dialog = Container(
width: double.infinity,
decoration: BoxDecoration(
... ... @@ -259,20 +314,19 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
borderRadius: BorderRadius.only(
topLeft: Radius.circular(ScreenUtil().setWidth(40)),
topRight: Radius.circular(ScreenUtil().setWidth(40)))),
child:dialogContent
);
child: dialogContent);
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (context) {
return Stack(
children: <Widget>[dialog],
);
});
return Stack(
children: <Widget>[dialog],
);
});
}
//处理在线预订
setReserveStatus(String status, {String tid = "",String ac=""}) async {
setReserveStatus(String status, {String tid = "", String ac = ""}) async {
bus.emit("remove_untreated_message", widget.mid);
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> causeMap = {
... ... @@ -287,20 +341,20 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
"mid": widget.mid,
"cause": json.encode(causeMap)
};
if(status=="6"){
isPause=true;
params['ac']=ac;//0=直接拒绝 1=拒绝并暂停预订
if (status == "6") {
isPause = true;
params['ac'] = ac; //0=直接拒绝 1=拒绝并暂停预订
}
bool success =
await detailModel.setReserveStatus(context, params, ifPush:(isPause?false:true),showLoading: true);
bool success = await detailModel.setReserveStatus(context, params,
ifPush: (isPause ? false : true), showLoading: true);
if (success != null && success) {
bus.emit("refresh_book_list");
if(status=="6"){
isRefused=true;
if (status == "6") {
isRefused = true;
}
if(isPause){
if (isPause) {
_getOrderListData();
refuseDialogState((){});
refuseDialogState(() {});
}
}
}
... ... @@ -498,7 +552,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
),
),
Offstage(
offstage: detailEntity.status!="0",
offstage: detailEntity.status != "0",
child: Container(
margin: EdgeInsets.only(
top: ScreenUtil().setHeight(30),
... ... @@ -513,12 +567,14 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
onPress: () async {
Map map = await NavigatorUtil
.goSelectTablePage(
context,
widget.rid,
int.parse(detailEntity.ddate) *
1000,
detailEntity.ddate_solt);
if (map != null && map['tid'] != null) {
context,
widget.rid,
int.parse(
detailEntity.ddate) *
1000,
detailEntity.ddate_solt);
if (map != null &&
map['tid'] != null) {
setReserveStatus("5",
tid: map['tid']);
}
... ... @@ -536,63 +592,69 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: GestureDetector(
child: Center(
child: Text(
"拒绝订单",
style: TextStyle(
color:
MyColours.color_199095,
fontSize:
ScreenUtil().setSp(34)),
),
),
onTap: () {
_showRefuseDialog2();
},
)),
child: Center(
child: Text(
"拒绝订单",
style: TextStyle(
color: MyColours
.color_199095,
fontSize: ScreenUtil()
.setSp(34)),
),
),
onTap: () {
_showRefuseDialog2();
},
)),
Offstage(
offstage: !isCallTel,
child: SizedBox(
width: ScreenUtil().setWidth(335),
height: ScreenUtil().setWidth(84),
width:
ScreenUtil().setWidth(335),
height:
ScreenUtil().setWidth(84),
child: Row(
children: [
MyDivider(
ScreenUtil().setWidth(2),
ScreenUtil().setHeight(52),
color:
MyColours.color_199095,
ScreenUtil()
.setHeight(52),
color: MyColours
.color_199095,
),
Expanded(
child: GestureDetector(
child: Center(
child: Text(
"联系顾客",
style: TextStyle(
color: MyColours
.color_199095,
fontSize:
child: Center(
child: Text(
"联系顾客",
style: TextStyle(
color: MyColours
.color_199095,
fontSize:
ScreenUtil()
.setSp(34)),
),
),
onTap: () {
if (detailEntity.phone !=
.setSp(
34)),
),
),
onTap: () {
if (detailEntity
.phone !=
null &&
detailEntity.phone
.isNotEmpty) {
Utils.goPhone(
detailEntity.phone);
} else {
Utils.showToast(
"没有客户电话!");
}
},
)),
detailEntity.phone
.isNotEmpty) {
Utils.goPhone(
detailEntity
.phone);
} else {
Utils.showToast(
"没有客户电话!");
}
},
)),
],
),
),
... ...
... ... @@ -56,6 +56,8 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
int xgCount = 1; //注册信鸽次数,最多5次
DateTime lastBack;
@override
void initState() {
// TODO: implement initState
... ... @@ -303,31 +305,32 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
@override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(
bottomNavigationBar: BottomNavigationBar(
iconSize: ScreenUtil().setWidth(48),
unselectedFontSize: ScreenUtil().setSp(22),
selectedFontSize: ScreenUtil().setSp(22),
backgroundColor: MyColours.color_ffffff,
items: [
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/message_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
activeIcon: Image(
image: AssetImage("assets/message_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
title: Text(
"消息中心",
style: TextStyle(
color: _currIndex == 0 ? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
return new WillPopScope(
child: Scaffold(
bottomNavigationBar: BottomNavigationBar(
iconSize: ScreenUtil().setWidth(48),
unselectedFontSize: ScreenUtil().setSp(22),
selectedFontSize: ScreenUtil().setSp(22),
backgroundColor: MyColours.color_ffffff,
items: [
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/message_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
activeIcon: Image(
image: AssetImage("assets/message_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
title: Text(
"消息中心",
style: TextStyle(
color: _currIndex == 0 ? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
),
),
),
// BottomNavigationBarItem(
// icon: Image(
// image: AssetImage("assets/message_default.png"),
... ... @@ -346,150 +349,162 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
// fontSize: ScreenUtil().setSp(22)),
// ),
// ),
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/notebook_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
activeIcon: Image(
image: AssetImage("assets/notebook_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
title: Text(
"已预订",
style: TextStyle(
color: _currIndex == 1 ? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
),
),
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/tablemanage_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/notebook_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
activeIcon: Image(
image: AssetImage("assets/notebook_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
title: Text(
"已预订",
style: TextStyle(
color: _currIndex == 1 ? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
),
),
activeIcon: Image(
image: AssetImage("assets/tablemanage_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/tablemanage_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
activeIcon: Image(
image: AssetImage("assets/tablemanage_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
title: Text(
"桌位",
style: TextStyle(
color: _currIndex == 2 ? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
),
),
title: Text(
"桌位",
style: TextStyle(
color: _currIndex == 2? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/my_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
activeIcon: Image(
image: AssetImage("assets/my_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
title: Text(
"我的",
style: TextStyle(
color: _currIndex == 3 ? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
),
),
),
BottomNavigationBarItem(
icon: Image(
image: AssetImage("assets/my_default.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
activeIcon: Image(
image: AssetImage("assets/my_selected.png"),
width: ScreenUtil().setWidth(48),
height: ScreenUtil().setWidth(48),
),
title: Text(
"我的",
style: TextStyle(
color: _currIndex == 3 ? _activeColor : _defaultColor,
fontSize: ScreenUtil().setSp(22)),
),
),
],
type: BottomNavigationBarType.fixed,
currentIndex: _currIndex,
onTap: (int index) {
if (_currIndex != index) {
setState(() {
_currIndex = index;
});
if (_currIndex == 3) {
Utils.changeStatusColor(color: MyColours.color_199095);
} else {
Utils.changeStatusColor(color: MyColours.color_ffffff);
],
type: BottomNavigationBarType.fixed,
currentIndex: _currIndex,
onTap: (int index) {
if (_currIndex != index) {
setState(() {
_currIndex = index;
});
if (_currIndex == 3) {
Utils.changeStatusColor(color: MyColours.color_199095);
} else {
Utils.changeStatusColor(color: MyColours.color_ffffff);
}
}
}
},
},
),
// bottomNavigationBar: BottomAppBar(
// shape: CircularNotchedRectangle(),
// child: Container(
// height: ScreenUtil().setWidth(98),
// // padding: EdgeInsets.fromLTRB(0, 12, 0, 8),
// child: Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// GestureDetector(
// onTap: () {
// // onTap(0);
// },
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Image(
// image: AssetImage("assets/my_selected.png"),
// width: ScreenUtil().setWidth(44),
// height: ScreenUtil().setWidth(44),
// ),
// Text(
// "我的",
// style: TextStyle(
// color: _currIndex == 2
// ? _activeColor
// : _defaultColor,
// fontSize: ScreenUtil().setSp(22)),
// )
// ],
// )),
// GestureDetector(
// onTap: () {
// // onTap(1);
// },
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Image(
// image: AssetImage("assets/my_selected.png"),
// width: ScreenUtil().setWidth(44),
// height: ScreenUtil().setWidth(44),
// ),
// Text(
// "我的",
// style: TextStyle(
// color: _currIndex == 2
// ? _activeColor
// : _defaultColor,
// fontSize: ScreenUtil().setSp(22)),
// )
// ],
// )),
// Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Image(
// image: AssetImage("assets/my_selected.png"),
// width: ScreenUtil().setWidth(44),
// height: ScreenUtil().setWidth(44),
// ),
// Text(
// "我的",
// style: TextStyle(
// color:
// _currIndex == 2 ? _activeColor : _defaultColor,
// fontSize: ScreenUtil().setSp(22)),
// )
// ],
// )
// ])),
// ),
body: pages[_currIndex],
),
// bottomNavigationBar: BottomAppBar(
// shape: CircularNotchedRectangle(),
// child: Container(
// height: ScreenUtil().setWidth(98),
// // padding: EdgeInsets.fromLTRB(0, 12, 0, 8),
// child: Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// GestureDetector(
// onTap: () {
// // onTap(0);
// },
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Image(
// image: AssetImage("assets/my_selected.png"),
// width: ScreenUtil().setWidth(44),
// height: ScreenUtil().setWidth(44),
// ),
// Text(
// "我的",
// style: TextStyle(
// color: _currIndex == 2
// ? _activeColor
// : _defaultColor,
// fontSize: ScreenUtil().setSp(22)),
// )
// ],
// )),
// GestureDetector(
// onTap: () {
// // onTap(1);
// },
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Image(
// image: AssetImage("assets/my_selected.png"),
// width: ScreenUtil().setWidth(44),
// height: ScreenUtil().setWidth(44),
// ),
// Text(
// "我的",
// style: TextStyle(
// color: _currIndex == 2
// ? _activeColor
// : _defaultColor,
// fontSize: ScreenUtil().setSp(22)),
// )
// ],
// )),
// Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Image(
// image: AssetImage("assets/my_selected.png"),
// width: ScreenUtil().setWidth(44),
// height: ScreenUtil().setWidth(44),
// ),
// Text(
// "我的",
// style: TextStyle(
// color:
// _currIndex == 2 ? _activeColor : _defaultColor,
// fontSize: ScreenUtil().setSp(22)),
// )
// ],
// )
// ])),
// ),
body: pages[_currIndex],
onWillPop: () async {
if (lastBack != null &&
DateTime.now().millisecondsSinceEpoch -
lastBack.millisecondsSinceEpoch <=
3000) {
return true;
}
lastBack = DateTime.now();
Utils.showToast("再次返回退出一键订");
return false;
},
);
}
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart';
import 'package:one_key/models/sms_info.dart';
import 'package:one_key/provider/my_model.dart';
import 'package:one_key/provider/update_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
... ... @@ -22,19 +24,58 @@ class MyPage extends StatefulWidget {
}
}
class MyPageState extends State<MyPage> {
class MyPageState extends State<MyPage> with WidgetsBindingObserver {
String cur_version = "";
bool newVersion = false;
MyModel myModel;
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addObserver(this);
Utils.getCurrVersion().then((version) {
setState(() {
cur_version = "v" + version;
});
});
WidgetsBinding.instance.addPostFrameCallback((_) async {
///获取短信余量
_getSmsInfo(context);
});
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
// TODO: implement didChangeAppLifecycleState
super.didChangeAppLifecycleState(state);
switch (state) {
case AppLifecycleState.resumed: //应用前台可见
_getSmsInfo(context);
break;
case AppLifecycleState.inactive:
print('inactive');
break;
case AppLifecycleState.paused:
print('paused');
break;
case AppLifecycleState.detached:
print('detached');
break;
default:
break;
}
}
///获取短信余量
_getSmsInfo(context) async {
await myModel.getSmsInfo(context);
// setState(() {
// if (smsInfoData != null) {
// smsInfo = smsInfoData?.lastNum;
// }
// });
}
//检查版本更新
... ... @@ -43,9 +84,9 @@ class MyPageState extends State<MyPage> {
updateModel.checkUpdate(context);
}
@override
Widget build(BuildContext context) {
myModel = Provider.of<MyModel>(context, listen: true);
return Stack(
children: <Widget>[
Padding(
... ... @@ -54,10 +95,23 @@ class MyPageState extends State<MyPage> {
children: <Widget>[
VEmptyView(40),
MyItem(
title: "短信管理",
content:
myModel.smsInfo.isNotEmpty ? '剩余${myModel.smsInfo}条' : '',
callback: () {
Utils.goMiniProgramZm(context, "setting/sms");
},
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyItem(
title: "包间类型置满管理",
content: "",
callback: () {
Utils.goMiniProgramZm(context);
Utils.goMiniProgramZm(context, "roomtype/roomtype");
},
),
VEmptyView(40),
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/models/sms_info.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/SmsModel.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class MyModel extends ChangeNotifier{
class MyModel extends ChangeNotifier {
String smsInfo = '';
}
\ No newline at end of file
/// 短信余量查询及套餐查询接口
Future<SmsInfoData> getSmsInfo(BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {"seller_id": userModel.user.sellerid};
try {
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(context, Method.get, HttpUrl.sms_info,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
SmsInfoData data;
if (baseResp?.code == Constant.status_success) {
SmsInfo smsInfo = SmsInfo.fromJson(baseResp.responseData);
if (smsInfo.ret == 200) {
data = smsInfo.data;
} else {
Utils.showToast(smsInfo.msg);
}
} else {
print('查询失败');
}
smsInfo = data.lastNum;
notifyListeners();
return data;
} catch (error) {
if (error is MyError) {
switch (error.type) {
case 1:
print('错误');
break;
case 2:
print('超时');
break;
default:
print('错误');
break;
}
}
}
}
}
... ...
... ... @@ -80,13 +80,15 @@ class Utils {
}
//跳转小程序包间类型置满管理
static goMiniProgramZm(BuildContext context){
UserModel model=Provider.of<UserModel>(context);
static goMiniProgramZm(BuildContext context, String subPath) {
UserModel model = Provider.of<UserModel>(context, listen: false);
launchWeChatMiniProgram(
username: "gh_487873d353b3",
path: "pack-book/pages/book/b_index?seller_id=${model.user.sellerid}&seller_openid=seller_openid&manager_id=&goPath=roomtype/roomtype",
path:
"pack-book/pages/book/b_index?seller_id=${model.user.sellerid}&seller_openid=seller_openid&manager_id=&goPath=${subPath}",
miniProgramType: WXMiniProgramType.RELEASE);
}
//跳转拨打电话页面
static goHelp(BuildContext context) async {
NavigatorUtil.goWebviewPage(context);
... ...