站点登录
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||
import 'package:ln_jq_app/common/login_util.dart';
|
||||
import 'package:ln_jq_app/common/model/base_model.dart';
|
||||
import 'package:ln_jq_app/common/styles/theme.dart';
|
||||
import 'package:ln_jq_app/pages/b_page/base_widgets/view.dart';
|
||||
import 'package:ln_jq_app/pages/c_page/base_widgets/view.dart';
|
||||
import 'package:ln_jq_app/pages/login/controller.dart';
|
||||
import 'package:ln_jq_app/storage_service.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
@@ -54,76 +57,77 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
return Container(
|
||||
color: Color(0xFFEFF4F7),
|
||||
child: <Widget>[
|
||||
Icon(cLogin ? AntdIcon.car : AntdIcon.USB),
|
||||
SizedBox(height: 5.h),
|
||||
TextX.bodyLarge(cLogin ? '司机端' : "加氢站", weight: FontWeight.w700),
|
||||
SizedBox(height: 5.h),
|
||||
TextX.bodyLarge(cLogin ? '安全驾驶·智能服务' : "氢能服务·专业运营"),
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15), // 设置圆角弧度
|
||||
),
|
||||
margin: EdgeInsets.all(15),
|
||||
elevation: 4,
|
||||
child: Container(
|
||||
height: cLogin ? 260.h : 320.h,
|
||||
padding: EdgeInsets.all(15),
|
||||
child: // TabBar切换
|
||||
Column(
|
||||
children: [
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(3),
|
||||
child: TabBar(
|
||||
controller: tabController,
|
||||
onTap: (index) {
|
||||
//保证尺寸变化
|
||||
delayed(300, () {
|
||||
switchTab(index);
|
||||
});
|
||||
},
|
||||
// 修改TabBar的选中状态和未选中状态样式
|
||||
labelColor: Colors.white,
|
||||
// 选中时的文字颜色
|
||||
unselectedLabelColor: Colors.black,
|
||||
// 未选中时的文字颜色
|
||||
indicator: BoxDecoration(
|
||||
color: AppTheme.themeColor, // 选中的Tab背景色(模拟卡片式效果)
|
||||
borderRadius: BorderRadius.circular(12), // 卡片的圆角效果
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.blue.withOpacity(0.2),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 6,
|
||||
),
|
||||
Icon(cLogin ? AntdIcon.car : AntdIcon.USB),
|
||||
SizedBox(height: 5.h),
|
||||
TextX.bodyLarge(cLogin ? '司机端' : "加氢站", weight: FontWeight.w700),
|
||||
SizedBox(height: 5.h),
|
||||
TextX.bodyLarge(cLogin ? '安全驾驶·智能服务' : "氢能服务·专业运营"),
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15), // 设置圆角弧度
|
||||
),
|
||||
margin: EdgeInsets.all(15),
|
||||
elevation: 4,
|
||||
child: Container(
|
||||
height: cLogin ? 260.h : 320.h,
|
||||
padding: EdgeInsets.all(15),
|
||||
child: // TabBar切换
|
||||
Column(
|
||||
children: [
|
||||
Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(3),
|
||||
child: TabBar(
|
||||
controller: tabController,
|
||||
onTap: (index) {
|
||||
//保证尺寸变化
|
||||
delayed(300, () {
|
||||
switchTab(index);
|
||||
});
|
||||
},
|
||||
// 修改TabBar的选中状态和未选中状态样式
|
||||
labelColor: Colors.white,
|
||||
// 选中时的文字颜色
|
||||
unselectedLabelColor: Colors.black,
|
||||
// 未选中时的文字颜色
|
||||
indicator: BoxDecoration(
|
||||
color: AppTheme.themeColor, // 选中的Tab背景色(模拟卡片式效果)
|
||||
borderRadius: BorderRadius.circular(12), // 卡片的圆角效果
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.blue.withOpacity(0.2),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 6,
|
||||
),
|
||||
],
|
||||
),
|
||||
tabs: [
|
||||
Tab(text: '司机端登录'),
|
||||
Tab(text: '加氢站登录'),
|
||||
],
|
||||
isScrollable: false,
|
||||
),
|
||||
tabs: [
|
||||
Tab(text: '司机端登录'),
|
||||
Tab(text: '加氢站登录'),
|
||||
],
|
||||
isScrollable: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 根据选择的Tab展示不同的输入框
|
||||
Flexible(
|
||||
child: TabBarView(
|
||||
controller: tabController,
|
||||
children: [
|
||||
// 司机端登录
|
||||
_driverLoginView(controller),
|
||||
// 加氢站登录
|
||||
_stationLoginView(controller),
|
||||
],
|
||||
// 根据选择的Tab展示不同的输入框
|
||||
Flexible(
|
||||
child: TabBarView(
|
||||
controller: tabController,
|
||||
children: [
|
||||
// 司机端登录
|
||||
_driverLoginView(controller),
|
||||
// 加氢站登录
|
||||
_stationLoginView(controller),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
].toColumn(mainAxisSize: MainAxisSize.min).center(),);
|
||||
].toColumn(mainAxisSize: MainAxisSize.min).center(),
|
||||
);
|
||||
}
|
||||
|
||||
// 司机端登录界面
|
||||
@@ -151,14 +155,12 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// 司机端登录
|
||||
Get.offAll(() => BaseWidgetsPage());
|
||||
Get.offAll(() => BaseWidgetsPage());
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.themeColor,
|
||||
minimumSize: Size(double.infinity, 50), // 设置按钮宽度占满,指定最小高度
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: Text('登录'),
|
||||
),
|
||||
@@ -215,13 +217,60 @@ class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMix
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.themeColor,
|
||||
minimumSize: Size(double.infinity, 50), // 设置按钮宽度占满,指定最小高度
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
// 加氢站登录逻辑
|
||||
Get.offAll(() => B_BaseWidgetsPage());
|
||||
String account = controller.stationIdController.text;
|
||||
String password = controller.passwordController.text;
|
||||
|
||||
//todo 删除
|
||||
account = "000017";
|
||||
password = "LnQn.314000";
|
||||
|
||||
if (account.isEmpty || password.isEmpty) {
|
||||
showToast("请输入账号和密码");
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading('登录中...');
|
||||
|
||||
try {
|
||||
// 对密码进行AES加密
|
||||
String encryptedPassword = LoginUtil.encrypt(password);
|
||||
|
||||
// 调用登录接口
|
||||
var responseData = await HttpService.to.post(
|
||||
'/login/password',
|
||||
data: {
|
||||
'account': account,
|
||||
'password': encryptedPassword,
|
||||
'loginType': "station",
|
||||
},
|
||||
);
|
||||
|
||||
if (responseData == null && responseData!.data == null) {
|
||||
dismissLoading();
|
||||
showToast('登录失败:无法获取凭证');
|
||||
return;
|
||||
}
|
||||
|
||||
final responseMap = responseData.data as Map<String, dynamic>;
|
||||
|
||||
//保存用户信息
|
||||
String token = responseMap['token'] ?? '';
|
||||
//hydrogenId
|
||||
String userId = responseMap['userId'] ?? '';
|
||||
await StorageService.to.saveLoginInfo(token: token, userId: userId);
|
||||
|
||||
dismissLoading();
|
||||
showToast('登录成功,欢迎您');
|
||||
HttpService.to.setAuthorization(token);
|
||||
// 跳转到主页,并清除所有历史页面
|
||||
Get.offAll(() => B_BaseWidgetsPage());
|
||||
} catch (e) {
|
||||
dismissLoading();
|
||||
}
|
||||
},
|
||||
child: Text('登录'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user