diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 07135df7..fc7afc84 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -31,6 +31,8 @@ class UserProvider extends ChangeNotifier { if (isLogin) { await updateUserInfo(); WebSocketUtil().setUser(userInfoModel!.id.toString()); + WebSocketUtil().setCommunityCode(userInfoModel!.communityCode); + WebSocketUtil().setNickName(userInfoModel!.nickName!); WebSocketUtil().startWebSocket(); await updateMyHouseInfo(); diff --git a/lib/ui/community/facility/facility_preorder_date_picker.dart b/lib/ui/community/facility/facility_preorder_date_picker.dart index 8eae8088..b368dc4b 100644 --- a/lib/ui/community/facility/facility_preorder_date_picker.dart +++ b/lib/ui/community/facility/facility_preorder_date_picker.dart @@ -169,7 +169,7 @@ int getNum(DateTime dateTime) { hour = dateTime.hour; minute = dateTime.minute; if (minute > 0) { - return hour * 2; + return hour * 2+1; } - return hour * 2 + 1; + return hour * 2; } diff --git a/lib/utils/websocket/alarm_models/fire_model.dart b/lib/utils/websocket/alarm_models/fire_model.dart index 751b55cc..5b535853 100644 --- a/lib/utils/websocket/alarm_models/fire_model.dart +++ b/lib/utils/websocket/alarm_models/fire_model.dart @@ -1,25 +1,42 @@ import 'package:json_annotation/json_annotation.dart'; +import 'package:equatable/equatable.dart'; part 'fire_model.g.dart'; @JsonSerializable() -class FireModel { - String? alarmNo; - String? alarmType; - String? deviceName; - String? deviceNo; - String? time; - int? type; +class FireModel extends Equatable { + final String? model; + final String? communityCode; + final int? alarmType; + final String? alarmNo; + final String? deviceNo; + final String? deviceName; + final String? time; + final String? alarmContent; factory FireModel.fromJson(Map json) => _$FireModelFromJson(json); + @override + List get props => [ + model, + communityCode, + alarmType, + alarmNo, + deviceNo, + deviceName, + time, + alarmContent, + ]; + FireModel({ - this.alarmNo, + this.model, + this.communityCode, this.alarmType, - this.deviceName, + this.alarmNo, this.deviceNo, + this.deviceName, this.time, - this.type, + this.alarmContent, }); } diff --git a/lib/utils/websocket/alarm_models/fire_model.g.dart b/lib/utils/websocket/alarm_models/fire_model.g.dart index 092a4003..b4fa2a01 100644 --- a/lib/utils/websocket/alarm_models/fire_model.g.dart +++ b/lib/utils/websocket/alarm_models/fire_model.g.dart @@ -7,10 +7,12 @@ part of 'fire_model.dart'; // ************************************************************************** FireModel _$FireModelFromJson(Map json) => FireModel( + model: json['model'] as String?, + communityCode: json['communityCode'] as String?, + alarmType: json['alarmType'] as int?, alarmNo: json['alarmNo'] as String?, - alarmType: json['alarmType'] as String?, - deviceName: json['deviceName'] as String?, deviceNo: json['deviceNo'] as String?, + deviceName: json['deviceName'] as String?, time: json['time'] as String?, - type: json['type'] as int?, + alarmContent: json['alarmContent'] as String?, ); diff --git a/lib/utils/websocket/web_socket_util.dart b/lib/utils/websocket/web_socket_util.dart index 8cdbc200..12d8869e 100644 --- a/lib/utils/websocket/web_socket_util.dart +++ b/lib/utils/websocket/web_socket_util.dart @@ -7,7 +7,9 @@ import 'package:web_socket_channel/web_socket_channel.dart'; import 'package:aku_new_community/widget/others/user_tool.dart'; -const String baseUri = 'wss://shop.kaidalai.cn/websocket/app'; +// const String baseUri = 'wss://shop.kaidalai.cn/websocket/app'; +const String baseUri = 'wss://saas.kaidalai.cn/websocket/app'; + enum SOCKETSTATUS { CONNECTED, //已连接 BREAKOFF, //已断开 @@ -27,6 +29,8 @@ class WebSocketUtil { ///用户设置不同的服务器地址 String _user = 'admin'; + String _communityCode = 'communityCode'; + String _nickName = 'nickName'; ///连接状态 SOCKETSTATUS _socketStatus = SOCKETSTATUS.CLOSED; @@ -86,12 +90,18 @@ class WebSocketUtil { void setUser(String user) { this._user = user; } + void setCommunityCode(String communityCode) { + this._communityCode = communityCode; + } + void setNickName(String nickName) { + this._nickName = nickName; + } ///开启websocket void startWebSocket() { closeWebSocket(); try { - _webSocket = IOWebSocketChannel.connect(Uri.parse('$baseUri/$_user')); + _webSocket = IOWebSocketChannel.connect(Uri.parse('$baseUri/$_communityCode/$_nickName')); print('webSocket已连接服务器:$baseUri/$_user'); _socketStatus = SOCKETSTATUS.CONNECTED; endReconnect();