欢迎页 登录

This commit is contained in:
2026-01-27 09:21:36 +08:00
parent 907983a1d1
commit 5ffaf81223
6 changed files with 434 additions and 239 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:get_storage/get_storage.dart'; import 'package:get_storage/get_storage.dart';
@@ -8,8 +9,8 @@ import 'package:ln_jq_app/storage_service.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'common/styles/theme.dart'; import 'common/styles/theme.dart';
import 'pages/home/view.dart';
import 'pages/login/view.dart'; import 'pages/login/view.dart';
import 'pages/welcome/view.dart'; // 引入启动页
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@@ -17,8 +18,10 @@ void main() async {
WidgetsBinding widgetsBinding = await init( WidgetsBinding widgetsBinding = await init(
isDebug: true, isDebug: true,
logTag: '小羚羚', logTag: '小羚羚',
supportedLocales: [Locale('zh', 'CN')], supportedLocales: [const Locale('zh', 'CN')],
); );
// 保持原生闪屏页,直到 WelcomeController 调用 remove()
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
await GetStorage.init(); await GetStorage.init();
@@ -28,36 +31,24 @@ void main() async {
runApp( runApp(
GetxApp( GetxApp(
// 设计稿尺寸 单位dp
designSize: const Size(390, 844), designSize: const Size(390, 844),
// Getx Log
enableLog: true, enableLog: true,
// 默认的跳转动画
defaultTransition: Transition.rightToLeft, defaultTransition: Transition.rightToLeft,
// 主题模式
themeMode: GlobalService.to.themeMode, themeMode: GlobalService.to.themeMode,
// 主题
theme: AppTheme.light, theme: AppTheme.light,
// Dark主题
darkTheme: AppTheme.light, darkTheme: AppTheme.light,
// AppTitle
title: '小羚羚', title: '小羚羚',
// 首页入口 // 将入口改为启动页
home: HomePage(), home: const WelcomePage(),
//组件国际化 fallbackLocale: const Locale('zh', 'CN'),
fallbackLocale: Locale('zh', 'CN'), supportedLocales: const [Locale('zh', 'CN')],
supportedLocales: [Locale('zh', 'CN')],
localizationsDelegates: const [ localizationsDelegates: const [
//pull_to_refresh
RefreshLocalizations.delegate, RefreshLocalizations.delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate, GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
], ],
// Builder
builder: (context, widget) { builder: (context, widget) {
// do something....
return widget!; return widget!;
}, },
), ),
@@ -67,20 +58,16 @@ void main() async {
void initHttpSet() { void initHttpSet() {
AppTheme.test_service_url = StorageService.to.hostUrl ?? AppTheme.test_service_url; AppTheme.test_service_url = StorageService.to.hostUrl ?? AppTheme.test_service_url;
// 设置基础 URL
HttpService.to.setBaseUrl(AppTheme.test_service_url); HttpService.to.setBaseUrl(AppTheme.test_service_url);
//指定请求头
HttpService.to.dio.interceptors.add(TokenInterceptor(tokenKey: 'asoco-token')); HttpService.to.dio.interceptors.add(TokenInterceptor(tokenKey: 'asoco-token'));
// 设置全局响应处理器
HttpService.to.setOnResponseHandler((response) async { HttpService.to.setOnResponseHandler((response) async {
try { try {
final baseModel = BaseModel.fromJson(response.data); final baseModel = BaseModel.fromJson(response.data);
if (baseModel.code == 0 || baseModel.code == 200) { if (baseModel.code == 0 || baseModel.code == 200) {
return null; return null;
} else if (baseModel.code == 401) { } else if (baseModel.code == 401) {
await StorageService.to.clearLoginInfo(); await StorageService.to.clearLoginInfo();
Get.offAll(() => LoginPage()); Get.offAll(() => const LoginPage());
return baseModel.message; return baseModel.message;
} else { } else {
return (baseModel.error.toString()).isEmpty return (baseModel.error.toString()).isEmpty

View File

@@ -13,11 +13,10 @@ class LoginController extends GetxController with BaseControllerMixin {
final TextEditingController phoneController = TextEditingController(); final TextEditingController phoneController = TextEditingController();
final TextEditingController codeController = TextEditingController(); final TextEditingController codeController = TextEditingController();
// 兼容旧逻辑
final TextEditingController driverIdentityController = TextEditingController();
final TextEditingController stationIdController = TextEditingController(); final TextEditingController stationIdController = TextEditingController();
final TextEditingController passwordController = TextEditingController(); final TextEditingController passwordController = TextEditingController();
// --- 倒计时逻辑 --- // --- 倒计时逻辑 ---
final RxInt countdown = 0.obs; final RxInt countdown = 0.obs;
Timer? _timer; Timer? _timer;
@@ -75,6 +74,9 @@ class LoginController extends GetxController with BaseControllerMixin {
_timer?.cancel(); _timer?.cancel();
phoneController.dispose(); phoneController.dispose();
codeController.dispose(); codeController.dispose();
stationIdController.dispose();
passwordController.dispose();
super.onClose(); super.onClose();
} }
} }

View File

@@ -24,119 +24,165 @@ class LoginPage extends StatefulWidget {
State<LoginPage> createState() => _LoginPageState(); State<LoginPage> createState() => _LoginPageState();
} }
class _LoginPageState extends State<LoginPage> { class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMixin {
late TabController _tabController;
bool _isAgreed = false;
bool _obscureText = true;
bool _rememberPassword = true;
bool _credentialsLoaded = false;
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
_tabController.addListener(() {
if (!_tabController.indexIsChanging) {
setState(() {});
}
});
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<LoginController>( return GetBuilder<LoginController>(
init: LoginController(), init: LoginController(),
id: 'login', id: 'login',
builder: (controller) { builder: (controller) {
// 站点登录凭证回填逻辑
if (!_credentialsLoaded) {
final savedAccount = StorageService.to.stationAccount;
final savedPassword = StorageService.to.stationPassword;
if (savedAccount != null && savedPassword != null) {
controller.stationIdController.text = savedAccount;
controller.passwordController.text = savedPassword;
_rememberPassword = true;
}
_credentialsLoaded = true;
}
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: Stack( body: GestureDetector(
children: [ onTap: () {
// 1. 顶部背景与装饰 hideKeyboard();
Positioned( },
top: 0, child: Stack(
left: 0, children: [
right: 0, // 1. 顶部背景与装饰
child: LoginUtil.getAssImg("bg_login"), Positioned(
), top: 0,
Positioned( left: 0,
top: 0, right: 0,
left: 0, child: LoginUtil.getAssImg("bg_login"),
child: SizedBox(
width: 180.w,
height: 218.h,
child: LoginUtil.getAssImg("ic_login_bg@2x"),
), ),
), Positioned(
_buildBackground(), top: 0,
// 2. 登录表单主体 left: 0,
Positioned( child: SizedBox(
top: 280.h, width: 180.w,
left: 0, height: 218.h,
right: 0, child: LoginUtil.getAssImg("ic_login_bg@2x"),
bottom: 0,
child: Container(
height: MediaQuery.of(context).size.height * 2 / 3,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40),
topRight: Radius.circular(40),
),
), ),
child: SingleChildScrollView( ),
child: Padding( _buildBrandingHeader(),
padding: EdgeInsets.symmetric(horizontal: 30.w),
child: Column( // 2. 登录表单主体
crossAxisAlignment: CrossAxisAlignment.start, Positioned(
children: [ top: 280.h,
SizedBox(height: 80.h), left: 0,
// 登录输入区域 right: 0,
_buildLoginInputFields(controller), bottom: 0,
SizedBox(height: 40.h), child: Container(
// 协议 decoration: const BoxDecoration(
buildAgreement(), color: Colors.white,
SizedBox(height: 80.h), borderRadius: BorderRadius.only(
// 底部 Slogan topLeft: Radius.circular(40),
Center( topRight: Radius.circular(40),
),
),
child: Column(
children: [
const SizedBox(height: 20),
// TabBar 切换
Container(
margin: EdgeInsets.symmetric(horizontal: 60.w),
child: TabBar(
controller: _tabController,
indicatorColor: const Color(0xFF006633),
indicatorWeight: 3,
labelColor: const Color(0xFF006633),
unselectedLabelColor: Colors.grey,
labelStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
tabs: const [
Tab(text: "司机登录"),
Tab(text: "站点登录"),
],
),
),
Expanded(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 30.w),
child: Column( child: Column(
children: [ children: [
Text( const SizedBox(height: 30),
"H Y P A I", // 根据 Tab 显示不同的输入框
style: TextStyle( _tabController.index == 0
fontSize: 16, ? _buildDriverInputFields(controller)
fontWeight: FontWeight.w400, : _buildStationInputFields(controller),
color: Color.fromRGBO(51, 51, 51, 1),
letterSpacing: 8, const SizedBox(height: 30),
), // 统一登录按钮
), _buildLoginButton(controller),
Text(
"HYDROGEN MOBILITY", const SizedBox(height: 10),
style: TextStyle( buildAgreement(),
fontSize: 9, const SizedBox(height: 40),
color: Colors.grey.shade400, _buildFooterSlogan(),
letterSpacing: 1, const SizedBox(height: 20),
),
),
], ],
), ),
), ),
], ),
), ],
), ),
), ),
), ),
),
if (AppTheme.is_show_host) if (AppTheme.is_show_host)
Positioned( Positioned(
top: 40.h, top: 40.h,
right: 20.w, right: 20.w,
child: TextButton( child: TextButton(
onPressed: () { onPressed: () => Get.to(() => const UrlHostPage()),
Get.to(() => UrlHostPage()); child: const Text(
}, "域名配置",
child: const Text( style: TextStyle(
"域名配置", color: Colors.black,
style: TextStyle( fontSize: 16,
color: Colors.black, fontWeight: FontWeight.bold,
fontSize: 16, ),
fontWeight: FontWeight.bold,
), ),
), ),
), ),
), ],
], ),
), ),
); );
}, },
); );
} }
/// 构建背景装饰 /// 品牌头部
Widget _buildBackground() { Widget _buildBrandingHeader() {
return Positioned( return Positioned(
top: 0, top: 0,
left: 32.w, left: 32.w,
@@ -145,7 +191,6 @@ class _LoginPageState extends State<LoginPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox(height: 100.h), SizedBox(height: 100.h),
// Logo
SizedBox(height: 60.h, child: LoginUtil.getAssImg('ic_logo_unbg@2x')), SizedBox(height: 60.h, child: LoginUtil.getAssImg('ic_logo_unbg@2x')),
SizedBox(height: 30.h), SizedBox(height: 30.h),
const Text( const Text(
@@ -170,7 +215,7 @@ class _LoginPageState extends State<LoginPage> {
Container( Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color.fromRGBO(56, 198, 151, 1), color: const Color.fromRGBO(56, 198, 151, 1),
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
), ),
child: const Text( child: const Text(
@@ -189,50 +234,32 @@ class _LoginPageState extends State<LoginPage> {
); );
} }
/// 构建登录输入框区域 /// 司机登录输入框 (手机号+验证码)
Widget _buildLoginInputFields(LoginController controller) { Widget _buildDriverInputFields(LoginController controller) {
return Column( return Column(
children: [ children: [
// 手机号输入 _buildInputWrapper(
Container(
height: 55.h,
decoration: BoxDecoration(
color: const Color(0xFFF7F9FB),
borderRadius: BorderRadius.circular(28),
),
child: TextField( child: TextField(
controller: controller.phoneController, controller: controller.phoneController,
keyboardType: TextInputType.phone, keyboardType: TextInputType.phone,
style: const TextStyle(fontSize: 15),
decoration: const InputDecoration( decoration: const InputDecoration(
hintText: '请输入手机号', hintText: '请输入手机号',
hintStyle: TextStyle(color: Colors.grey, fontSize: 14),
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 24), contentPadding: EdgeInsets.symmetric(horizontal: 24),
), ),
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// 验证码输入 _buildInputWrapper(
Container(
height: 55.h,
decoration: BoxDecoration(
color: const Color(0xFFF7F9FB),
borderRadius: BorderRadius.circular(28),
),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: TextField( child: TextField(
inputFormatters: [
LengthLimitingTextInputFormatter(6), // 最多6位
],
controller: controller.codeController, controller: controller.codeController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
style: const TextStyle(fontSize: 15), inputFormatters: [LengthLimitingTextInputFormatter(6)],
decoration: const InputDecoration( decoration: const InputDecoration(
hintText: '请输入验证码', hintText: '请输入验证码',
hintStyle: TextStyle(color: Colors.grey, fontSize: 14),
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 24), contentPadding: EdgeInsets.symmetric(horizontal: 24),
), ),
@@ -248,7 +275,7 @@ class _LoginPageState extends State<LoginPage> {
child: Text( child: Text(
controller.countdown.value == 0 controller.countdown.value == 0
? "获取验证码" ? "获取验证码"
: "${controller.countdown.value}s后重新获取", : "${controller.countdown.value}s后重",
style: TextStyle( style: TextStyle(
color: controller.countdown.value == 0 color: controller.countdown.value == 0
? const Color(0xFF006633) ? const Color(0xFF006633)
@@ -263,27 +290,97 @@ class _LoginPageState extends State<LoginPage> {
], ],
), ),
), ),
const SizedBox(height: 40), ],
// 登录按钮 );
ElevatedButton( }
onPressed: () => _handleLogin(controller),
style: ElevatedButton.styleFrom( /// 站点登录输入框 (账号+密码)
backgroundColor: const Color(0xFF006633), Widget _buildStationInputFields(LoginController controller) {
foregroundColor: Colors.white, return Column(
minimumSize: const Size(double.infinity, 55), children: [
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)), _buildInputWrapper(
elevation: 0, child: TextField(
controller: controller.stationIdController,
decoration: const InputDecoration(
hintText: '请输入加氢站编号',
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 24),
),
), ),
child: const Text( ),
"立即登录", const SizedBox(height: 20),
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), _buildInputWrapper(
child: Row(
children: [
Expanded(
child: TextField(
controller: controller.passwordController,
obscureText: _obscureText,
decoration: const InputDecoration(
hintText: '请输入密码',
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 24),
),
),
),
IconButton(
icon: Icon(
_obscureText ? Icons.visibility_off : Icons.visibility,
color: Colors.grey,
),
onPressed: () => setState(() => _obscureText = !_obscureText),
),
],
), ),
), ),
const SizedBox(height: 10),
Row(
children: [
SizedBox(
width: 40,
child: Checkbox(
value: _rememberPassword,
activeColor: const Color(0xFF006633),
onChanged: (val) => setState(() => _rememberPassword = val ?? false),
),
),
const Text("记住密码", style: TextStyle(color: Colors.grey, fontSize: 14)),
],
),
], ],
); );
} }
/// 处理登录逻辑 /// 通用输入框包装
Widget _buildInputWrapper({required Widget child}) {
return Container(
height: 55.h,
decoration: BoxDecoration(
color: const Color(0xFFF7F9FB),
borderRadius: BorderRadius.circular(28),
),
child: child,
);
}
/// 统一登录按钮逻辑
Widget _buildLoginButton(LoginController controller) {
return ElevatedButton(
onPressed: () => _handleLogin(controller),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF006633),
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 55),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)),
elevation: 0,
),
child: Text(
_tabController.index == 0 ? "司机登录" : "站点登录",
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
);
}
void _handleLogin(LoginController controller) async { void _handleLogin(LoginController controller) async {
if (!_isAgreed) { if (!_isAgreed) {
DialogX.to.showConfirmDialog( DialogX.to.showConfirmDialog(
@@ -298,10 +395,16 @@ class _LoginPageState extends State<LoginPage> {
); );
return; return;
} }
_tabController.index == 0
? _handleDriverLogin(controller)
: _handleStationLogin(controller);
}
/// 司机登录逻辑 (短信登录)
void _handleDriverLogin(LoginController controller) async {
if (!_validateAgreed()) return;
String phone = controller.phoneController.text; String phone = controller.phoneController.text;
String code = controller.codeController.text; String code = controller.codeController.text;
if (phone.isEmpty || !phone.isPhoneNumber) { if (phone.isEmpty || !phone.isPhoneNumber) {
showToast("请输入正确的手机号"); showToast("请输入正确的手机号");
return; return;
@@ -317,86 +420,110 @@ class _LoginPageState extends State<LoginPage> {
'appointment/login/login', 'appointment/login/login',
data: {'mobile': phone, 'code': code}, data: {'mobile': phone, 'code': code},
); );
if (responseData == null && responseData!.data == null) { _processLoginResponse(responseData, "driver", phone);
dismissLoading();
showToast('登录失败:无法获取凭证');
return;
}
//登录信息处理
try {
var result = BaseModel.fromJson(responseData.data);
if (result.code != 0) {
showToast(result.error);
dismissLoading();
return;
}
//类型2是司机 1是站点
String loginType = result.data['loginType'].toString() ?? '';
String token = result.data['token'] ?? '';
if (loginType == "2") {
String idCard = result.data['idCard'] ?? '';
String name = result.data['name'] ?? '';
String phone = result.data['phone'] ?? '';
await StorageService.to.saveLoginInfo(
token: token,
userId: "",
channel: "driver",
idCard: idCard,
name: name,
phone: phone,
);
//司机登录后查询已绑定车辆信息
var carInfo = await HttpService.to.get(
"appointment/driver/getTruckInfoByDriver?phone=$phone",
);
if (carInfo != null) {
var carInforesult = BaseModel.fromJson(carInfo.data);
if (carInforesult.data != null) {
final vehicle = VehicleInfo.fromJson(
carInforesult.data as Map<String, dynamic>,
);
//保存使用
await StorageService.to.saveVehicleInfo(vehicle);
}
}
}
if (loginType == "1") {
String userId = result.data['userId'] ?? '';
String mobile = result.data['mobile'] ?? '';
await StorageService.to.saveLoginInfo(
token: token,
userId: userId,
phone: mobile,
channel: "station",
);
}
//注册推送别名
addAlias(phone);
//页面操作
dismissLoading();
showToast('登录成功,欢迎您');
if (loginType == "2") {
Get.offAll(() => BaseWidgetsPage());
} else {
Get.offAll(() => B_BaseWidgetsPage());
}
} catch (e) {
dismissLoading();
showToast('登录失败:数据异常');
}
} catch (e) { } catch (e) {
dismissLoading(); dismissLoading();
} }
} }
bool _isAgreed = false; /// 站点登录逻辑 (账号密码)
void _handleStationLogin(LoginController controller) async {
if (!_validateAgreed()) return;
String account = controller.stationIdController.text;
String password = controller.passwordController.text;
if (account.isEmpty || password.isEmpty) {
showToast("请输入账号和密码");
return;
}
showLoading('登录中...');
try {
String encryptedPassword = LoginUtil.encrypt(password);
var responseData = await HttpService.to.post(
'appointment/login/password',
data: {'account': account, 'password': encryptedPassword, 'loginType': "station"},
);
if (_rememberPassword) {
await StorageService.to.saveStationCredentials(account, password);
} else {
await StorageService.to.clearStationCredentials();
}
_processLoginResponse(responseData, "station", account);
} catch (e) {
dismissLoading();
}
}
bool _validateAgreed() {
if (!_isAgreed) {
DialogX.to.showConfirmDialog(
icon: DialogIcon.warn,
message: '请阅读并同意用户协议和隐私政策',
confirmText: '确定',
onConfirm: () {},
);
return false;
}
return true;
}
void _processLoginResponse(
dynamic responseData,
String channel,
String identifier,
) async {
if (responseData == null || responseData.data == null) {
dismissLoading();
showToast('登录失败');
return;
}
var result = BaseModel.fromJson(responseData.data);
if (result.code != 0) {
showToast(result.error);
dismissLoading();
return;
}
String token = result.data['token'] ?? '';
if (channel == "driver") {
await StorageService.to.saveLoginInfo(
token: token,
userId: "",
channel: "driver",
name: result.data['name'],
phone: result.data['phone'],
);
// 成功后自动获取车辆信息
var carInfo = await HttpService.to.get(
"appointment/driver/getTruckInfoByDriver?phone=${result.data['phone']}",
);
if (carInfo != null) {
var carResult = BaseModel.fromJson(carInfo.data);
if (carResult.data != null)
await StorageService.to.saveVehicleInfo(VehicleInfo.fromJson(carResult.data));
}
dismissLoading();
Get.offAll(() => BaseWidgetsPage());
} else {
await StorageService.to.saveLoginInfo(
token: token,
userId: result.data['userId'],
phone: result.data['mobile'],
channel: "station",
);
dismissLoading();
Get.offAll(() => B_BaseWidgetsPage());
}
addAlias(identifier);
}
final _aliyunPush = AliyunPushFlutter();
void addAlias(String alias) async {
await _aliyunPush.addAlias(alias);
}
Widget buildAgreement() { Widget buildAgreement() {
return Padding( return Padding(
@@ -478,17 +605,30 @@ class _LoginPageState extends State<LoginPage> {
Get.to(() => const WebViewPage(), arguments: {'title': title, 'url': url}); Get.to(() => const WebViewPage(), arguments: {'title': title, 'url': url});
} }
final _aliyunPush = AliyunPushFlutter(); Widget _buildFooterSlogan() {
return Center(
void addAlias(String alias) async { child: Column(
var result = await _aliyunPush.addAlias(alias); children: [
var code = result['code']; Text(
if (code == kAliyunPushSuccessCode) { "H Y P A I",
Logger.d('添加别名$alias成功'); style: TextStyle(
} else { fontSize: 16,
var errorCode = result['code']; fontWeight: FontWeight.w400,
var errorMsg = result['errorMsg']; color: const Color.fromRGBO(51, 51, 51, 1),
Logger.d('添加别名$alias失败: $errorCode - $errorMsg'); letterSpacing: 8,
} ),
),
Text(
"HYDROGEN MOBILITY",
style: TextStyle(
fontWeight: FontWeight.w300,
fontSize: 9,
color: Colors.grey.shade400,
letterSpacing: 1,
),
),
],
),
);
} }
} }

View File

@@ -0,0 +1,32 @@
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:get/get.dart';
import 'package:ln_jq_app/pages/home/view.dart';
import 'package:ln_jq_app/pages/login/view.dart';
import 'package:ln_jq_app/storage_service.dart';
class WelcomeController extends GetxController {
@override
void onReady() {
super.onReady();
// 移除原生闪屏页(如果有的话)
FlutterNativeSplash.remove();
_startTimer();
}
void _startTimer() {
// 1.5秒后执行跳转逻辑
Future.delayed(const Duration(milliseconds: 1500), () {
Get.offAll(() => const HomePage());
});
}
void _jumpToNextPage() {
if (StorageService.to.isLoggedIn) {
// 已登录,跳转到首页
Get.offAll(() => const HomePage());
} else {
// 未登录,跳转到登录页
Get.offAll(() => const LoginPage());
}
}
}

View File

@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ln_jq_app/common/login_util.dart';
import 'controller.dart';
class WelcomePage extends GetView<WelcomeController> {
const WelcomePage({super.key});
@override
Widget build(BuildContext context) {
// 初始化控制器
Get.put(WelcomeController());
return Scaffold(
backgroundColor: Colors.white,
body: SizedBox.expand(
child: Stack(
children: [
Positioned(
top: 0,
bottom: 0,
left: 0,
right: 0,
child: Image.asset(
'assets/images/welcome.png',
fit: BoxFit.fill
),
),
],
),
),
);
}
}