|
|
@ -1,5 +1,13 @@
|
|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:aku_community/constants/api.dart';
|
|
|
|
|
|
|
|
import 'package:aku_community/utils/network/base_model.dart';
|
|
|
|
|
|
|
|
import 'package:aku_community/utils/network/net_util.dart';
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
|
|
|
|
import 'package:flustars/flustars.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
|
|
import 'package:qr_flutter/qr_flutter.dart';
|
|
|
|
import 'package:qr_flutter/qr_flutter.dart';
|
|
|
@ -15,92 +23,153 @@ class OpeningCodePage extends StatefulWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _OpeningCodePageState extends State<OpeningCodePage> {
|
|
|
|
class _OpeningCodePageState extends State<OpeningCodePage> {
|
|
|
|
|
|
|
|
bool _onload = true;
|
|
|
|
|
|
|
|
late String _qrCode;
|
|
|
|
|
|
|
|
late bool _overDate;
|
|
|
|
|
|
|
|
late EasyRefreshController _refreshController;
|
|
|
|
|
|
|
|
Timer? _overDateTimer;
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
_refreshController = EasyRefreshController();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
|
|
_refreshController.dispose();
|
|
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future getQrcode() async {
|
|
|
|
|
|
|
|
DateTime _currentTime = DateTime.now();
|
|
|
|
|
|
|
|
BaseModel baseModel =
|
|
|
|
|
|
|
|
await NetUtil().get(API.manager.getDoorQrCode, params: {
|
|
|
|
|
|
|
|
"startTime":
|
|
|
|
|
|
|
|
DateUtil.formatDate(_currentTime, format: 'yyyy/MM/dd HH:mm:ss'),
|
|
|
|
|
|
|
|
"endTime": DateUtil.formatDate(_currentTime.add(Duration(minutes: 30)),
|
|
|
|
|
|
|
|
format: 'yyyy/MM/dd HH:mm:ss'),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if ((baseModel.status ?? false) && baseModel.data != null) {
|
|
|
|
|
|
|
|
_qrCode = baseModel.data;
|
|
|
|
|
|
|
|
_onload = false;
|
|
|
|
|
|
|
|
_overDate = false;
|
|
|
|
|
|
|
|
endTimer();
|
|
|
|
|
|
|
|
startTimer();
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
BotToast.showText(text: '网络请求错误');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startTimer() {
|
|
|
|
|
|
|
|
_overDateTimer = Timer.periodic(Duration(minutes: 1), (timer) {
|
|
|
|
|
|
|
|
if (timer.tick >= 5) {
|
|
|
|
|
|
|
|
_overDate = true;
|
|
|
|
|
|
|
|
endTimer();
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
endTimer() {
|
|
|
|
|
|
|
|
_overDateTimer?.cancel();
|
|
|
|
|
|
|
|
_overDateTimer = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return BeeScaffold(
|
|
|
|
return BeeScaffold(
|
|
|
|
|
|
|
|
bgColor: Colors.white,
|
|
|
|
title: '开门码',
|
|
|
|
title: '开门码',
|
|
|
|
body: Container(
|
|
|
|
body: EasyRefresh(
|
|
|
|
color: Color(0xfff9f9f9),
|
|
|
|
firstRefresh: true,
|
|
|
|
child: ListView(
|
|
|
|
header: MaterialHeader(),
|
|
|
|
children: [
|
|
|
|
onRefresh: () async {
|
|
|
|
Container(
|
|
|
|
await getQrcode();
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
},
|
|
|
|
top: 70.w,
|
|
|
|
child: _onload
|
|
|
|
left: 32.w,
|
|
|
|
? Container()
|
|
|
|
right: 32.w,
|
|
|
|
: ListView(
|
|
|
|
bottom: 76.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
|
|
|
horizontal: 20.w,
|
|
|
|
|
|
|
|
vertical: 32.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Color(0xffffffff),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(8.w)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
height: 746.w,
|
|
|
|
|
|
|
|
width: 686.w,
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: 44.w,
|
|
|
|
top: 70.w,
|
|
|
|
bottom: 32.w,
|
|
|
|
left: 32.w,
|
|
|
|
),
|
|
|
|
right: 32.w,
|
|
|
|
height: 460.w,
|
|
|
|
bottom: 76.w,
|
|
|
|
width: 460.w,
|
|
|
|
|
|
|
|
child: QrImage(
|
|
|
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
|
|
|
data: '智慧社区开门码',
|
|
|
|
|
|
|
|
size: 460.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: 29.w,
|
|
|
|
horizontal: 20.w,
|
|
|
|
vertical: 33.w,
|
|
|
|
vertical: 32.w,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Color(0xfffffbf6),
|
|
|
|
color: Color(0xffffffff),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(8.w)),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(8.w)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
width: 646.w,
|
|
|
|
height: 746.w,
|
|
|
|
height: 146.w,
|
|
|
|
width: 686.w,
|
|
|
|
child: Text(
|
|
|
|
child: Column(
|
|
|
|
'扫一扫,你的专属二维码,人人文明出行,路路畅通安宁,智慧社区祝您一路顺风',
|
|
|
|
children: [
|
|
|
|
maxLines: 2,
|
|
|
|
Container(
|
|
|
|
style: TextStyle(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
fontSize: 28.sp,
|
|
|
|
top: 44.w,
|
|
|
|
color: Color(0xff666666),
|
|
|
|
bottom: 32.w,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
height: 460.w,
|
|
|
|
|
|
|
|
width: 460.w,
|
|
|
|
|
|
|
|
child: QrImage(
|
|
|
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
|
|
|
data: _qrCode,
|
|
|
|
|
|
|
|
size: 460.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
|
|
|
horizontal: 29.w,
|
|
|
|
|
|
|
|
vertical: 33.w,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Color(0xfffffbf6),
|
|
|
|
|
|
|
|
borderRadius:
|
|
|
|
|
|
|
|
BorderRadius.all(Radius.circular(8.w)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
width: 646.w,
|
|
|
|
|
|
|
|
height: 146.w,
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
'扫一扫,你的专属二维码,人人文明出行,路路畅通安宁,智慧社区祝您一路顺风',
|
|
|
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
fontSize: 28.sp,
|
|
|
|
|
|
|
|
color: Color(0xff666666),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
Container(
|
|
|
|
),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
Container(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
children: [
|
|
|
|
child: Row(
|
|
|
|
Icon(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
AntDesign.checkcircleo,
|
|
|
|
children: [
|
|
|
|
color: Color(0xffffc40c),
|
|
|
|
Icon(
|
|
|
|
size: 32.sp,
|
|
|
|
AntDesign.checkcircleo,
|
|
|
|
),
|
|
|
|
color: Color(0xffffc40c),
|
|
|
|
SizedBox(width: 19.w),
|
|
|
|
size: 32.sp,
|
|
|
|
Text(
|
|
|
|
),
|
|
|
|
_overDate ? '已过期' : '已刷新',
|
|
|
|
SizedBox(width: 19.w),
|
|
|
|
style: TextStyle(
|
|
|
|
Text(
|
|
|
|
fontSize: 32.sp,
|
|
|
|
'已刷新',
|
|
|
|
color: Color(0xff999999),
|
|
|
|
style: TextStyle(
|
|
|
|
),
|
|
|
|
fontSize: 32.sp,
|
|
|
|
),
|
|
|
|
color: Color(0xff999999),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|