对接 智慧养老

fix bugs
pull/1/head
张萌 3 years ago
parent 53ee58cf1c
commit 4deeb6ab10

@ -58,6 +58,12 @@ class _City {
class _Bracelet {
///
String get data => '/app/user/elderlyCareEquipment/getAqgData';
///
String get add => '/app/user/elderlyCareEquipment/bind';
///
String get list => '/app/user/elderlyCareEquipment/list';
}
class _User {

@ -1,3 +1,4 @@
import 'package:aku_new_community/provider/old_age_provider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -40,6 +41,7 @@ class _MyAppState extends State<MyApp> {
ChangeNotifierProvider(create: (context) => SignUpProvider()),
ChangeNotifierProvider(create: (context) => DataProvider()),
ChangeNotifierProvider(create: (context) => ClockTimerProvider()),
ChangeNotifierProvider(create: (context) => OldAgeProvider()),
],
child: GestureDetector(
onTap: () {

@ -0,0 +1,33 @@
import 'package:aku_new_community/pages/services/old_age/old_enum.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'bracelet_list_model.g.dart';
@JsonSerializable()
class BraceletListModel extends Equatable {
final int id;
final int type;
final String deviceType;
final String imei;
factory BraceletListModel.fromJson(Map<String, dynamic> json) =>
_$BraceletListModelFromJson(json);
BraceletBrand get braceletBrand => BraceletBrand.getValue(type);
const BraceletListModel({
required this.id,
required this.type,
required this.deviceType,
required this.imei,
});
@override
List<Object?> get props => [
id,
type,
deviceType,
imei,
];
}

@ -1,11 +1,15 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'test.dart';
part of 'bracelet_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Test _$TestFromJson(Map<String, dynamic> json) => Test(
BraceletListModel _$BraceletListModelFromJson(Map<String, dynamic> json) =>
BraceletListModel(
id: json['id'] as int,
type: json['type'] as int,
deviceType: json['deviceType'] as String,
imei: json['imei'] as String,
);

@ -1,20 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'test.g.dart';
@JsonSerializable()
class Test extends Equatable {
final int id;
factory Test.fromJson(Map<String, dynamic> json) => _$TestFromJson(json);
@override
List<Object?> get props => [
id,
];
const Test({
required this.id,
});
}

@ -1,3 +1,5 @@
import 'package:aku_new_community/extensions/widget_list_ext.dart';
import 'package:aku_new_community/widget/bee_divider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -31,6 +33,7 @@ class _BalanceRecordViewState extends State<BalanceRecordView> {
int _pickType = 0;
Map<int, String> _types = {
0: '全部',
1: '支付',
2: '退还',
3: '充值',
@ -89,7 +92,7 @@ class _BalanceRecordViewState extends State<BalanceRecordView> {
return BeePickerBox(
onPressed: () {
Get.back();
setState(() {});
_refreshController.callRefresh();
},
child: CupertinoPicker.builder(
itemExtent: 60.w,
@ -142,7 +145,7 @@ class _BalanceRecordViewState extends State<BalanceRecordView> {
.getList(SAASAPI.balance.tradeRecordList, params: {
'pageNum': _pageNum,
'size': _size,
'modelType': 0,
'modelType': 1,
'type': _pickType == 0 ? null : _pickType,
'createDate':
DateUtil.formatDate(_pickTime, format: DateFormats.full),
@ -176,7 +179,11 @@ class _BalanceRecordViewState extends State<BalanceRecordView> {
},
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
children: _models.map((e) => _buildCard(e)).toList(),
children: _models.map((e) => _buildCard(e)).toList().sepWidget(
separate: Padding(
padding: EdgeInsets.symmetric(vertical: 20.w),
child: BeeDivider(),
)),
),
),
),
@ -189,6 +196,7 @@ class _BalanceRecordViewState extends State<BalanceRecordView> {
Widget _buildCard(TradeRecordListModel model) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [

@ -1,3 +1,6 @@
import 'package:aku_new_community/extensions/widget_list_ext.dart';
import 'package:aku_new_community/gen/assets.gen.dart';
import 'package:aku_new_community/widget/bee_divider.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -31,6 +34,7 @@ class _PointRecordViewState extends State<PointRecordView> {
int _pickType = 0;
Map<int, String> _types = {
0:'全部',
1: '支付',
2: '退还',
3: '充值',
@ -89,7 +93,7 @@ class _PointRecordViewState extends State<PointRecordView> {
return BeePickerBox(
onPressed: () {
Get.back();
setState(() {});
_refreshController.callRefresh();
},
child: CupertinoPicker.builder(
itemExtent: 60.w,
@ -142,7 +146,7 @@ class _PointRecordViewState extends State<PointRecordView> {
.getList(SAASAPI.balance.tradeRecordList, params: {
'pageNum': _pageNum,
'size': _size,
'modelType': 1,
'modelType': 2,
'type': _pickType == 0 ? null : _pickType,
'createDate':
DateUtil.formatDate(_pickTime, format: DateFormats.full),
@ -175,7 +179,10 @@ class _PointRecordViewState extends State<PointRecordView> {
},
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
children: _models.map((e) => _buildCard(e)).toList(),
children: _models.map((e) => _buildCard(e)).toList().sepWidget(separate: Padding(
padding: EdgeInsets.symmetric(vertical: 20.w),
child: BeeDivider(),
)),
),
),
),
@ -188,6 +195,7 @@ class _PointRecordViewState extends State<PointRecordView> {
Widget _buildCard(TradeRecordListModel model) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
@ -197,13 +205,14 @@ class _PointRecordViewState extends State<PointRecordView> {
.color(Colors.black.withOpacity(0.85))
.make(),
Spacer(),
'${incom(model.type) ? '+' : '-'}¥${model.payAmount}'
'${incom(model.type) ? '+' : '-'}${model.payAmount.toInt()}'
.text
.size(28.sp)
.color(incom(model.type)
? Colors.red
: Colors.black.withOpacity(0.85))
.make(),
Assets.icons.intergral.image(width: 32.w,height: 32.w),
],
),
8.hb,

@ -34,7 +34,7 @@ class _WalletRechargePageState extends State<WalletRechargePage>
late TabController _tabController;
List<String> _tabs = ['余额充值', '积分充值'];
List<int> _balanceValue = [10, 20, 30, 50, 00, 200, 300, 500];
List<int> _balanceValue = [10, 20, 30, 50, 100, 200, 300, 500];
List<int> _pointValue = [10, 200, 300, 500, 1000, 2000, 5000, 10000];
int _rechargeValue = 0;

@ -1,29 +1,20 @@
import 'package:aku_new_community/constants/saas_api.dart';
import 'package:aku_new_community/models/bracelet/bracelet_list_model.dart';
import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_new_community/extensions/widget_list_ext.dart';
import 'package:aku_new_community/gen/assets.gen.dart';
import 'package:aku_new_community/pages/services/old_age/add_equipment_page.dart';
import 'package:aku_new_community/widget/bee_divider.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
class bracelet {
String title;
String describe;
bool open;
String path;
bracelet({
required this.title,
required this.describe,
required this.open,
required this.path,
});
}
import 'add_equipment_page.dart';
class EquipmentListPage extends StatefulWidget {
const EquipmentListPage({Key? key}) : super(key: key);
@ -33,20 +24,8 @@ class EquipmentListPage extends StatefulWidget {
}
class _EquipmentListPageState extends State<EquipmentListPage> {
List<bracelet> _connects = [
bracelet(
title: 'x5手环',
describe: '爱牵挂',
open: true,
path: Assets.bracelet.x5.path),
];
List<bracelet> _bracelets = [
bracelet(
title: 'x8手环 旗舰型',
describe: '爱牵挂',
open: false,
path: Assets.bracelet.x8.path),
];
BraceletListModel? _currentBracelet;
List<BraceletListModel> _bracelets = [];
@override
Widget build(BuildContext context) {
@ -82,49 +61,8 @@ class _EquipmentListPageState extends State<EquipmentListPage> {
.bold
.make(),
24.w.heightBox,
..._connects
.map((e) => Container(
width: double.infinity,
padding: EdgeInsets.all(24.w),
decoration: BoxDecoration(
color: Color(0xFF6395D7),
borderRadius: BorderRadius.circular(16.w)),
child: Row(
children: [
Image.asset(
e.path,
width: 100.w,
height: 100.w,
),
12.w.widthBox,
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
'${e.title}'.text.size(24.sp).white.make(),
16.w.heightBox,
'${e.describe}'.text.size(24.sp).white.make(),
],
),
Spacer(),
Container(
width: 15.w,
height: 16.w,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.w),
),
),
24.w.widthBox,
'${e.open ? '已连接' : '未开启'}'
.text
.size(24.sp)
.white
.make(),
],
),
))
.toList()
.sepWidget(separate: 24.w.heightBox),
if (_currentBracelet != null)
_braceletWidget(e: _currentBracelet!, bgColor: Color(0xFF6395D7))
],
),
);
@ -141,16 +79,81 @@ class _EquipmentListPageState extends State<EquipmentListPage> {
.make(),
24.w.heightBox,
..._bracelets
.map((e) => Container(
.map((e) => _braceletWidget(
e: e,
onTap: () {
_currentBracelet = e;
setState(() {});
}))
.toList()
.sepWidget(
separate: 24.w.heightBox,
),
],
),
);
return BeeScaffold(
title: '设备列表',
bodyColor: Colors.white,
body: SafeArea(
child: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
onRefresh: () async {
var base = await NetUtil().get(SAASAPI.bracelet.list);
if (base.success) {
_bracelets = (base.data as List)
.map((e) => BraceletListModel.fromJson(e))
.toList();
setState(() {});
}
},
child: ListView(
padding: EdgeInsets.all(24.w),
children: [
// user,
// BeeDivider.horizontal(),
connected,
24.w.heightBox,
bingding,
BeeDivider.horizontal(),
// 24.w.heightBox,
],
),
),
),
bottomNavi: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
child: MaterialButton(
onPressed: () {
Get.to(() => AddEquipmentPage());
},
color: Color(0xFF5096F1),
padding: EdgeInsets.symmetric(vertical: 24.w),
minWidth: 686.w,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.w),
),
child: '添加设备'.text.size(28.sp).white.make(),
),
),
);
}
Widget _braceletWidget(
{required BraceletListModel e, VoidCallback? onTap, Color? bgColor}) {
return GestureDetector(
onTap: onTap,
child: Container(
width: double.infinity,
padding: EdgeInsets.all(24.w),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.06),
color: bgColor ?? Colors.black.withOpacity(0.06),
borderRadius: BorderRadius.circular(16.w)),
child: Row(
children: [
Image.asset(
e.path,
e.braceletBrand.imgPath,
width: 100.w,
height: 100.w,
),
@ -159,13 +162,13 @@ class _EquipmentListPageState extends State<EquipmentListPage> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
'${e.title}'
'${e.deviceType} ${e.braceletBrand.name}'
.text
.size(24.sp)
.color(Colors.black.withOpacity(0.65))
.make(),
16.w.heightBox,
'${e.describe}'
'设备码:${e.imei}'
.text
.size(24.sp)
.color(Colors.black.withOpacity(0.65))
@ -182,51 +185,14 @@ class _EquipmentListPageState extends State<EquipmentListPage> {
),
),
24.w.widthBox,
'${e.open ? '已连接' : '未开启'}'
'${UserTool.oldAgeProvider.imei == e.imei ? '已连接' : '未开启'}'
.text
.size(24.sp)
.color(Colors.black.withOpacity(0.65))
.make(),
],
),
))
.toList()
.sepWidget(
separate: 24.w.heightBox,
),
],
),
);
return BeeScaffold(
title: '设备列表',
bodyColor: Colors.white,
body: SafeArea(
child: ListView(
padding: EdgeInsets.all(24.w),
children: [
// user,
// BeeDivider.horizontal(),
connected,
24.w.heightBox,
bingding,
BeeDivider.horizontal(),
// 24.w.heightBox,
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
TextButton(
onPressed: () {
Get.to(() => AddEquipmentPage());
},
child: '添加智能设备'
.text
.size(28.sp)
.color(Color(0xFF6395D7))
.make()),
],
)
],
)),
);
}
}

@ -1,16 +1,17 @@
import 'dart:async';
import 'package:aku_new_community/constants/saas_api.dart';
import 'package:aku_new_community/utils/network/base_model.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart' hide Response;
import 'package:velocity_x/velocity_x.dart';
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/pages/services/old_age/add_equipment_page.dart';
@ -31,17 +32,35 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
BraceletModel? _model;
DateTime? _date;
Timer? _timer;
void _startTimer() {
_timer = Timer.periodic(Duration(seconds: 5), (timer) {
_date = DateTime.now();
getData();
});
}
void _disposeTimer() {
_timer?.cancel();
_timer = null;
}
@override
void initState() {
Future.delayed(Duration.zero, () async {
var cancel = BotToast.showLoading();
getData();
await getData();
cancel();
_startTimer();
});
super.initState();
}
@override
void dispose() {
BotToast.closeAllLoading();
_disposeTimer();
super.dispose();
}
@ -130,17 +149,14 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
}
Future getData() async {
var cancel = BotToast.showLoading();
BaseModel base =
await NetUtil().get(SAASAPI.bracelet.data, params: {
'imei': 863204050238280,
BaseModel base = await NetUtil().get(SAASAPI.bracelet.data, params: {
'imei': UserTool.oldAgeProvider.imei,
});
if (base.data != null) {
_model = BraceletModel.fromJson(base.data);
_date = DateTime.now();
}
setState(() {});
cancel();
}
Container bottomCard() {
@ -441,7 +457,7 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
'剩余电量'.text.size(28.sp).color(Colors.black.withOpacity(0.65)).make(),
'${_model?.remainingPower??0}'
'${_model?.remainingPower ?? 0}'
.richText
.withTextSpanChildren([
' %'
@ -547,6 +563,16 @@ class _OldAgeSupportPageSimpleState extends State<OldAgeSupportPageSimple> {
),
),
),
actions: [
IconButton(
icon: Icon(CupertinoIcons.repeat),
iconSize: 30.w,
color: Colors.black,
onPressed: () {
Get.to(() => EquipmentListPage());
},
)
],
bottomNavi: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
child: MaterialButton(

@ -0,0 +1,13 @@
enum BraceletBrand {
aqg(1, '爱牵挂','assets/bracelet/x5.png');
final int typeNum;
final String name;
final String imgPath;
static BraceletBrand getValue(int value) =>
BraceletBrand.values.firstWhere((element) => element.typeNum == value);
const BraceletBrand(this.typeNum, this.name,this.imgPath);
}

@ -1,7 +1,11 @@
import 'package:aku_new_community/constants/saas_api.dart';
import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:flutter/material.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_new_community/gen/assets.gen.dart';
@ -67,12 +71,25 @@ class _SubmitEquipmentCodePageState extends State<SubmitEquipmentCodePage> {
bottomNavi: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 32.w),
child: MaterialButton(
onPressed: () {
onPressed: () async {
if (_editingController.text.isEmpty) {
BotToast.showText(text: '设备码不能为空');
return;
}
BotToast.showText(text: '请输入正确的设备码');
var base = await NetUtil().post(SAASAPI.bracelet.add, params: {
'type': 1,
'deviceType': 'x5',
'imei': _editingController.text
});
if (base.success) {
Get.back();
Get.back();
if (UserTool.oldAgeProvider.imei.isEmpty) {
UserTool.oldAgeProvider.changeImei(_editingController.text);
}
} else {
BotToast.showText(text: base.msg);
}
},
elevation: 0,
color: Color(0xFF6395D7),

@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
class OldAgeProvider extends ChangeNotifier {
String _imei='';
String get imei => _imei;
void changeImei(String value) {
_imei = value;
notifyListeners();
}
}

@ -96,9 +96,6 @@ class _AdviceDetailPageState extends State<AdviceDetailPage> {
type = '';
break;
case 2:
type = '装修公司';
break;
case 3:
type = '物业';
break;
}

@ -1,4 +1,5 @@
import 'package:aku_new_community/constants/app_theme.dart';
import 'package:aku_new_community/provider/old_age_provider.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
@ -20,5 +21,8 @@ class UserTool {
static MyAppStyle get myAppStyle =>
Theme.of(Get.context!).extension<MyAppStyle>()!;
static OldAgeProvider get oldAgeProvider =>
Provider.of<OldAgeProvider>(Get.context!, listen: false);
UserTool();
}

Loading…
Cancel
Save