fix:修复登录页面报错
This commit is contained in:
parent
42e2e1c88b
commit
52ea9866a8
@ -53,23 +53,27 @@ class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
|
||||
index: 0,
|
||||
),
|
||||
pageView(
|
||||
widget: MessageListPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
logic: logic,
|
||||
index: 1),
|
||||
widget: MessageListPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
logic: logic,
|
||||
index: 1,
|
||||
),
|
||||
pageView(
|
||||
widget: LockMallPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
logic: logic,
|
||||
index: 2),
|
||||
widget: LockMallPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
logic: logic,
|
||||
index: 2,
|
||||
),
|
||||
pageView(
|
||||
widget: MinePersonInfoPage(
|
||||
showAppBar: false,
|
||||
),
|
||||
logic: logic,
|
||||
index: 3),
|
||||
widget: MinePersonInfoPage(
|
||||
showAppBar: false,
|
||||
showAbout: true,
|
||||
),
|
||||
logic: logic,
|
||||
index: 3,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -13,7 +13,10 @@ import 'package:webview_flutter/webview_flutter.dart';
|
||||
import '../../tools/baseGetXController.dart';
|
||||
|
||||
class LockMallLogic extends BaseGetXController {
|
||||
final LockMallState state = LockMallState();
|
||||
late LockMallState state;
|
||||
|
||||
LockMallLogic({required bool allowReturn})
|
||||
: state = LockMallState(allowReturn: allowReturn);
|
||||
|
||||
//获取商城跳转地址
|
||||
Future<void> getMallURLRequest() async {
|
||||
@ -96,7 +99,7 @@ class LockMallLogic extends BaseGetXController {
|
||||
if (canGoBack) {
|
||||
await state.mallWebView.goBack();
|
||||
} else {
|
||||
Get.back();
|
||||
if (state.allowReturn) Get.back();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7,17 +7,16 @@ import 'package:star_lock/tools/titleAppBar.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class LockMallPage extends StatefulWidget {
|
||||
LockMallPage({Key? key, this.showAppBar = true}) : super(key: key);
|
||||
LockMallPage({Key? key, this.showAppBar = true, this.allowReturn = true})
|
||||
: super(key: key);
|
||||
bool showAppBar;
|
||||
bool allowReturn;
|
||||
|
||||
@override
|
||||
State<LockMallPage> createState() => _LockMallPageState();
|
||||
}
|
||||
|
||||
class _LockMallPageState extends State<LockMallPage> {
|
||||
final logic = Get.put(LockMallLogic());
|
||||
final state = Get.find<LockMallLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -28,41 +27,46 @@ class _LockMallPageState extends State<LockMallPage> {
|
||||
// FIXME 如果未登录状态,应先跳转登录页
|
||||
// FIXME url应该使用接口获取,接口名称 “获取商城跳转地址:/mall/getUrl“ POST请求,无参数,需要登录
|
||||
// String url = 'https://ge.mall.star-lock.cn/quick_login?id=4&key=1ffb9d37109b8351ebb04ccfcca02c8e';
|
||||
return PopScope(
|
||||
onPopInvoked: logic.canGoBack,
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: const Color(0xFFFFFFFF),
|
||||
appBar: widget.showAppBar
|
||||
? TitleAppBar(
|
||||
barTitle: getWebTitle(),
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
)
|
||||
: null,
|
||||
body: Obx(() => Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(bottom: 10.w),
|
||||
child: LinearProgressIndicator(
|
||||
value: state.webProgress.value,
|
||||
backgroundColor: Colors.grey,
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<Color>(AppColors.mainColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: WebViewWidget(controller: state.mallWebView),
|
||||
),
|
||||
],
|
||||
))),
|
||||
);
|
||||
return GetBuilder<LockMallLogic>(
|
||||
init: LockMallLogic(allowReturn: widget.allowReturn),
|
||||
builder: (LockMallLogic logic) {
|
||||
return PopScope(
|
||||
onPopInvoked: logic.canGoBack,
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: const Color(0xFFFFFFFF),
|
||||
appBar: widget.showAppBar
|
||||
? TitleAppBar(
|
||||
barTitle: getWebTitle(logic),
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
)
|
||||
: null,
|
||||
body: Obx(() => Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(bottom: 10.w),
|
||||
child: LinearProgressIndicator(
|
||||
value: logic.state.webProgress.value,
|
||||
backgroundColor: Colors.grey,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppColors.mainColor),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: WebViewWidget(
|
||||
controller: logic.state.mallWebView),
|
||||
),
|
||||
],
|
||||
))),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
String getWebTitle() {
|
||||
String getWebTitle(LockMallLogic logic) {
|
||||
String webTitleStr = "配件商城".tr;
|
||||
state.mallWebView.getTitle().then((result) {
|
||||
logic.state.mallWebView.getTitle().then((result) {
|
||||
webTitleStr = result!;
|
||||
});
|
||||
return webTitleStr;
|
||||
|
||||
@ -4,8 +4,11 @@ import 'package:star_lock/webview/webview_logic.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class LockMallState {
|
||||
LockMallState({required this.allowReturn});
|
||||
|
||||
var lockMallUrl = "".obs;
|
||||
var webProgress = 0.0.obs;
|
||||
bool allowReturn;
|
||||
late WebViewController mallWebView = initWebViewController();
|
||||
|
||||
//初始化webView控制器
|
||||
@ -16,5 +19,4 @@ class LockMallState {
|
||||
allWebView.setUserAgent(WebViewLogic.userAgent);
|
||||
return allWebView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart';
|
||||
import 'package:star_lock/tools/custom_bottom_sheet.dart';
|
||||
|
||||
@ -13,8 +14,10 @@ import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
|
||||
class MinePersonInfoPage extends StatefulWidget {
|
||||
MinePersonInfoPage({Key? key, this.showAppBar = true}) : super(key: key);
|
||||
MinePersonInfoPage({Key? key, this.showAppBar = true, this.showAbout = false})
|
||||
: super(key: key);
|
||||
bool showAppBar;
|
||||
bool showAbout;
|
||||
|
||||
@override
|
||||
State<MinePersonInfoPage> createState() => _MinePersonInfoPageState();
|
||||
@ -146,8 +149,28 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
||||
rightTitle: state.mineInfoData.value.countryName != null
|
||||
? state.mineInfoData.value.countryName!
|
||||
: "",
|
||||
isHaveLine: false,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: false)),
|
||||
if (F.isLite == false && widget.showAbout)
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.valueAddedServices!.tr,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.valueAddedServicesPage);
|
||||
},
|
||||
),
|
||||
if (widget.showAbout)
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.about!.tr,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.aboutPage);
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
typedef BlockStrCallback = void Function(dynamic textStr);
|
||||
typedef BlockClickCallback = void Function();
|
||||
|
||||
class LoginInput extends StatelessWidget {
|
||||
TextEditingController? controller;
|
||||
FocusNode? focusNode;
|
||||
@ -24,6 +25,7 @@ class LoginInput extends StatelessWidget {
|
||||
Widget? rightSlot;
|
||||
BlockStrCallback? onchangeAction;
|
||||
BlockClickCallback? onTapAction;
|
||||
|
||||
LoginInput(
|
||||
{Key? key,
|
||||
required this.controller,
|
||||
@ -58,7 +60,7 @@ class LoginInput extends StatelessWidget {
|
||||
onChanged: onchangeAction,
|
||||
onTap: onTapAction,
|
||||
autofocus: false,
|
||||
inputFormatters:inputFormatters,
|
||||
inputFormatters: inputFormatters,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
@ -69,10 +71,12 @@ class LoginInput extends StatelessWidget {
|
||||
hintText: hintText,
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
suffixIcon: isSuffixIcon! ? IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: controller!.clear,
|
||||
) : null,
|
||||
suffixIcon: (isSuffixIcon ?? false)
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: controller!.clear,
|
||||
)
|
||||
: null,
|
||||
//左边图标设置
|
||||
icon: isHaveLeftWidget == true
|
||||
? leftWidget
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user