更新页面
This commit is contained in:
@@ -5,7 +5,24 @@ part 'blueteeth_bind_controller.g.dart'; // 由json_serializable自动生成的
|
||||
|
||||
@JsonSerializable()
|
||||
class BlueteethBindModel {
|
||||
int read = 1;//是否不再提示教程 0 不再提示 1 需要提示
|
||||
int? read = 1; //是否不再提示教程 0 不再提示 1 需要提示
|
||||
double? singal = -70; //扫描信号强度
|
||||
|
||||
List? devicelist = []; //蓝牙扫描到的设备数据列表
|
||||
List? blelist = []; //蓝牙扫描到的设备数据列表
|
||||
List? wifiList = [];
|
||||
|
||||
List bindArr = ["", "", ""];
|
||||
|
||||
String connectedWifiName = "";
|
||||
|
||||
int connectedRssi = 0;
|
||||
|
||||
String deviceName = "";
|
||||
|
||||
bool? deviceIndex0 = true;
|
||||
bool? deviceIndex1 = false;
|
||||
bool? deviceIndex2 = false;
|
||||
|
||||
BlueteethBindModel();
|
||||
|
||||
@@ -27,5 +44,23 @@ class BlueteethBindModel {
|
||||
class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
BlueteethBindController() {
|
||||
attr = GetModel(BlueteethBindModel()).obs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updateDeviceStatus() {
|
||||
// try {
|
||||
|
||||
// } catch (e) {
|
||||
// print(e);
|
||||
// EasyDartModule.logger.info("向后端请求设备绑定状态报错了:$e");
|
||||
// } finally {
|
||||
// EasyDartModule.logger.info("向后端请求设备绑定状态");
|
||||
// }
|
||||
}
|
||||
|
||||
Future bindDevice(d) async {
|
||||
print("绑定参数:$d");
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
// return ApiService.request
|
||||
// .post("/api/device/info/bind", data: formdata.FormData.fromMap(d));
|
||||
}
|
||||
}
|
||||
|
||||
175
lib/controller/login/login_controller.dart
Normal file
175
lib/controller/login/login_controller.dart
Normal file
@@ -0,0 +1,175 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
part 'login_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class LoginModel {
|
||||
//版本id
|
||||
int? loginStyle = 1; //1.密码登录 2.短信登录
|
||||
String? account = '17649984946'; //账户
|
||||
String? password = 'wyf123,.'; //密码
|
||||
|
||||
String? phone; //手机号
|
||||
String? code; //验证码
|
||||
|
||||
String? register_code;
|
||||
|
||||
bool? showPd = true;
|
||||
|
||||
int? forceLogin = 0;
|
||||
|
||||
bool? isIos; //是否为ios设备
|
||||
|
||||
bool? isWeChatNotInstalled; //是否安装微信
|
||||
|
||||
bool? register_agree = false; //是否同意协议
|
||||
|
||||
LoginModel();
|
||||
|
||||
static LoginModel fromJson(Map<String, dynamic> json) =>
|
||||
_$LoginModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$LoginModelToJson(this);
|
||||
}
|
||||
|
||||
class LoginController extends GetControllerEx<LoginModel> {
|
||||
// 初始化实例
|
||||
// final Fluwx fluwx = Fluwx();
|
||||
// 微信监听返回值
|
||||
// FluwxCancelable? fluwxCancelable;
|
||||
|
||||
// final UserRepository repository = UserRepository();
|
||||
LoginController() {
|
||||
attr = GetModel(LoginModel()).obs;
|
||||
}
|
||||
|
||||
//登录
|
||||
Future<String> login(BuildContext context) async {
|
||||
// return '';
|
||||
String message = '';
|
||||
String account = '';
|
||||
String password = '';
|
||||
// if (model.loginStyle == 1) {
|
||||
// //账号登录
|
||||
// if (model.account == null || model.account!.isEmpty) {
|
||||
// message = '账户不能为空';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.password == null || model.password!.isEmpty) {
|
||||
// message = '密码不能为空';
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// account = model.account!;
|
||||
// password = model.password!;
|
||||
// }
|
||||
// if (model.loginStyle == 2) {
|
||||
// //账号登录
|
||||
// if (model.phone == null || model.phone!.isEmpty) {
|
||||
// message = '手机号不能为空';
|
||||
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (!MyUtils.isValidPhoneNumber(model.phone!)) {
|
||||
// message = '请输入正确的手机号';
|
||||
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// if (model.code == null || model.code!.isEmpty) {
|
||||
// message = '验证码不能为空';
|
||||
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// account = model.phone!;
|
||||
// password = model.code!;
|
||||
// }
|
||||
// RegisterController registerController = Get.find();
|
||||
// if (registerController.model.register_agree == null ||
|
||||
// registerController.model.register_agree != true) {
|
||||
// message = "需要同意协议";
|
||||
// showToast(message);
|
||||
// return message;
|
||||
// }
|
||||
// message = await repository.login(
|
||||
// model.loginStyle!, account, password, model.forceLogin);
|
||||
// model.forceLogin = 0;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
Future<String> getCode(BuildContext context) async {
|
||||
String message = "";
|
||||
if (model.register_agree == null || model.register_agree != true) {
|
||||
// message = "需要同意协议";
|
||||
// showToast(message);
|
||||
return message;
|
||||
}
|
||||
if (model.phone == null || model.phone!.isEmpty) {
|
||||
message = "请输入手机号";
|
||||
// showToast(message);
|
||||
return message;
|
||||
}
|
||||
if (!MyUtils.isValidPhoneNumber(model.phone!)) {
|
||||
message = '请输入正确的手机号';
|
||||
showToast(message);
|
||||
return message;
|
||||
}
|
||||
// message = await repository.sendRegisterCode(model.phone!);
|
||||
if (message.isNotEmpty) {
|
||||
showToast(message ?? "发送失败,请稍后再试!");
|
||||
return "发送失败,请稍后再试!";
|
||||
} else {
|
||||
showToast("发送验证码成功!", color: color_success);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
//微信登录
|
||||
// Future<void> wxLoginSendAuth() async {
|
||||
// /*
|
||||
// 1、目前移动应用上微信登录只提供原生的登录方式,需要用户安装微信客户端才能配合使用。
|
||||
// 2、对于Android应用,建议总是显示微信登录按钮,当用户手机没有安装微信客户端时,请引导用户下载安装微信客户端。
|
||||
// 3、对于iOS应用,考虑到iOS应用商店审核指南中的相关规定,建议开发者接入微信登录时,先检测用户手机是否已安装微信客户端
|
||||
// (使用sdk中isWXAppInstalled函数 ),对未安装的用户隐藏微信登录按钮,只提供其他登录方式(比如手机号注册登录、游客登录等)
|
||||
// */
|
||||
// if (isAndroid) {
|
||||
// bool isWeChatInstalled = await fluwx.isWeChatInstalled;
|
||||
// debugPrint('is wechat installed: $isWeChatInstalled');
|
||||
// if (!isWeChatInstalled) {
|
||||
// showToast("请先安装微信APP,再使用微信登录");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// fluwx
|
||||
// .authBy(
|
||||
// which: NormalAuth(
|
||||
// scope: 'snsapi_userinfo',
|
||||
// state: 'wechat_sdk_zhmht_wxlogin',
|
||||
// ))
|
||||
// .then((data) {
|
||||
// //返回true表示成功或者false表示失败,这边没有意义从login_controller页面构造函数监听中去处理
|
||||
// debugPrint('msg:$data');
|
||||
// });
|
||||
// }
|
||||
|
||||
//退出登录
|
||||
// Future<void> logout() async {
|
||||
// await repository.logout();
|
||||
// }
|
||||
|
||||
// loginByWechatCode(String code) async {
|
||||
// return await repository.loginByWechatCode(code);
|
||||
// }
|
||||
|
||||
//注销账号
|
||||
// deletedAccount() async {
|
||||
// return await repository.deletedAccount();
|
||||
// }
|
||||
}
|
||||
33
lib/controller/login/login_controller.g.dart
Normal file
33
lib/controller/login/login_controller.g.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'login_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
LoginModel _$LoginModelFromJson(Map<String, dynamic> json) => LoginModel()
|
||||
..loginStyle = (json['loginStyle'] as num?)?.toInt()
|
||||
..account = json['account'] as String?
|
||||
..password = json['password'] as String?
|
||||
..phone = json['phone'] as String?
|
||||
..code = json['code'] as String?
|
||||
..register_code = json['register_code'] as String?
|
||||
..showPd = json['showPd'] as bool?
|
||||
..forceLogin = (json['forceLogin'] as num?)?.toInt()
|
||||
..isIos = json['isIos'] as bool?
|
||||
..isWeChatNotInstalled = json['isWeChatNotInstalled'] as bool?;
|
||||
|
||||
Map<String, dynamic> _$LoginModelToJson(LoginModel instance) =>
|
||||
<String, dynamic>{
|
||||
'loginStyle': instance.loginStyle,
|
||||
'account': instance.account,
|
||||
'password': instance.password,
|
||||
'phone': instance.phone,
|
||||
'code': instance.code,
|
||||
'register_code': instance.register_code,
|
||||
'showPd': instance.showPd,
|
||||
'forceLogin': instance.forceLogin,
|
||||
'isIos': instance.isIos,
|
||||
'isWeChatNotInstalled': instance.isWeChatNotInstalled,
|
||||
};
|
||||
@@ -1,8 +1,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/main_page_controller.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
|
||||
class GlobalModel {
|
||||
List deviceList = [];
|
||||
@@ -138,16 +140,11 @@ class GlobalController extends GetControllerEx<GlobalModel> {
|
||||
deviceUpdateTimerCreated() {
|
||||
if (getDeviceListTimer == null) {
|
||||
getDeviceListTimer = Timer.periodic(const Duration(seconds: 10), (t) {
|
||||
if (userInfoController.model.token != null) {
|
||||
|
||||
}
|
||||
if (userInfoController.model.token != null) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
getDeviceGroupName(device) {
|
||||
return "${device['roomName']}/${device["deviceType"]?["name"]}/${device["name"]}";
|
||||
}
|
||||
@@ -169,4 +166,49 @@ class GlobalController extends GetControllerEx<GlobalModel> {
|
||||
model.deviceType = rs.where((d) => d["page"] != null).toList();
|
||||
updateAll();
|
||||
}
|
||||
|
||||
getDeviceList({int time = 1}) async {
|
||||
await EasyDartModule.dio.get("/api/device/info/list").then((d) {
|
||||
Map d_ = {};
|
||||
d.data?["data"]?.forEach((item) {
|
||||
if (d_[item["roomName"]] == null) {
|
||||
d_[item["roomName"]] = [];
|
||||
}
|
||||
d_[item["roomName"]].add(item);
|
||||
});
|
||||
List res_ = [];
|
||||
d_.keys.forEach((key) {
|
||||
res_.addAll(d_[key]);
|
||||
});
|
||||
model.deviceList = res_;
|
||||
if (model.deviceMain != null && model.deviceMain["mac"] != null) {
|
||||
bool isClose = false;
|
||||
model.deviceList.forEach((item) {
|
||||
if (item["mac"] == model.deviceMain["mac"]) {
|
||||
model.deviceMain = item;
|
||||
isClose = true;
|
||||
updateAll();
|
||||
}
|
||||
});
|
||||
if (!isClose) {
|
||||
model.deviceMain = {};
|
||||
updateAll();
|
||||
showCustomConfirmAndCancelDialog(Get.context!, "设备已经被解绑,是否回到主界面?")
|
||||
.then((e) {
|
||||
if (e == "confirm") {
|
||||
Get.find<MainPageController>().model.currentIndex = 0;
|
||||
Get.offAllNamed("/mianPageBottomChange");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
updateAll();
|
||||
}
|
||||
}).catchError((e) {
|
||||
print("$e");
|
||||
if (time > 0) {
|
||||
getDeviceList(time: time - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
33
lib/controller/person/person_controller.dart
Normal file
33
lib/controller/person/person_controller.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'person_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class PersonModel {
|
||||
int read = 1;
|
||||
|
||||
DateTime? birthday;//是否不再提示教程 0 不再提示 1 需要提示
|
||||
|
||||
PersonModel();
|
||||
|
||||
// 从JSON反序列化时的异常处理
|
||||
|
||||
factory PersonModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$PersonModelFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return PersonModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$PersonModelToJson(this);
|
||||
}
|
||||
|
||||
class PersonController extends GetControllerEx<PersonModel> {
|
||||
PersonController() {
|
||||
attr = GetModel(PersonModel()).obs;
|
||||
}
|
||||
}
|
||||
19
lib/controller/person/person_controller.g.dart
Normal file
19
lib/controller/person/person_controller.g.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'person_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PersonModel _$PersonModelFromJson(Map<String, dynamic> json) => PersonModel()
|
||||
..read = (json['read'] as num).toInt()
|
||||
..birthday = json['birthday'] == null
|
||||
? null
|
||||
: DateTime.parse(json['birthday'] as String);
|
||||
|
||||
Map<String, dynamic> _$PersonModelToJson(PersonModel instance) =>
|
||||
<String, dynamic>{
|
||||
'read': instance.read,
|
||||
'birthday': instance.birthday?.toIso8601String(),
|
||||
};
|
||||
33
lib/controller/time/countdown_controller.dart
Normal file
33
lib/controller/time/countdown_controller.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'dart:async';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class CountdownController extends GetxController {
|
||||
var countdown = 0.obs;
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void startCountdown(int seconds) {
|
||||
timer?.cancel(); // 取消之前的定时器
|
||||
countdown.value = seconds;
|
||||
timer = Timer.periodic(Duration(seconds: 1), (timer) {
|
||||
int elapsed = timer.tick;
|
||||
int remaining = seconds - elapsed;
|
||||
if (remaining > 0) {
|
||||
countdown.value = remaining;
|
||||
} else {
|
||||
countdown.value = 0;
|
||||
timer.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
timer?.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'package:vbvs_app/model/user_data.dart';
|
||||
|
||||
|
||||
part 'user_info_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@@ -34,9 +22,13 @@ class UserInfoModel {
|
||||
User? superbase_user;
|
||||
|
||||
String? img_bucket = 'user';
|
||||
int? login = 0;
|
||||
int? login = 1; //0未登录 1 登录
|
||||
|
||||
bool? register_agree = false; //注册协议
|
||||
|
||||
|
||||
int? deviceBindNum = 0; //绑定设备数量
|
||||
|
||||
int? loginPhone = 0;//0 本机号码 1其他手机号
|
||||
|
||||
UserInfoModel();
|
||||
static UserInfoModel fromJson(Map<String, dynamic> json) =>
|
||||
|
||||
@@ -19,8 +19,7 @@ UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
|
||||
..deviceModel = json['deviceModel'] as String?
|
||||
..appVersion = json['appVersion'] as String?
|
||||
..img_bucket = json['img_bucket'] as String?
|
||||
..login = (json['login'] as num?)?.toInt()
|
||||
..register_agree = json['register_agree'] as bool?;
|
||||
..login = (json['login'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$UserInfoModelToJson(UserInfoModel instance) =>
|
||||
<String, dynamic>{
|
||||
@@ -34,5 +33,4 @@ Map<String, dynamic> _$UserInfoModelToJson(UserInfoModel instance) =>
|
||||
'appVersion': instance.appVersion,
|
||||
'img_bucket': instance.img_bucket,
|
||||
'login': instance.login,
|
||||
'register_agree': instance.register_agree,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user