Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smart_hotel_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张宏
smart_hotel_app
Commits
ea90a54a
Commit
ea90a54a
authored
Jun 10, 2026
by
张宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3
parent
cfc4a398
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
52 deletions
+152
-52
service_room_cubit.dart
lib/views/service/room/cubit/service_room_cubit.dart
+20
-2
room_detail_view.dart
lib/views/service/room/room_detail_view.dart
+36
-2
room_bottom_buttons.dart
lib/views/service/room/widget/room_bottom_buttons.dart
+69
-43
对接方案.md
对接方案.md
+27
-5
No files found.
lib/views/service/room/cubit/service_room_cubit.dart
View file @
ea90a54a
...
@@ -146,8 +146,8 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
...
@@ -146,8 +146,8 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
return
Icons
.
devices_other
;
return
Icons
.
devices_other
;
}
}
/// 房间总电源开关
/// 房间总电源开关
Future
<
void
>
toggleMainPower
(
bool
value
)
async
{
Future
<
void
>
toggleMainPower
ForSwitch
(
bool
value
)
async
{
if
(
state
.
isTogglingPower
)
return
;
if
(
state
.
isTogglingPower
)
return
;
emit
(
state
.
copyWith
(
isTogglingPower:
true
));
emit
(
state
.
copyWith
(
isTogglingPower:
true
));
try
{
try
{
...
@@ -164,6 +164,24 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
...
@@ -164,6 +164,24 @@ class ServiceRoomCubit extends Cubit<ServiceRoomState> {
}
}
}
}
/// 房间总电源开关
Future
<
void
>
toggleMainPower
(
bool
value
)
async
{
if
(
state
.
isTogglingPower
)
return
;
emit
(
state
.
copyWith
(
isTogglingPower:
true
));
try
{
if
(
value
)
{
await
_service
.
powerOn
(
deviceId:
_roomId
);
}
else
{
await
_service
.
powerOff
(
deviceId:
_roomId
);
}
emit
(
state
.
copyWith
(
isTogglingPower:
false
,
mainPowerOn:
value
));
}
catch
(
e
)
{
emit
(
state
.
copyWith
(
isTogglingPower:
false
));
// Re-throw so the view can show error snackbar
rethrow
;
}
}
/// 分设备电源开关
/// 分设备电源开关
Future
<
void
>
toggleControlDevice
(
int
index
,
bool
value
)
async
{
Future
<
void
>
toggleControlDevice
(
int
index
,
bool
value
)
async
{
final
devices
=
state
.
controlDevices
;
final
devices
=
state
.
controlDevices
;
...
...
lib/views/service/room/room_detail_view.dart
View file @
ea90a54a
...
@@ -103,7 +103,7 @@ class ServiceRoomDetailView extends StatelessWidget {
...
@@ -103,7 +103,7 @@ class ServiceRoomDetailView extends StatelessWidget {
controlDevices:
state
.
controlDevices
,
controlDevices:
state
.
controlDevices
,
onMainPowerToggle:
(
value
)
async
{
onMainPowerToggle:
(
value
)
async
{
try
{
try
{
await
cubit
.
toggleMainPower
(
value
);
await
cubit
.
toggleMainPower
ForSwitch
(
value
);
if
(
context
.
mounted
)
{
if
(
context
.
mounted
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
SnackBar
(
...
@@ -128,7 +128,41 @@ class ServiceRoomDetailView extends StatelessWidget {
...
@@ -128,7 +128,41 @@ class ServiceRoomDetailView extends StatelessWidget {
},
},
),
),
SizedBox
(
height:
20
.
h
),
SizedBox
(
height:
20
.
h
),
const
RoomBottomButtons
(),
RoomBottomButtons
(
isProcessing:
state
.
isTogglingPower
,
onPowerOn:
()
async
{
try
{
await
cubit
.
toggleMainPower
(
true
);
if
(
context
.
mounted
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'送电成功'
)),
);
}
}
catch
(
e
)
{
if
(
context
.
mounted
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'送电失败:
$e
'
)),
);
}
}
},
onPowerOff:
()
async
{
try
{
await
cubit
.
toggleMainPower
(
false
);
if
(
context
.
mounted
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'断电成功'
)),
);
}
}
catch
(
e
)
{
if
(
context
.
mounted
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'断电失败:
$e
'
)),
);
}
}
},
),
SizedBox
(
height:
20
.
h
),
SizedBox
(
height:
20
.
h
),
],
],
),
),
...
...
lib/views/service/room/widget/room_bottom_buttons.dart
View file @
ea90a54a
...
@@ -2,26 +2,42 @@ import 'package:flutter/material.dart';
...
@@ -2,26 +2,42 @@ import 'package:flutter/material.dart';
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
class
RoomBottomButtons
extends
StatelessWidget
{
class
RoomBottomButtons
extends
StatelessWidget
{
const
RoomBottomButtons
({
super
.
key
});
final
VoidCallback
?
onPowerOn
;
final
VoidCallback
?
onPowerOff
;
final
VoidCallback
?
onDeviceControl
;
final
bool
isProcessing
;
const
RoomBottomButtons
({
super
.
key
,
this
.
onPowerOn
,
this
.
onPowerOff
,
this
.
onDeviceControl
,
this
.
isProcessing
=
false
,
});
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Row
(
return
Row
(
children:
[
children:
[
Expanded
(
Expanded
(
child:
Container
(
child:
GestureDetector
(
height:
88
.
h
,
onTap:
(
onPowerOn
!=
null
&&
!
isProcessing
)
?
onPowerOn
:
null
,
decoration:
BoxDecoration
(
child:
Container
(
color:
const
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
),
height:
88
.
h
,
borderRadius:
BorderRadius
.
circular
(
20
.
r
),
decoration:
BoxDecoration
(
),
color:
(
onPowerOn
!=
null
&&
!
isProcessing
)
child:
Center
(
?
const
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
)
child:
Text
(
:
const
Color
.
fromRGBO
(
204
,
204
,
204
,
1
),
'送电'
,
borderRadius:
BorderRadius
.
circular
(
20
.
r
),
style:
TextStyle
(
),
color:
Colors
.
white
,
child:
Center
(
fontSize:
32
.
sp
,
child:
Text
(
fontWeight:
FontWeight
.
bold
,
'送电'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
32
.
sp
,
fontWeight:
FontWeight
.
bold
,
),
),
),
),
),
),
),
...
@@ -29,23 +45,30 @@ class RoomBottomButtons extends StatelessWidget {
...
@@ -29,23 +45,30 @@ class RoomBottomButtons extends StatelessWidget {
),
),
SizedBox
(
width:
12
.
w
),
SizedBox
(
width:
12
.
w
),
Expanded
(
Expanded
(
child:
Container
(
child:
GestureDetector
(
height:
88
.
h
,
onTap:
(
onPowerOff
!=
null
&&
!
isProcessing
)
?
onPowerOff
:
null
,
decoration:
BoxDecoration
(
child:
Container
(
color:
Colors
.
white
,
height:
88
.
h
,
borderRadius:
BorderRadius
.
circular
(
20
.
r
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
Colors
.
white
,
color:
const
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
),
borderRadius:
BorderRadius
.
circular
(
20
.
r
),
width:
2
.
w
,
border:
Border
.
all
(
color:
(
onPowerOff
!=
null
&&
!
isProcessing
)
?
const
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
)
:
const
Color
.
fromRGBO
(
204
,
204
,
204
,
1
),
width:
2
.
w
,
),
),
),
),
child:
Center
(
child:
Center
(
child:
Text
(
child:
Text
(
'断电'
,
'断电'
,
style:
TextStyle
(
style:
TextStyle
(
color:
(
onPowerOff
!=
null
&&
!
isProcessing
)
color:
const
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
),
?
const
Color
.
fromRGBO
(
66
,
165
,
245
,
1.0
)
fontSize:
32
.
sp
,
:
const
Color
.
fromRGBO
(
100
,
116
,
139
,
1
),
fontWeight:
FontWeight
.
bold
,
fontSize:
32
.
sp
,
fontWeight:
FontWeight
.
bold
,
),
),
),
),
),
),
),
...
@@ -53,19 +76,22 @@ class RoomBottomButtons extends StatelessWidget {
...
@@ -53,19 +76,22 @@ class RoomBottomButtons extends StatelessWidget {
),
),
SizedBox
(
width:
12
.
w
),
SizedBox
(
width:
12
.
w
),
Expanded
(
Expanded
(
child:
Container
(
child:
GestureDetector
(
height:
88
.
h
,
onTap:
onDeviceControl
,
decoration:
BoxDecoration
(
child:
Container
(
color:
const
Color
.
fromRGBO
(
200
,
208
,
220
,
1.0
),
height:
88
.
h
,
borderRadius:
BorderRadius
.
circular
(
20
.
r
),
decoration:
BoxDecoration
(
),
color:
const
Color
.
fromRGBO
(
200
,
208
,
220
,
1.0
),
child:
Center
(
borderRadius:
BorderRadius
.
circular
(
20
.
r
),
child:
Text
(
),
'设备控制'
,
child:
Center
(
style:
TextStyle
(
child:
Text
(
color:
const
Color
.
fromRGBO
(
100
,
116
,
139
,
1.0
),
'设备控制'
,
fontSize:
32
.
sp
,
style:
TextStyle
(
fontWeight:
FontWeight
.
bold
,
color:
const
Color
.
fromRGBO
(
100
,
116
,
139
,
1.0
),
fontSize:
32
.
sp
,
fontWeight:
FontWeight
.
bold
,
),
),
),
),
),
),
),
...
...
对接方案.md
View file @
ea90a54a
# 智慧酒
店 App 接口对接方案
# 智慧酒
店 App 接口对接方案
...
@@ -217,12 +217,15 @@ class xxxBO extends Equatable {
...
@@ -217,12 +217,15 @@ class xxxBO extends Equatable {
|
客房服务看板-断电 |POST | /app/room/device/power/off | 已对接 | 客房服务看板-断电 | |
|
客房服务看板-断电 |POST | /app/room/device/power/off | 已对接 | 客房服务看板-断电 | |
|
客房详情 |GET | /app/room/detail |
未
对接 | 客房详情 | |
|
客房详情 |GET | /app/room/detail |
已
对接 | 客房详情 | |
|
客房详情-房间总电源-switch开 |
GET | /app/room/power/on | 未
对接 | 客房详情-房间总电源-switch开 | |
|
客房详情-房间总电源-switch开 |
POST | /app/room/power/on | 已
对接 | 客房详情-房间总电源-switch开 | |
|
客房详情-房间总电源-switch关 |POST | /app/room/power/off |
未
对接 | 客房详情-房间总电源-switch关 | |
|
客房详情-房间总电源-switch关 |POST | /app/room/power/off |
已
对接 | 客房详情-房间总电源-switch关 | |
|
空调控制 |GET | /app/device/ac/status | 未对接 | 空调控制 | |
|
空调控制 |GET | /app/device/ac/status | 未对接 | 空调控制 | |
|
空调控制-相关操作 |POST | /app/device/ac/control | 未对接 | 空调控制-相关操作 | |
...
@@ -230,6 +233,25 @@ class xxxBO extends Equatable {
...
@@ -230,6 +233,25 @@ class xxxBO extends Equatable {
#
## 3.2 接口详细定义
#
## 3.2 接口详细定义
#
### 空调控制-相关操作
*
*POST /app/device/ac/control**
`
``
请
求体:
{
"deviceId": 0, // 设备ID 必传
"powerOn": true, // 是否开机:true-开机,false-关机 可选
"targetTemperature": 16, // 目标温度(16°C ~ 30°C) 可选
"mode": "string", // 运行模式:cool-制冷,heat-制热,fan-送风,dry-除湿 可选
"fanSpeed": "string" // 风速:low-低速,medium-中速,high-高速,auto-自动 可选
}
响
应 data:
`
``
#
### 空调控制
#
### 空调控制
*
*GET /app/device/ac/status**
*
*GET /app/device/ac/status**
...
@@ -316,7 +338,7 @@ class xxxBO extends Equatable {
...
@@ -316,7 +338,7 @@ class xxxBO extends Equatable {
#
### 客房详情-房间总电源-switch开
#
### 客房详情-房间总电源-switch开
*
*
GE
T /app/room/power/on**
*
*
POS
T /app/room/power/on**
`
``
`
``
请
求体:
请
求体:
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment