Commit 4d183d79 by tanghuan

Merge branch 'feature-2606-pad' into pad-feature-2607

# Conflicts:
#	lib/bloc/web_cubit.dart
#	lib/ui/pages/web_page.dart
2 parents 780ef5a7 3c3991bc
Showing 144 changed files with 195 additions and 174 deletions
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" /> <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<!-- APP 自动更新:安装未知来源应用 -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application <application
android:label="班小二" android:label="班小二"
...@@ -26,6 +29,7 @@ ...@@ -26,6 +29,7 @@
android:networkSecurityConfig="@xml/network_security_config"> android:networkSecurityConfig="@xml/network_security_config">
<!-- 隐私政策Activity - 启动入口 --> <!-- 隐私政策Activity - 启动入口 -->
<!--
<activity <activity
android:name=".PrivacyActivity" android:name=".PrivacyActivity"
android:exported="true" android:exported="true"
...@@ -36,6 +40,7 @@ ...@@ -36,6 +40,7 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
-->
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
...@@ -53,6 +58,10 @@ ...@@ -53,6 +58,10 @@
android:name="io.flutter.embedding.android.NormalTheme" android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" android:resource="@style/NormalTheme"
/> />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity> </activity>
<!-- Don't delete the meta-data below. <!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
......
...@@ -5,6 +5,7 @@ import android.app.AlertDialog; ...@@ -5,6 +5,7 @@ import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.drawable.GradientDrawable;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
...@@ -16,6 +17,7 @@ import android.text.style.ClickableSpan; ...@@ -16,6 +17,7 @@ import android.text.style.ClickableSpan;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
...@@ -62,30 +64,37 @@ public class PrivacyActivity extends Activity { ...@@ -62,30 +64,37 @@ public class PrivacyActivity extends Activity {
} }
private View createContentView() { private View createContentView() {
// 根布局 // 外层根布局(浅灰色背景,垂直居中)
LinearLayout rootLayout = new LinearLayout(this); FrameLayout rootLayout = new FrameLayout(this);
rootLayout.setOrientation(LinearLayout.VERTICAL);
rootLayout.setGravity(Gravity.CENTER_VERTICAL);
rootLayout.setPadding(dpToPx(32), dpToPx(48), dpToPx(32), dpToPx(48));
rootLayout.setBackgroundColor(0xFFFFFFFF); rootLayout.setBackgroundColor(0xFFFFFFFF);
// 内容容器 // 卡片容器(白色圆角卡片)
LinearLayout contentLayout = new LinearLayout(this); LinearLayout cardLayout = new LinearLayout(this);
contentLayout.setOrientation(LinearLayout.VERTICAL); cardLayout.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams contentLayoutParams = new LinearLayout.LayoutParams( cardLayout.setPadding(dpToPx(28), dpToPx(36), dpToPx(28), dpToPx(36));
LinearLayout.LayoutParams.MATCH_PARENT, GradientDrawable cardBg = new GradientDrawable();
LinearLayout.LayoutParams.WRAP_CONTENT); cardBg.setColor(0xFFFFFFFF);
rootLayout.addView(contentLayout, contentLayoutParams); cardBg.setCornerRadius(dpToPx(16));
cardLayout.setBackground(cardBg);
FrameLayout.LayoutParams cardParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
int cardMarginH = dpToPx(24);
int cardMarginV = dpToPx(80);
cardParams.setMargins(cardMarginH, cardMarginV, cardMarginH, cardMarginV);
cardParams.gravity = Gravity.CENTER_VERTICAL;
rootLayout.addView(cardLayout, cardParams);
// 标题 // 标题
TextView titleView = new TextView(this); TextView titleView = new TextView(this);
titleView.setText("用户协议与隐私政策"); titleView.setText("用户协议与隐私政策");
titleView.setTextSize(22); titleView.setTextSize(23);
titleView.setTextColor(0xFF333333); titleView.setTextColor(0xFF333333);
titleView.setTypeface(null, Typeface.BOLD); titleView.setTypeface(null, Typeface.BOLD);
titleView.setGravity(Gravity.CENTER); titleView.setGravity(Gravity.CENTER);
titleView.setPadding(0, 0, 0, dpToPx(32)); titleView.setPadding(0, 0, 0, dpToPx(28));
contentLayout.addView(titleView); cardLayout.addView(titleView);
// 内容(带可点击链接) // 内容(带可点击链接)
TextView contentView = new TextView(this); TextView contentView = new TextView(this);
...@@ -93,10 +102,10 @@ public class PrivacyActivity extends Activity { ...@@ -93,10 +102,10 @@ public class PrivacyActivity extends Activity {
contentView.setMovementMethod(LinkMovementMethod.getInstance()); contentView.setMovementMethod(LinkMovementMethod.getInstance());
contentView.setHighlightColor(0x00000000); contentView.setHighlightColor(0x00000000);
contentView.setTextSize(17); contentView.setTextSize(17);
contentView.setTextColor(0xFF666666); contentView.setTextColor(0xFF555555);
contentView.setLineSpacing(dpToPx(6), 1.0f); contentView.setLineSpacing(dpToPx(6), 1.0f);
contentView.setGravity(Gravity.START); contentView.setGravity(Gravity.START);
contentLayout.addView(contentView); cardLayout.addView(contentView);
// 按钮容器 // 按钮容器
LinearLayout buttonLayout = new LinearLayout(this); LinearLayout buttonLayout = new LinearLayout(this);
...@@ -105,45 +114,51 @@ public class PrivacyActivity extends Activity { ...@@ -105,45 +114,51 @@ public class PrivacyActivity extends Activity {
LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams.WRAP_CONTENT);
buttonLayoutParams.topMargin = dpToPx(48); buttonLayoutParams.topMargin = dpToPx(32);
contentLayout.addView(buttonLayout, buttonLayoutParams); cardLayout.addView(buttonLayout, buttonLayoutParams);
// 同意按钮 int btnHeight = dpToPx(44);
int btnRadius = dpToPx(22);
// 同意按钮(蓝紫色填充,大圆角)
Button agreeButton = new Button(this); Button agreeButton = new Button(this);
agreeButton.setText("同意"); agreeButton.setText("同意");
agreeButton.setTextColor(0xFFFFFFFF); agreeButton.setTextColor(0xFFFFFFFF);
agreeButton.setBackgroundColor(0xFF4CAF50);
agreeButton.setTextSize(16); agreeButton.setTextSize(16);
agreeButton.setTypeface(null, Typeface.BOLD);
agreeButton.setGravity(Gravity.CENTER); agreeButton.setGravity(Gravity.CENTER);
agreeButton.setSingleLine(true); agreeButton.setSingleLine(true);
agreeButton.setMinWidth(dpToPx(120)); agreeButton.setPadding(0, 0, 0, 0);
agreeButton.setMinHeight(dpToPx(48)); GradientDrawable agreeBg = new GradientDrawable();
int btnPaddingH = dpToPx(24); agreeBg.setColor(0xFF7691FA);
int btnPaddingV = dpToPx(12); agreeBg.setCornerRadius(btnRadius);
agreeButton.setPadding(btnPaddingH, btnPaddingV, btnPaddingH, btnPaddingV); agreeButton.setBackground(agreeBg);
agreeButton.setOnClickListener(v -> onAgreeClicked()); agreeButton.setOnClickListener(v -> onAgreeClicked());
LinearLayout.LayoutParams agreeParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams agreeParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, 0,
LinearLayout.LayoutParams.WRAP_CONTENT); btnHeight,
agreeParams.setMargins(dpToPx(16), 0, dpToPx(16), 0); 1.0f);
agreeParams.setMargins(0, 0, dpToPx(8), 0);
buttonLayout.addView(agreeButton, agreeParams); buttonLayout.addView(agreeButton, agreeParams);
// 不同意按钮 // 不同意按钮(灰色描边,大圆角)
Button disagreeButton = new Button(this); Button disagreeButton = new Button(this);
disagreeButton.setText("不同意"); disagreeButton.setText("不同意");
disagreeButton.setTextColor(0xFF666666); disagreeButton.setTextColor(0xFF666666);
disagreeButton.setBackgroundColor(0xFFEEEEEE);
disagreeButton.setTextSize(16); disagreeButton.setTextSize(16);
disagreeButton.setGravity(Gravity.CENTER); disagreeButton.setGravity(Gravity.CENTER);
disagreeButton.setSingleLine(true); disagreeButton.setSingleLine(true);
disagreeButton.setMinWidth(dpToPx(120)); disagreeButton.setPadding(0, 0, 0, 0);
disagreeButton.setMinHeight(dpToPx(48)); GradientDrawable disagreeBg = new GradientDrawable();
disagreeButton.setPadding(btnPaddingH, btnPaddingV, btnPaddingH, btnPaddingV); disagreeBg.setColor(0xFFF5F6FA);
disagreeBg.setCornerRadius(btnRadius);
disagreeButton.setBackground(disagreeBg);
disagreeButton.setOnClickListener(v -> onDisagreeClicked()); disagreeButton.setOnClickListener(v -> onDisagreeClicked());
LinearLayout.LayoutParams disagreeParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams disagreeParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, 0,
LinearLayout.LayoutParams.WRAP_CONTENT); btnHeight,
disagreeParams.setMargins(dpToPx(16), 0, dpToPx(16), 0); 1.0f);
disagreeParams.setMargins(dpToPx(8), 0, 0, 0);
buttonLayout.addView(disagreeButton, disagreeParams); buttonLayout.addView(disagreeButton, disagreeParams);
return rootLayout; return rootLayout;
...@@ -172,7 +187,7 @@ public class PrivacyActivity extends Activity { ...@@ -172,7 +187,7 @@ public class PrivacyActivity extends Activity {
@Override @Override
public void updateDrawState(TextPaint ds) { public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds); super.updateDrawState(ds);
ds.setColor(0xFF4CAF50); ds.setColor(0xFF7691FA);
ds.setUnderlineText(true); ds.setUnderlineText(true);
} }
}, userAgreementStart, userAgreementEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }, userAgreementStart, userAgreementEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
...@@ -188,7 +203,7 @@ public class PrivacyActivity extends Activity { ...@@ -188,7 +203,7 @@ public class PrivacyActivity extends Activity {
@Override @Override
public void updateDrawState(TextPaint ds) { public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds); super.updateDrawState(ds);
ds.setColor(0xFF4CAF50); ds.setColor(0xFF7691FA);
ds.setUnderlineText(true); ds.setUnderlineText(true);
} }
}, privacyPolicyStart, privacyPolicyEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }, privacyPolicyStart, privacyPolicyEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" /> <item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
<!-- You can insert your own image assets here --> </item>
<!-- <item> <item>
<bitmap <bitmap android:gravity="center" android:src="@drawable/splash"/>
android:gravity="center" </item>
android:src="@mipmap/launch_image" /> <item android:bottom="24dp">
</item> --> <bitmap android:gravity="bottom" android:src="@drawable/branding"/>
</item>
</layer-list> </layer-list>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" /> <item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
<!-- You can insert your own image assets here --> </item>
<!-- <item> <item>
<bitmap <bitmap android:gravity="center" android:src="@drawable/splash"/>
android:gravity="center" </item>
android:src="@mipmap/launch_image" /> <item android:bottom="24dp">
</item> --> <bitmap android:gravity="bottom" android:src="@drawable/branding"/>
</item>
</layer-list> </layer-list>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#FFFFFF</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/android12branding</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
<item name="android:windowSplashScreenIconBackgroundColor">#FFFFFF</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
<!-- Show a splash screen on the activity. Automatically removed when <!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame --> the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item> <item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style> </style>
<!-- Theme applied to the Android Window as soon as the process has started. <!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your This theme determines the color of the Android Window while your
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#FFFFFF</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/android12branding</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
<item name="android:windowSplashScreenIconBackgroundColor">#FFFFFF</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
<!-- Show a splash screen on the activity. Automatically removed when <!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame --> the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item> <item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style> </style>
<!-- Theme applied to the Android Window as soon as the process has started. <!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your This theme determines the color of the Android Window while your
......
...@@ -3,6 +3,7 @@ import 'dart:io'; ...@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:appframe/l10n/gen/app_localizations.dart'; import 'package:appframe/l10n/gen/app_localizations.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'config/routes.dart'; import 'config/routes.dart';
...@@ -10,29 +11,41 @@ class App extends StatelessWidget { ...@@ -10,29 +11,41 @@ class App extends StatelessWidget {
const App({super.key}); const App({super.key});
@override @override
Widget build(BuildContext context) => Platform.isIOS Widget build(BuildContext context) {
? CupertinoApp.router( final Widget app = Platform.isIOS
routerConfig: router, ? CupertinoApp.router(
title: '班小二', routerConfig: router,
theme: const CupertinoThemeData(primaryColor: CupertinoColors.systemBlue), title: '班小二',
localizationsDelegates: AppLocalizations.localizationsDelegates, theme: const CupertinoThemeData(primaryColor: CupertinoColors.systemBlue),
supportedLocales: AppLocalizations.supportedLocales, localizationsDelegates: AppLocalizations.localizationsDelegates,
// // === 为 iOS 添加本地化配置 === supportedLocales: AppLocalizations.supportedLocales,
// localizationsDelegates: const [ )
// GlobalMaterialLocalizations.delegate, // 为Material组件提供本地化 : MaterialApp.router(
// GlobalCupertinoLocalizations.delegate, // 为Cupertino组件提供本地化 routerConfig: router,
// GlobalWidgetsLocalizations.delegate, // 定义文本方向等 title: '班小二',
// ], theme: ThemeData(primarySwatch: Colors.blue),
// supportedLocales: const [ supportedLocales: AppLocalizations.supportedLocales,
// Locale('zh', 'CN'), // 中文(中国) localizationsDelegates: AppLocalizations.localizationsDelegates,
// Locale('en', 'US'), // 英语(美国) // Android edge-to-edge 模式下虚拟导航键叠在内容上方,
// ], // 通过 builder 统一包裹 SafeArea,所有路由页面自动适配底部安全区域。
) builder: (context, child) => ColoredBox(
: MaterialApp.router( color: Colors.white,
routerConfig: router, child: SafeArea(top: false, child: child!),
title: '班小二', ),
theme: ThemeData(primarySwatch: Colors.blue), );
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates, // 全局默认状态栏样式兑底:透明背景 + 深色图标。
); // 作为最外层 AnnotatedRegion 只挂载一次,不会随页面状态变化反复
// 下发命令,避免污染 Android decorView 上 H5 <video> 全屏依赖的
// systemUiVisibility flag。带 AppBar 的页面由 AppBar.systemOverlayStyle
// 在其 region 区域局部覆盖,隐藏 AppBar 后自动回到本全局值。
return AnnotatedRegion<SystemUiOverlayStyle>(
value: const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light,
),
child: app,
);
}
} }
import 'dart:async'; import 'dart:async';
import 'package:appframe/config/constant.dart'; import 'package:app_settings/app_settings.dart';
import 'package:appframe/config/locator.dart'; import 'package:appframe/config/locator.dart';
import 'package:appframe/config/routes.dart'; import 'package:appframe/config/routes.dart';
import 'package:appframe/data/repositories/phone_auth_repository.dart'; import 'package:appframe/data/repositories/phone_auth_repository.dart';
import 'package:appframe/utils/login_util.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
...@@ -102,7 +103,11 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> { ...@@ -102,7 +103,11 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> {
} }
// 发送验证码 // 发送验证码
var result = await _phoneAuthRepository.verifyCode(phone, 0); var result = await _phoneAuthRepository.verifyCode(phone, 1);
if (result == null) {
Fluttertoast.showToast(msg: '发送请求失败', gravity: ToastGravity.TOP, backgroundColor: Colors.red);
return;
}
if (result['code'] != 0) { if (result['code'] != 0) {
final err = result['error'] ?? ''; final err = result['error'] ?? '';
// 手机号未注册时,打开指引界面 // 手机号未注册时,打开指引界面
...@@ -154,97 +159,15 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> { ...@@ -154,97 +159,15 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> {
} }
var data = resultData['data'] as Map<String, dynamic>; var data = resultData['data'] as Map<String, dynamic>;
_handleLoginSuccess(data); int binding = resultData['binding'];
} // binding=1 代表已绑定,不是游客
var visitor = binding == 1 ? 0 : 1;
void _handleLoginSuccess(Map<String, dynamic> data) { if (visitor == 1) {
var roles = data['roles']; var sharedPreferences = getIt.get<SharedPreferences>();
// 过滤出家长角色的数据 sharedPreferences.setString('auth_visitor_type', 'phone');
if (roles?.isNotEmpty ?? false) { sharedPreferences.setString('auth_visitor_id', phone);
roles.removeWhere((element) => element['userType'] != 2);
} else {
roles = [];
}
var sessionCode = data['sessionCode'];
var userCode = data['userCode'];
var classCode = '';
var userType = 0;
var stuId = '';
var className = '';
var stuName = '';
var relation = '';
var sharedPreferences = getIt.get<SharedPreferences>();
if (roles.isNotEmpty) {
var role = roles[0];
classCode = role['classCode'];
userType = role['userType'];
stuId = role['stuId'];
className = role['className'];
stuName = role['stuName'];
relation = role['relation'] ?? '';
// 将角色中的班级数据处理后,进行缓存
List<String> classIdList = [];
for (var role in roles) {
classIdList.add(role['classCode'] as String);
}
debugPrint('classCodeIds:-------------- $classIdList');
sharedPreferences.setStringList(Constant.classIdSetKey, classIdList);
} else {
sharedPreferences.setStringList(Constant.classIdSetKey, []);
}
var preUserCode = sharedPreferences.getString('pre_userCode') ?? '';
if (userCode != preUserCode) {
// 新用户登录
sharedPreferences.setString('pre_userCode', userCode);
sharedPreferences.setString('pre_classCode', classCode);
sharedPreferences.setInt('pre_userType', userType);
sharedPreferences.setString('pre_stuId', stuId);
} else {
// 前一个登录用户重新登录
var preClassCode = sharedPreferences.getString('pre_classCode') ?? '';
var preUserType = sharedPreferences.getInt('pre_userType') ?? 0;
var preStuId = sharedPreferences.getString('pre_stuId') ?? '';
if (preClassCode != '' &&
roles.any((element) =>
element['classCode'] == preClassCode &&
element['userType'] == preUserType &&
element['stuId'] == preStuId)) {
classCode = preClassCode;
userType = preUserType;
stuId = preStuId;
} else {
sharedPreferences.setString('pre_userCode', userCode);
sharedPreferences.setString('pre_classCode', classCode);
sharedPreferences.setInt('pre_userType', userType);
sharedPreferences.setString('pre_stuId', stuId);
}
} }
LoginUtil.handleLoginSuccess(data, visitor, 'router');
sharedPreferences.setString('auth_sessionCode', sessionCode);
sharedPreferences.setString('auth_userCode', userCode);
sharedPreferences.setString('auth_classCode', classCode);
sharedPreferences.setInt('auth_userType', userType);
sharedPreferences.setString('auth_stuId', stuId);
sharedPreferences.setString('auth_className', className);
sharedPreferences.setString('auth_stuName', stuName);
sharedPreferences.setString('auth_relation', relation);
router.go(
'/web',
extra: {
'sessionCode': sessionCode,
'userCode': userCode,
'classCode': classCode,
'userType': userType,
'stuId': stuId,
},
);
} }
void toggleAgreed(bool value) { void toggleAgreed(bool value) {
...@@ -272,6 +195,13 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> { ...@@ -272,6 +195,13 @@ class LoginPhoneCubit extends Cubit<LoginPhoneState> {
router.go('/loginQr'); router.go('/loginQr');
} }
Future<void> openWifiSettings() async {
await AppSettings.openAppSettings(
type: AppSettingsType.wifi,
asAnotherTask: false,
);
}
@override @override
Future<void> close() async { Future<void> close() async {
try { try {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!