|
|
|
@ -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/material.dart';
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
|
|
|
import 'package:qr_flutter/qr_flutter.dart';
|
|
|
|
@ -15,13 +23,73 @@ class OpeningCodePage extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return BeeScaffold(
|
|
|
|
|
bgColor: Colors.white,
|
|
|
|
|
title: '开门码',
|
|
|
|
|
body: Container(
|
|
|
|
|
color: Color(0xfff9f9f9),
|
|
|
|
|
child: ListView(
|
|
|
|
|
body: EasyRefresh(
|
|
|
|
|
firstRefresh: true,
|
|
|
|
|
header: MaterialHeader(),
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
await getQrcode();
|
|
|
|
|
},
|
|
|
|
|
child: _onload
|
|
|
|
|
? Container()
|
|
|
|
|
: ListView(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
@ -51,7 +119,7 @@ class _OpeningCodePageState extends State<OpeningCodePage> {
|
|
|
|
|
width: 460.w,
|
|
|
|
|
child: QrImage(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
data: '智慧社区开门码',
|
|
|
|
|
data: _qrCode,
|
|
|
|
|
size: 460.w,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -62,7 +130,8 @@ class _OpeningCodePageState extends State<OpeningCodePage> {
|
|
|
|
|
),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Color(0xfffffbf6),
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(8.w)),
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.all(Radius.circular(8.w)),
|
|
|
|
|
),
|
|
|
|
|
width: 646.w,
|
|
|
|
|
height: 146.w,
|
|
|
|
@ -90,7 +159,7 @@ class _OpeningCodePageState extends State<OpeningCodePage> {
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 19.w),
|
|
|
|
|
Text(
|
|
|
|
|
'已刷新',
|
|
|
|
|
_overDate ? '已过期' : '已刷新',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 32.sp,
|
|
|
|
|
color: Color(0xff999999),
|
|
|
|
|