修改弹窗

添加手环功能
hmxc
张萌 3 years ago
parent 5ecb32e71c
commit 7eaa5b917e

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@ -27,6 +27,12 @@ class API {
static _Pay pay = _Pay();
static _House house = _House();
static _SarsApi sarsApi = _SarsApi();
static _Bracelet bracelet = _Bracelet();
}
class _Bracelet {
///
String get data => '/user/aqg/getData';
}
class _Login {

@ -730,6 +730,9 @@ class $AssetsIconsGen {
AssetGenImage get shoppingMall =>
const AssetGenImage('assets/icons/shopping_mall.png');
/// File path: assets/icons/sos.png
AssetGenImage get sos => const AssetGenImage('assets/icons/sos.png');
/// File path: assets/icons/system_notice.png
AssetGenImage get systemNotice =>
const AssetGenImage('assets/icons/system_notice.png');

@ -0,0 +1,48 @@
import 'package:json_annotation/json_annotation.dart';
part 'bracelet_model.g.dart';
@JsonSerializable()
class BraceletModel {
final int sbp;
final int todaySteps;
final int bloodOxygen;
final int switchType;
final int dbp;
final int heartRate;
final int remainingPower;
final int detectionDays;
final int alarmNums;
final int fallNums;
factory BraceletModel.fromJson(Map<String, dynamic> json) =>
_$BraceletModelFromJson(json);
String get switchTypeString {
switch (switchType) {
case 0:
return '开机';
case 1:
return '关机';
case 2:
return '开机';
case 3:
return '低电通知';
default:
return '';
}
}
const BraceletModel({
required this.sbp,
required this.todaySteps,
required this.bloodOxygen,
required this.switchType,
required this.dbp,
required this.heartRate,
required this.remainingPower,
required this.detectionDays,
required this.alarmNums,
required this.fallNums,
});
}

@ -0,0 +1,21 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'bracelet_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
BraceletModel _$BraceletModelFromJson(Map<String, dynamic> json) =>
BraceletModel(
sbp: json['sbp'] as int,
todaySteps: json['todaySteps'] as int,
bloodOxygen: json['bloodOxygen'] as int,
switchType: json['switchType'] as int,
dbp: json['dbp'] as int,
heartRate: json['heartRate'] as int,
remainingPower: json['remainingPower'] as int,
detectionDays: json['detectionDays'] as int,
alarmNums: json['alarmNums'] as int,
fallNums: json['fallNums'] as int,
);

@ -1,6 +1,12 @@
import 'package:aku_new_community/constants/api.dart';
import 'package:aku_new_community/gen/assets.gen.dart';
import 'package:aku_new_community/models/bracelet/bracelet_model.dart';
import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:aku_new_community/widget/bee_divider.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:dio/dio.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -15,6 +21,23 @@ class OldAgeSupportPageSimple extends StatefulWidget {
}
class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
BraceletModel? _model;
DateTime? _date;
@override
void initState() {
var cancel = BotToast.showLoading();
getData();
cancel();
super.initState();
}
@override
void dispose() {
BotToast.closeAllLoading();
super.dispose();
}
@override
Widget build(BuildContext context) {
var open = Row(
@ -27,7 +50,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
color: Color(0xFF57DAD2),
),
4.w.widthBox,
'设备 已开机'
'设备 ${_model?.switchTypeString}'
.text
.size(26.sp)
.lineHeight(1.2)
@ -50,7 +73,9 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
end: Alignment.bottomCenter,
colors: [Colors.white, Color(0xFFC0E5DC).withOpacity(0.355)]),
),
child: ListView(
child: _model == null
? Container()
: ListView(
padding: EdgeInsets.symmetric(horizontal: 32.w),
children: [
550.w.heightBox,
@ -59,7 +84,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
'数据更新自 2022年1月1日 18:21:15'
'数据更新自 ${DateUtil.formatDate(_date!, format: DateFormats.full)}'
.text
.size(22.sp)
.color(Colors.black.withOpacity(0.25))
@ -79,6 +104,18 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
);
}
Future getData() async {
Response base =
await NetUtil().dio!.get(API.bracelet.data, queryParameters: {
'imei': 863204050238280,
});
if (base.data != null) {
_model = BraceletModel.fromJson(base.data);
_date = DateTime.now();
}
setState(() {});
}
Container bottomCard() {
var left = Column(
children: [
@ -204,7 +241,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
],
),
Spacer(),
'141'
'${_model?.heartRate}'
.richText
.withTextSpanChildren([
' 次/分'
@ -248,7 +285,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
],
),
Spacer(),
'3'
'${_model?.fallNums}'
.richText
.withTextSpanChildren([
''
@ -292,7 +329,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
],
),
Spacer(),
'1042'
'${_model?.todaySteps}'
.richText
.withTextSpanChildren([
''
@ -332,7 +369,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
Spacer(),
Row(
children: [
'98'
'${_model?.bloodOxygen}'
.richText
.withTextSpanChildren([
' %'
@ -375,7 +412,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
'剩余电量'.text.size(28.sp).color(Colors.black.withOpacity(0.65)).make(),
'58'
'${_model?.remainingPower}'
.richText
.withTextSpanChildren([
' %'
@ -401,7 +438,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
.size(28.sp)
.color(Colors.black.withOpacity(0.45))
.make(),
'58'
'${_model?.detectionDays}'
.richText
.withTextSpanChildren([
''
@ -427,7 +464,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
.size(28.sp)
.color(Colors.black.withOpacity(0.45))
.make(),
'5'
'${_model?.alarmNums}'
.richText
.withTextSpanChildren([
''

@ -1,36 +0,0 @@
class AlarmModel {
String? alarmNo;
String? alarmType;
String? deviceName;
String? deviceNo;
String? time;
int? type;
AlarmModel(
{this.alarmNo,
this.alarmType,
this.deviceName,
this.deviceNo,
this.time,
this.type});
AlarmModel.fromJson(Map<String, dynamic> json) {
alarmNo = json['alarmNo'];
alarmType = json['alarmType'];
deviceName = json['deviceName'];
deviceNo = json['deviceNo'];
time = json['time'];
type = json['type'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['alarmNo'] = this.alarmNo;
data['alarmType'] = this.alarmType;
data['deviceName'] = this.deviceName;
data['deviceNo'] = this.deviceNo;
data['time'] = this.time;
data['type'] = this.type;
return data;
}
}

@ -0,0 +1,24 @@
import 'package:json_annotation/json_annotation.dart';
part 'fall_model.g.dart';
@JsonSerializable()
class FallModel {
final String? userName;
final String? tel;
final String? address;
final num? lon;
final num? lat;
final int? type;
factory FallModel.fromJson(Map<String, dynamic> json) =>
_$FallModelFromJson(json);
const FallModel({
this.userName,
this.tel,
this.address,
this.lon,
this.lat,
this.type,
});
}

@ -0,0 +1,16 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'fall_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
FallModel _$FallModelFromJson(Map<String, dynamic> json) => FallModel(
userName: json['userName'] as String?,
tel: json['tel'] as String?,
address: json['address'] as String?,
lon: json['lon'] as num?,
lat: json['lat'] as num?,
type: json['type'] as int?,
);

@ -0,0 +1,25 @@
import 'package:json_annotation/json_annotation.dart';
part 'fire_model.g.dart';
@JsonSerializable()
class FireModel {
String? alarmNo;
String? alarmType;
String? deviceName;
String? deviceNo;
String? time;
int? type;
factory FireModel.fromJson(Map<String, dynamic> json) =>
_$FireModelFromJson(json);
FireModel({
this.alarmNo,
this.alarmType,
this.deviceName,
this.deviceNo,
this.time,
this.type,
});
}

@ -0,0 +1,16 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'fire_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
FireModel _$FireModelFromJson(Map<String, dynamic> json) => FireModel(
alarmNo: json['alarmNo'] as String?,
alarmType: json['alarmType'] as String?,
deviceName: json['deviceName'] as String?,
deviceNo: json['deviceNo'] as String?,
time: json['time'] as String?,
type: json['type'] as int?,
);

@ -1,29 +1,27 @@
import 'dart:convert';
import 'package:aku_new_community/extensions/num_ext.dart';
import 'package:aku_new_community/gen/assets.gen.dart';
import 'package:aku_new_community/pages/tab_navigator.dart';
import 'package:aku_new_community/utils/developer_util.dart';
import 'package:aku_new_community/utils/headers.dart';
import 'package:aku_new_community/utils/websocket/alarm_models/fall_model.dart';
import 'package:aku_new_community/utils/websocket/alarm_models/fire_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'AlarmModel.dart';
class FireDialog {
static fireAlarm(String content) async {
var json = jsonDecode(content);
AlarmModel alarmModel = AlarmModel.fromJson(json);
int type = json['type'] as int;
await Get.dialog(
CupertinoAlertDialog(
title: getImage(alarmModel),
title: getImage(type),
content: Column(
children: [
Text(getTitle(alarmModel)),
Text(getTitle(type)),
10.hb,
Text(getContent(alarmModel)),
Text(getContent(json, type)),
],
),
actions: [
@ -44,37 +42,52 @@ class FireDialog {
);
}
static String getTitle(AlarmModel alarmModel) {
switch (alarmModel.type) {
static String getTitle(int type) {
switch (type) {
case 1:
return '发现火灾!请立刻组织疏散人群!';
case 2:
return '设备故障';
case 3:
return '管家端APP报警';
case 4:
return '跌倒报警';
case 45:
return 'SOS紧急联系报警';
default:
return '';
}
}
static String getContent(AlarmModel alarmModel) {
switch (alarmModel.type) {
static String getContent(dynamic json, int type) {
switch (type) {
case 1:
var alarmModel = FireModel.fromJson(json);
return '${alarmModel.time},${alarmModel.deviceName}附近出现了火灾报警,请各位业主、租户保持镇静,不要慌乱,有序开始撤离!';
case 2:
var alarmModel = FireModel.fromJson(json);
return '${alarmModel.time},小区内有设备${alarmModel.deviceName}发生了报警,请物业负责人员尽快前往现场排查故障!';
case 3:
var alarmModel = FireModel.fromJson(json);
return '注意:\n${alarmModel.time},${alarmModel.deviceNo}${alarmModel.deviceName}' +
'在管家端app上点击了"一键报警",请尽快联系他沟通情况。\n' +
'${alarmModel.deviceName}联系方式:${alarmModel.alarmNo}\n' +
'如未能联系到${alarmModel.deviceName}。可择情报警';
case 4:
var alarmModel = FallModel.fromJson(json);
return '注意:\n\n有住户 ${alarmModel.userName} 发生跌倒情况,请及时上门或联系人员前往查看,住户联系方式:${alarmModel.tel}\n\n' +
'跌倒位置————\n${alarmModel.address},经度${alarmModel.lon},纬度${alarmModel.lat}\n\n如未能联系到住户,可择情报警';
case 5:
var alarmModel = FallModel.fromJson(json);
return '注意:\n\n有住户 ${alarmModel.userName} 使用了SOS紧急联系报警请及时上门或联系人员前往查看住户联系方式${alarmModel.tel}\n\n' +
'跌倒位置————\n${alarmModel.address},经度${alarmModel.lon},纬度${alarmModel.lat}\n\n如未能联系到住户,可择情报警';
default:
return '';
}
}
static Widget getImage(AlarmModel alarmModel) {
switch (alarmModel.type) {
static Widget getImage(int type) {
switch (type) {
case 1:
return Image.asset(
R.ASSETS_ICONS_FIRE_ALARM_PNG,
@ -96,8 +109,22 @@ class FireDialog {
height: 110.w,
fit: BoxFit.fill,
);
case 4:
return Image.asset(
R.ASSETS_ICONS_APP_ALARM_PNG,
width: 110.w,
height: 110.w,
fit: BoxFit.fill,
);
case 5:
return Image.asset(
Assets.icons.sos.path,
width: 110.w,
height: 110.w,
fit: BoxFit.fill,
);
default:
return SizedBox();
return SizedBox(width: 110.w, height: 110.w);
}
}
}

@ -6,7 +6,7 @@ import 'package:power_logger/power_logger.dart';
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
const String baseUri = 'wss://test.kaidalai.cn/websocket/app';
const String baseUri = 'wss://shop.kaidalai.cn/websocket/app';
enum SOCKETSTATUS {
CONNECTED, //
BREAKOFF, //

Loading…
Cancel
Save