更新登录对接

This commit is contained in:
wyf
2025-04-18 18:13:21 +08:00
parent 1765403f21
commit 850c34b408
40 changed files with 2101 additions and 1745 deletions

View File

@@ -3,9 +3,14 @@ import 'dart:async';
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.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/FitTool.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/model/api_response.dart';
ThemeController themeController = Get.find();
Future<void> initDataEf({String key = ""}) async {
await ef.init(
@@ -16,6 +21,25 @@ Future<void> initDataEf({String key = ""}) async {
}
class MyUtils {
static ApiResponse formatResponse(
ApiResponse res,
String successMsg,
String errorMsg,
) {
if (res.code == HttpStatusCodes.ok) {
// 成功但 msg 为空时填默认成功提示
if (res.msg == null || res.msg!.isEmpty) {
res.msg = successMsg;
}
} else {
// 失败且 msg 为空时填默认失败提示
if (res.msg == null || res.msg!.isEmpty) {
res.msg = errorMsg;
}
}
return res;
}
static String timestampToDateString(int timestamp) {
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
@@ -43,6 +67,13 @@ class MyUtils {
return phoneRegExp.hasMatch(phoneNumber);
}
static bool isValidEmail(String email) {
final RegExp emailRegExp = RegExp(
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
);
return emailRegExp.hasMatch(email);
}
static Future<void> makePhoneCall(String phoneNumber) async {
final Uri launchUri = Uri(
scheme: 'tel',
@@ -114,7 +145,6 @@ showToast(String msg,
// gravity: ToastGravity.CENTER,
// timeInSecForIosWeb: 1,
// backgroundColor: color == null ? color_error : color,
// textColor: Colors.white,
// fontSize: 14.0,
// );
final context = Get.overlayContext; // 获取 Overlay 的上下文
@@ -211,7 +241,7 @@ var closeIconWhite = GestureDetector(
alignment: Alignment.center,
child: Icon(
Icons.close,
color: Colors.white,
color: themeController.currentColor.sc3,
),
),
),
@@ -263,6 +293,7 @@ enum LoadingDialogIcon { ble, wifi, none }
class LoadingDialog {
static show(String name, {LoadingDialogIcon icon = LoadingDialogIcon.none}) {
ThemeController themeController = Get.find();
String iconUrl = "";
if (icon == LoadingDialogIcon.wifi) {
iconUrl = "wifi";
@@ -296,18 +327,18 @@ class LoadingDialog {
Text(
textAlign: TextAlign.center,
name,
style: const TextStyle(
style: TextStyle(
fontSize: 16,
color: Colors.white,
color: themeController.currentColor.sc3,
decoration: TextDecoration.none),
),
SizedBox(
height: 30.rpx,
),
const CircularProgressIndicator(
CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white,
themeController.currentColor.sc3,
),
),
],